Getting Error : Unknown Argument "id" On Field "user" Of Type "query" [graphql, Relay, React]
We are forming a query in relay. We have user database set as follows: function User(id, name, des) { this.id = id.toString() this.name = name this.des = des } var users =
Solution 1:
Your schema doesn't define any arguments for the user field:
user: {
type: userType,
resolve: function() { return db.getAnonymousUser() },
},
To fetch user by ID, define the id
argument, and fetch the user by that ID:
user: {
args: {
id: { type: GraphQLString }
},
resolve: function(root, args) {
return db.findUserById(args.id); // you don't have this method but it's an example of how to use the arg
}
}
Post a Comment for "Getting Error : Unknown Argument "id" On Field "user" Of Type "query" [graphql, Relay, React]"