-
Notifications
You must be signed in to change notification settings - Fork 535
Allow to pass function that returns Promise as a rootValue option #253
Conversation
@wincent @leebyron Can you please review this PR? |
This is actually already supported! However instead of allowing each property in this configuration to be an async function, providing the configuration as a whole is provided as an async function. You can chain promises (or await async functions) in whatever order makes the most sense for your configuration before returning it to be used. For example:
|
@leebyron My bad, I didn't state it clearly in PR description, but we already tried this approach. Problem is that This PR adds support for the callback that is called with query AST and only if query passed validation. I believe this functionality may be required for other complicated tools. |
Sorry for letting this sit. Thanks for the additional context. It sounds like there is a separate issue at hand then. This is a fixing the symptom of the problem, but not the problem itself, which is that you want the order of parsing the request and running the async function to return options to happen in the reverse order, which I think is a good idea. |
This ensures that the `request` parameter to the `options()` function is already endowed with metadata about the GraphQL request so that it may be used when constructing options. Addresses #253
I've added #302 which ensures the ordering of creating params and options will then ensure Please let me know if that addresses the concern |
This ensures that the `request` parameter to the `options()` function is already endowed with metadata about the GraphQL request so that it may be used when constructing options. Adds a third argument to the function for easier access to graphql specific data. Addresses #253
This ensures that the `request` parameter to the `options()` function is already endowed with metadata about the GraphQL request so that it may be used when constructing options. Adds a third argument to the function for easier access to graphql specific data. Addresses #253
@leebyron #302 Solves only the first part of the problem of getting raw parameters. After that, I still have to parse the query to AST and validate since I can’t use Moreover, at the time when So in the end, I had to copy-paste ~200 lines into my code. |
Closing in favor of #391. |
This PR allows providing your own `execute` function instead of the default one from the `graphql-js`. It’s a small change that adds a lot of flexibility since you can wrap standard `execute` and it opens new possibilities for middlewares. Personally, I need it to proxy calls to 3rd-party APIs. It’s an alternative to #253 but introduces less code and more flexible mechanism. It’s very important for us as it will be the last change required to switch [graphql-faker](https://github.com/APIs-guru/graphql-faker) from custom forks of `graphql-js` and `graphql-express`. @wincent @leebyron Can you please review it?
This PR allows providing your own `execute` function instead of the default one from the `graphql-js`. It’s a small change that adds a lot of flexibility since you can wrap standard `execute` and it opens new possibilities for middlewares. Personally, I need it to proxy calls to 3rd-party APIs. It’s an alternative to graphql#253 but introduces less code and more flexible mechanism. It’s very important for us as it will be the last change required to switch [graphql-faker](https://github.com/APIs-guru/graphql-faker) from custom forks of `graphql-js` and `graphql-express`. @wincent @leebyron Can you please review it?
This functionality is required when you need different
rootValue
depending on the query. In our case, we are working on a GraphQL proxy that needs to pass a query to the original GraphQL server and provide its response as therootValue
.