0
GraphQLタイプ内でフィールドを解決しようとすると問題が発生します。 だから、ここで私はpatientQuery
GraphqlはmakeExecutableSchemaでマッピングを解決します
const gqlSchema = makeExecutableSchema({
typeDefs: `
type patientQuery {
find: [String]
findOne: String
}
type Query {
patient: patientQuery
}
type Mutation {
addPost(name: String, title: String, content: String): patientQuery
}
schema {
query: Query
mutation: Mutation
}
`,
resolvers: {
patientQuery: {
find(root, params, context, ast) {
console.log('testing');
return ['title'];
}
}
}
});
のfind
プロパティを解決しようとしていますが、私はこの
{
patient {
find
}
}
のようなクエリを実行するとき、私は常にnull
{
"data": {
"patient": null
}
}
を取得するだから何がありますpatientQuery
タイプのフィールドを解決する適切な方法はありますか?
を、私はそれが関係している疑いがあります実際には文字列を返すが、フィールドは文字列の配列を返すと予想されます。 'return ['title']' – XuoriG
は配列を返す解決関数を変更しましたが、それでもnullを返します – Shalkam