field resolver is not being called
See original GitHub issueHello,
Could you please help me to find where can I find an answer or documentation describing this situation?
I know I can easily do this if I use javascript for building the scheme, but the syntax needs much more words 😄
Here is the code of schema and resolver:
const { buildSchema } = require('graphql');
const schema = buildSchema(/* GraphQL */ `
type Position {
x: String
y: String
}
type Location {
name: String!
position: Position
}
type Query {
locations: [Location!]!
}
`);
const root = {
Location: {
position() {
// this line is not called <-------------------
return new Promise(resolve => {
setTimeout(() => {
resolve({ x: 111, y: 222 });
}, 300);
});
},
},
locations() {
return [{ name: 'test' }];
},
};
module.exports = {
schema,
root,
};
Here is the query
{
locations {
name
position {
x
y
}
}
}
here is the result:
{
"data": {
"locations": [
{
"name": "test",
"position": null
}
]
}
}
Versions:
"express": "^4.14.1",
"express-graphql": "^0.6.6",
"graphql": "^0.10.1",
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
GraphQL field's resolver not getting called - Stack Overflow
I set up my resolvers based on Apollo's GitHunt-API example, but the resolver on the field "review.extraStuff" never gets called.
Read more >Resolvers - Apollo GraphQL Docs
We want to define resolvers for the numberSix and numberSeven fields of the root Query type so that they always return 6 and...
Read more >Resolvers | NestJS - A progressive Node.js framework
Resolvers. Resolvers provide the instructions for turning a GraphQL operation (a query, mutation, or subscription) into data. They return the same shape of ......
Read more >Execution - GraphQL
When a field is executed, the corresponding resolver is called to produce the next value. If a field produces a scalar value like...
Read more >Resolvers – GraphQL Tools
It's just every resolver function being called in a nested way according to the layout of the query. Default Resolver. You don't need...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@IvanGoncharov @asci Can you post the root variable here. I still couldn’t understand
@vivex In @asci example you should change
Location
=> 'locations` here:Details here: http://graphql.org/graphql-js/object-types/