내가 graphql에 명시 서버를 실행하기 위해 노력하고있어 나는 다음과 같은 오류 얻을 :GraphQL : Query.example 필드 유형 출력 유형 만 가지고해야합니다 : [개체 개체]
Error: Query.example field type must be Output Type but got: [object Object].
익스프레스를
app.use('/graphql', graphqlHTTP(req => ({
schema,
pretty: true
})));
스키마가 다음과 같습니다 : 경로에 사용 graphql
export default new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: queries
})
});
쿼리는 하나 개의 쿼리를 가지 여기에서 수입 :
import {
GraphQLList,
GraphQLID,
GraphQLNonNull
} from 'graphql';
import exampleScheme from '../models/schemes/example';
import {example as exampleData} from '../models/jsons'
export default {
type: exampleScheme,
resolve (root, params, options) {
return exampleData;
}
};
스키마 (exampleScheme) 및 데이터 (exampleScheme가) 다른 프로젝트에 노력하고 있습니다 그래서 나는 그들이 문제가 아니에요 가정합니다.
아이디어가 있으십니까? '출력 유형'의 의미는 무엇입니까?
는export default {
helloString: {
type: GraphQLString,
resolve (root, params, options) {
return "Hello World!";
}
}
... <Next query>
};
어쨌든, 오류는 다음과 같습니다
export default {
type: exampleScheme,
resolve (root, params, options) {
return exampleData;
}
};
이 쿼리입니다
감사합니다 HagaiCo, 내가 다른 프로젝트에서 스키마를 가져 왔기 때문에, 'GraphQLObjectType'대신 'GraphQLSchema'스키마가 사용되었습니다. – alonp99