We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As a user migrating from express-graphql, I want to pass a rootValue resolver. With express-graphql, I was able to do the following:
express-graphql
rootValue
app.get('/graphql', graphqlHTTP((req, res) => ({ schema, rootValue: resolvers })))
Ideally, I would like to set rootValue as an option of createHandler
createHandler
app.use( '/graphql', createHandler({ schema, rootValue }), )
ExecutionContext
onSubscribe
Maybe using a rootValue is not recommended anymore? Maybe there's an alternative? For reference, here's how I declare my schema/resolvers:
module.exports = { /** * Create an article. */ articles: async (args, { req }) => { // ... } /** * Delete an article. */ deleteArticle: async (args, { req }) => { // ... }, }
const gql = require('graphql-tag') const { buildASTSchema } = require('graphql') module.exports = buildASTSchema(gql` type Article { _id: ID! title: String content: String createdAt: String updatedAt: String } type RootQuery { articles (user: ID): [Article!]! } type RootMutation { deleteArticle(article: ID!): Article! } schema { query: RootQuery mutation: RootMutation } `)
The text was updated successfully, but these errors were encountered:
This makes sense! Thank you for opening an issue, I will tackle this rather soon.
Sorry, something went wrong.
0f04fa2
chore(release): 🎉 1.10.0 [skip ci]
35833ff
# [1.10.0](v1.9.0...v1.10.0) (2022-12-24) ### Features * **handler:** Accept a GraphQL execution rootValue ([0f04fa2](0f04fa2)), closes [#30](#30)
🎉 This issue has been resolved in version 1.10.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
enisdenjo
No branches or pull requests
Story
As a user migrating from
express-graphql
, I want to pass arootValue
resolver. Withexpress-graphql
, I was able to do the following:Ideally, I would like to set
rootValue
as an option ofcreateHandler
Acceptance criteria
rootValue
without overriding the wholeExecutionContext
withonSubscribe
rootValue
Note
Maybe using a
rootValue
is not recommended anymore? Maybe there's an alternative? For reference, here's how I declare my schema/resolvers:The text was updated successfully, but these errors were encountered: