Created
March 20, 2018 09:27
-
-
Save cgrice/f4b17dc591921e2df8115898902330a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const resolvers = { | |
// Resolvers can fetch data for fields on the query root. As long as they return | |
// data that matches the schema, this can come from anywhere. Here we've hardcoded | |
// some data. | |
Query: { | |
products: () => [ | |
{ | |
name: 'Eggs', | |
price: 199 | |
} | |
] | |
}, | |
// They can also retrieve data for individual types. | |
Product: { | |
// In this case, we need to access the parent node to fetch related products | |
related: (product) => getRelatedProducts(product.id), | |
// And here we need to access the arguments passed through to the field as well | |
inStockAt: (product, args) => isInStockAtStore(product.id, args.storeId), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment