Skip to content
New issue

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

Make the auto-filtering feature an off-by-default option? #34

Open
jneurock opened this issue Apr 12, 2021 · 2 comments
Open

Make the auto-filtering feature an off-by-default option? #34

jneurock opened this issue Apr 12, 2021 · 2 comments
Labels
question Further information is requested

Comments

@jneurock
Copy link
Collaborator

jneurock commented Apr 12, 2021

To maintain compatibility with the design of ember-cli-mirage-graphql (the Ember-specific library that came before this), Mirage GraphQL automatically filters records by variables when auto-resolving. I think this behavior is probably surprising to most and I'm not sure if it's actually useful.

Example of the behavior being useful:

query Products($size: String) {
  products(size: $size) {
    id
    name
    size
  }
}

The query is called with a $size variable having the value "XL" and only records that match are returned from Mirage's database.


Example of the behavior being painful (forcing a query to be manually resolved):

query Products($limit: Int) {
  products(limit: $limit) {
    id
    name
  }
}

The query is called with a $limit variable having the value 10 and Mirage GraphQL tries to auto-resolve this by filtering for products having a "limit" field with a value of 10. Since "limit" isn't a field, no records are returned.


I'd like to gather some feedback on whether or not to change this behavior and make it off-by-default. I could add a handler creation option to enable this for anyone who does find this behavior useful.

@jneurock jneurock added the question Further information is requested label Apr 12, 2021
@villander
Copy link

villander commented Feb 21, 2022

@jneurock it really makes sense I think the @miragejs/graphql should work as graphQL server works out of the box without need for any resolver or custom functions for that.

@jneurock
Copy link
Collaborator Author

I'm planning to make this filtering functionality opt-in for version 0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants