parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Expose options for generated queries in GraphQL server

Open mdarens opened this issue 2 years ago • 1 comments

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 like readPreference
  • A query and/or resolver middleware property on classConfigs elements' query property 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?

mdarens avatar Sep 28 '23 21:09 mdarens

Thanks for opening this issue!