Skip to content

Add filterPath option#20

Open
dobrynin wants to merge 2 commits intotimqian:masterfrom
INLT:master
Open

Add filterPath option#20
dobrynin wants to merge 2 commits intotimqian:masterfrom
INLT:master

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