Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apollo Graphql自定义标量JSON-抱怨;TypeError:type.getFields不是函数;_Json_Graphql_Graphql Js_Apollo - Fatal编程技术网

Apollo Graphql自定义标量JSON-抱怨;TypeError:type.getFields不是函数;

Apollo Graphql自定义标量JSON-抱怨;TypeError:type.getFields不是函数;,json,graphql,graphql-js,apollo,Json,Graphql,Graphql Js,Apollo,我正在使用apollo express graphql服务器。我试图集成模块“graphql type json”,但当我继续学习如何集成时,我尝试了很多方法,但似乎没有正确地将该类型传递给解析器——但我在调试中遇到了困难,需要一些帮助。下面是我所做工作的总结 import { makeExecutableSchema } from 'graphql-tools'; const GraphQLJSON = require('graphql-type-json'); //Have also tri

我正在使用apollo express graphql服务器。我试图集成模块“graphql type json”,但当我继续学习如何集成时,我尝试了很多方法,但似乎没有正确地将该类型传递给解析器——但我在调试中遇到了困难,需要一些帮助。下面是我所做工作的总结

import { makeExecutableSchema } from 'graphql-tools';
const GraphQLJSON = require('graphql-type-json');
//Have also tried import GraphQLJSON from 'graphql-type-json';

const schema = `
scalar JSON

type Device {
  deviceconfig: JSON
}

type Query {
  foo: Foo
}
`;

const resolveFunctions = {
   JSON: GraphQLJSON,
   //JSON: {return GraphQLJSON} stops error but other issues come up...
   Query: ...
 };

const jsSchema = makeExecutableSchema({
typeDefs: schema,
resolvers: resolveFunctions,
resolverValidationOptions: {
  requireResolversForNonScalar: false,
},
allowUndefinedInResolve: true,
printErrors: true,
});
不确定是否相关,但我的npm存在一些问题:

graphql-type-json@0.1.4

UNMET PEER DEPENDENCY graphql@0.8.2 invalid

├─┬ graphql-tools@0.4.2

│ ├── UNMET PEER DEPENDENCY graphql@^0.5.0 || ^0.6.0


npm ERR! peer dep missing: graphql@^0.6.1 || ^0.7.0, required by apollo-server@0.3.3

npm ERR! peer dep missing: graphql@^0.5.0, required by graphql-tools@0.4.2

npm ERR! extraneous: casual@1.5.8 /home/apollo/node_modules/casual

npm ERR! extraneous: mongoose@4.6.6 /home/apollo/node_modules/mongoose

npm ERR! extraneous: mysql-events@0.0.8 /home/apollo/node_modules/mysql-events

npm ERR! peer dep missing: graphql@^0.5.0 || ^0.6.0, required by express-widgetizer@0.5.11

我在解析器中像这样解析自定义标量JSON

 JSON: {

    __serialize(value) {
        return GraphQLJSON.parseValue(value);
    } }

这对我来说很好。我认为它将帮助您

”(节点:5338)未经处理的Promisejection警告:未经处理的承诺拒绝(拒绝id:1):TypeError:type.getFields不是函数”是我得到的确切警告我建议升级到最新版本的
graphql工具
graphql
,并使用最新的
graphql server express
,这是阿波罗服务器的新名称。这可能是一些奇怪的依赖关系交互。