shurcooL / githubv4

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).
MIT License
1.1k stars 89 forks source link

Is it possible to dynamically include graphql fields? #95

Open patrickdevivo opened 2 years ago

patrickdevivo commented 2 years ago

Hi all!

I'm wondering if it's possible to use this library in a way that "dynamically" sets what GraphQL fields are used in a query (in the actual request to the GitHub API).

By "dynamic" I mean a way of specifying at runtime what fields to include in a request. For my use case, I'd actually be more interested in excluding fields under certain conditions 😃 .

For context, I maintain this project, which uses this library to implement the GitHub tables. We often hit GitHub's GraphQL API rate limit - which I believe is related to the number of fields/connections we request.

We have the ability to know, in our SQL query, which columns (GraphQL fields) are actually needed/requested by the user, so if we could only send those in the request to the GitHub API, that would probably allow us to avoid hitting the rate limit as frequently.

Is this possible today?

jmguzik commented 2 years ago

I think you look for something similar to this: https://github.com/shurcooL/githubv4/issues/17#issuecomment-437646874