我试图弄清楚我的撰写模式出了什么问题:问题是我遇到了以下错误:
{"errors":[{"message":"Unknown argument \"record\" on field \"entityCreate\" of type \"Mutation\".","locations":[{"line":2,"column":16}]},{"message":"Field \"entityCreate\" argument \"input\" of type \"RelayCreateOneEntityInput!\" is required but not provided.","locations":[{"line":2,"column":3}]}]}
import ComplaintSC from "./complaint.js"
import EntitySC from "./entity.js"
import { schemaComposer } from 'graphql-compose';
const graphqlSchema = schemaComposer.buildSchema();
export default graphqlSchema
知道我有一些实体可以按如下方式在rootQuery和rootMutation中推送字段:
import { composeWithMongoose } from 'graphql-compose-mongoose';
import { composeWithRelay } from 'graphql-compose-relay';
import { schemaComposer } from 'graphql-compose';
import {Entity} from '../db'
const customizationOptions = {}; // left it empty for simplicity, described below
const EntityTC = composeWithRelay(composeWithMongoose(Entity, customizationOptions));
//TODO make this function evolve to allow filtering on a specified field in params
//Found in https://github.com/graphql-compose/graphql-compose-examples/blob/master/examples/northwind/models/product.js#L38,L49
const addEntityNameRegexpSearch = function () {
const extendedResolver = EntityTC.getResolver('findMany').addFilterArg({
name: 'nameRegexp',
type: 'String',
description: 'Search by name in regExp',
query: (query, value, resolveParams) => { // eslint-disable-line
query.name = new RegExp(value, 'i'); // eslint-disable-line
},
});
extendedResolver.name = 'findMany';
EntityTC.addResolver(extendedResolver);
};
addEntityNameRegexpSearch()
schemaComposer.rootQuery().addFields({
entityById: EntityTC.getResolver('findById'),
entityByIds: EntityTC.getResolver('findByIds'),
entityOne: EntityTC.getResolver('findOne'),
entityMany: EntityTC.getResolver('findMany'),
entityCount: EntityTC.getResolver('count'),
entityConnection: EntityTC.getResolver('connection'),
entityPagination: EntityTC.getResolver('pagination'),
});
schemaComposer.rootMutation().addFields({
entityCreate: EntityTC.getResolver('createOne'),
entityUpdateById: EntityTC.getResolver('updateById'),
entityUpdateOne: EntityTC.getResolver('updateOne'),
entityUpdateMany: EntityTC.getResolver('updateMany'),
entityRemoveById: EntityTC.getResolver('removeById'),
entityRemoveOne: EntityTC.getResolver('removeOne'),
entityRemoveMany: EntityTC.getResolver('removeMany'),
});
export default schemaComposer;
在我添加中继之前,一切正常,您能解释出什么问题了吗?
p.s:这个问题与graphql-compose有关,但是没有标签,我仍然没有创建它的权限
最诚挚的问候