Expose options for generated queries in GraphQL server
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
Current Limitation
If you are using the auto-generated resolvers from the included ParseGraphQLServer, there does not seem to be a way to set the read preference on these queries in bulk without affecting other queries. You can either:
- Include it in the database connection URL, thus affecting all queries
- Set it via GraphQL resolver
args, requiring it to be present in the query document.
Feature / Enhancement Description
- A top level default query options property on the
ParseGraphQLServer's config for settings likereadPreference - A query and/or resolver middleware property on
classConfigselements'queryproperty which allows mapping and modifying these queries or requests before they are executed
Example Use Case
We have an app where we would like to route JS SDK requests to a primary, and requests from the GQL API to secondary replicas. With the database url environment variable and the --mountGraphQL argument, we have no way to differentiate between these requests.
Alternatives / Workarounds
Deploying the parse server image with the read preference hardcoded in the connection string, then wrapping the SDK query constructor with one that sets the read preference back to primary (not ideal).
If you've read this far, thanks for your interest! Does this seem like a good idea? Is there a workaround I'm not thinking of?