3
정의되지 않은 내가GraphQL 오류 - 인수 유형이 입력 유형이 될하지만 도착해야합니다
export const getPicture = {
type: GraphPicture,
args: {
type: new GraphQLNonNull(GraphQLInt)
},
resolve(_, args) {
return Picture.findByPrimary(args.id);
}
};
export const getPictureList = {
type: new GraphQLList(GraphPicture),
resolve(_, __, session) {
return Picture.findAll({where: {owner: session.userId}});
}
};
및 발생
const query = new GraphQLObjectType({
name: 'Queries',
fields:() => {
return {
getPictureList: getPictureList,
getPicture: getPicture
}
}
});
const schema = new GraphQLSchema({
query: query,
mutation: mutation
});
있습니다
Error: Queries.getPicture(type:) argument type must be Input Type but got: undefined.
getPictureList가 잘 작동을 getPicture이 실패합니다.
getPicture를 GraphQLLIst로 만들려고했으나 도움이되지 않습니다.
args 유형을 입력 유형으로 만들려고했으나 도움이되지 않습니다.
여기
스택 추적을 무슨 일이 일어나고 있는지에 대한 어떤 아이디어는 다음과 같습니다
Error: Queries.getPicture(type:) argument type must be Input Type but got: undefined.
at invariant (/home/jrootham/dev/trytheseon/node_modules/graphql/jsutils/invariant.js:19:11)
at /home/jrootham/dev/trytheseon/node_modules/graphql/type/definition.js:307:33
at Array.map (native)
at /home/jrootham/dev/trytheseon/node_modules/graphql/type/definition.js:304:52
at Array.forEach (native)
at defineFieldMap (/home/jrootham/dev/trytheseon/node_modules/graphql/type/definition.js:293:14)
at GraphQLObjectType.getFields (/home/jrootham/dev/trytheseon/node_modules/graphql/type/definition.js:250:46)
at /home/jrootham/dev/trytheseon/node_modules/graphql/type/schema.js:224:27
at typeMapReducer (/home/jrootham/dev/trytheseon/node_modules/graphql/type/schema.js:236:7)
at Array.reduce (native)
at new GraphQLSchema (/home/jrootham/dev/trytheseon/node_modules/graphql/type/schema.js:104:34)
at Object.<anonymous> (/home/jrootham/dev/trytheseon/server/graphQL.js:45:16)
at Module._compile (module.js:399:26)
at normalLoader (/usr/lib/node_modules/babel/node_modules/babel-core/lib/babel/api/register/node.js:160:5)
at Object.require.extensions.(anonymous function) [as .js] (/usr/lib/node_modules/babel/node_modules/babel-core/lib/babel/api/register/node.js:173:7)
at Module.load (module.js:345:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:355:17)
at require (internal/module.js:13:17)
at Object.<anonymous> (/home/jrootham/dev/trytheseon/devServer.js:14:44)
at Module._compile (module.js:399:26)
at normalLoader (/usr/lib/node_modules/babel/node_modules/babel-core/lib/babel/api/register/node.js:160:5)
관련이 있지만 유형을 지정하고 인수 이름 (id)이 누락되었습니다. – helfer
@OP, 루트 쿼리에서'getPicture'를 매개 변수화하십시오. 다른 메모에서는,'getPicture' 대신에'picture'를 명명하는 것을 고려할 수 있습니다. 더 많은 국제 대회입니다. –
스키마 정의에 전달 된 @AhmadFerdous 쿼리는 매개 변수화 할 필요가 없으며 쿼리 호출 자체를 통해 매개 변수를 전달합니다. –