Итак, я пытаюсь включить скалярный тип JSON, как описано ниже, но он выдает мне неверную ошибку схемы GraphQL.Что я определил неправильно?Я просто пытаюсь следовать их руководству:
https://www.apollographql.com/docs/graphql-tools/scalars.html
const GraphQLJSON = require("graphql-type-json")
const {
makeExecutableSchema
} = require("graphql-tools")
const typeDefs = `
scalar JSON
type Query {
hello: String,
print (name: String): String,
json (a: JSON): JSON
}
`
// Provide resolver functions for your schema fields
export const resolvers = {
Query: {
hello:
function (parent, args, context)
{
console.log(context.body)
return "Hello"
},
print:
function (parent, args, context)
{
console.log(context.body)
console.log(args)
return "hello"
},
json:
function (parent, args, context)
{
console.log(args)
return args
}
},
JSON: GraphQLJSON
}
export default makeExecutableSchema({
typeDefs,
resolvers
})
Ошибка:
Error: Expected { resolvers: { Query: { hello: [function hello], print: [function print], json: [function json] }, JSON: JSON }, default: { astNode: undefined, extensionASTNodes: undefined, _queryType: Query, _mutationType: null, _subscriptionType: null, _directives: [@skip, @include, @deprecated], _typeMap: { Query: Query, String: String, JSON: JSON, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, Boolean: Boolean, __Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive, __DirectiveLocation: __DirectiveLocation }, _implementations: {}, _possibleTypeMap: undefined, __validationErrors: undefined, __allowedLegacyNames: [] } } to be a GraphQL schema.