我正在尝试一个简单的GraphQL原型我有一个简单的查询工作...
import {
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLString
} from 'graphql'
...
var schema = buildSchema(`
type Partner {
name:String!,
id:ID,
print: String
}
type Query {
getPartner(name: String!, id: ID) : Partner
}
我现在尝试使用构建模式的实用方法......
let partnerType = new GraphQLObjectType({
name: 'Partner',
fields: {
name: { type: graphql.GraphQLString },
id: { type: graphql.GraphQLString },
print: { type: graphql.GraphQLString}
}
})
let queryType = new GraphQLObjectType({
name: 'Query',
fields: {
getPartner: {
type: partnerType,
args: {
name: { type: graphql.GraphQLString },
id: { type: graphql.GraphQLID }
},
//resolve: function(_, { id }) {
resolve() {
//as a test remove args
return new Partner("test", 1)
}
}
}
})
显然我在这里遗漏了一些东西 - 我收到了错误
{
"errors": [
{
"message": "The type of Query.getPartner(name:) must be Input
Type but got: undefined.\n\nThe type of Query.getPartner(id:) must be
Input Type but got: undefined.\n\nThe type of Partner.name must be
Output Type but got: undefined.\n\nThe type of Partner.id must be
Output Type but got: undefined.\n\nThe type of Partner.print must be
Output Type but got: undefined."
}
]
}
我得到的输入参数不会被传递给查询? 有任何想法吗 ?我通过示例代码http://graphql.org/graphql-js/constructing-types/
获得相同的错误