Graphql Unknown argument on field
looks like you are missing args on users, hence, it should look like this:
var users = new graphql.GraphQLObjectType({
name : 'user',
description : 'this is user info',
fields : function(){
return {
id :{
type : graphql.GraphQLInt,
resolve(user){
return user.id;
}
},
username :{
type : graphql.GraphQLString,
resolve(user){
return user.username;
}
},
posts:{
args: {
id:{
type : graphql.GraphQLInt,
},
type: new graphql.GraphQLList(posts),
resolve(user, args){
// Code here to use args.id
return user.getPosts();
}
}
}
}
});