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

Add filterPath option #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add filterPath option #20

wants to merge 2 commits into from

Conversation

dobrynin
Copy link

Hi!

This PR adds support for an optional --leafsPath command line argument. If provided, the leafs file should contain a JSON object with GraphQL types (including unions, if desired) as keys and "leaf" fields to include as as array values. For example:

 {
   ALeafType: ['fieldToInclude', 'anotherFieldToInclude']
   AnotherLeafType: ['fieldToInclude', 'anotherFieldToInclude']
 }

When gql-generator encounters the listed types anywhere other than at the top-level, it will exclude any fields not included in the associated array.

We implemented this because we use a lot of nested revolvers, and the queries, while useful, were also large and unwieldy. This feature allows us to still generate comprehensive queries, without the redundant overkill of traversing Types that have their own stand-alone queries.

I implemented this feature for my team's internal use. If this doesn't seem generally useful to others, feel free to close this PR.

@dobrynin dobrynin changed the title Add leafsPath option Add filterPath option Jun 21, 2019
@dobrynin
Copy link
Author

I've updated the PR to make it more flexible. It now takes a generic filter function that takes in a number of variables. This solution is more imperative, but it allows greater latitude for potential use cases.

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

Successfully merging this pull request may close these issues.

1 participant