hier die Mutation:GraphQL Fehlerfeldtyp muss Eingang Typ sein, aber bekam:
const createNotebook = mutationWithClientMutationId ({
name: 'CreateNotebook',
inputFields: {
token: {
type: GraphQLString,
},
details: {
type: NotebookDetails,
},
},
outputFields: {
},
async mutateCRNotebook(input, context) {
const data = getJSONFromRelativeURL(input.token);
},
});
Hier ist das Schema im Detailfeld der Mutation verwendet:
const NotebookDetails = new GraphQLObjectType({
name: 'NotebookDetails',
interfaces: [nodeInterface],
fields:() => ({
id: globalIdField('NotebookDetails'),
description: {
type: GraphQLString,
description: '...',
resolve(obj) {
return obj.description;
},
},
language: {
type: GraphQLString,
description: '...',
resolve(obj) {
return obj.language;
},
},
}),
});
Fehler ich immer bin beim Ausführen dieses Codes ist:
api_1 | Error: CreateNotebookInput.details field type must be Input Type but got: NotebookDetails.
api_1 | at invariant (/usr/src/app/node_modules/graphql/jsutils/invariant.js:19:11)
api_1 | at /usr/src/app/node_modules/graphql/type/definition.js:698:58
api_1 | at Array.forEach (native)
api_1 | at GraphQLInputObjectType._defineFieldMap (/usr/src/app/node_modules/graphql/type/definition.js:693:16)
api_1 | at GraphQLInputObjectType.getFields (/usr/src/app/node_modules/graphql/type/definition.js:682:49)
api_1 | at typeMapReducer (/usr/src/app/node_modules/graphql/type/schema.js:224:26)
api_1 | at typeMapReducer (/usr/src/app/node_modules/graphql/type/schema.js:190:12)
api_1 | at Array.reduce (native)
api_1 | at /usr/src/app/node_modules/graphql/type/schema.js:217:36
api_1 | at Array.forEach (native)
api_1 | at typeMapReducer (/usr/src/app/node_modules/graphql/type/schema.js:210:27)
api_1 | at Array.reduce (native)
api_1 | at new GraphQLSchema (/usr/src/app/node_modules/graphql/type/schema.js:98:34)
api_1 | at Object.<anonymous> (/usr/src/app/src/schema/index.js:39:16)
api_1 | at Module._compile (module.js:569:30)
api_1 | at Object.Module._extensions..js (module.js:580:10)
Ich habe diese Syntax mit Abfragen verwendet und sie funktionierten korrekt. Aber sie geben Fehler mit einer Mutation zurück. Was ist in meinem Code falsch und wie korrigiere ich es?
Das dauerte mich viel zu lange, aber es scheint ziemlich "offensichtlich", sobald Sie auf! –