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

How GraphQL queries args are defined #49

Open
rerissondaniel opened this issue Mar 23, 2020 · 1 comment
Open

How GraphQL queries args are defined #49

rerissondaniel opened this issue Mar 23, 2020 · 1 comment
Labels
discussion Something isn't working practices/patterns stale This will not be worked on

Comments

@rerissondaniel
Copy link
Contributor

rerissondaniel commented Mar 23, 2020

What is to be discussed?
The way our arguments for graphql queries are defined.

Describe the solution you'd like
I would like a solution that allowed me to perform as little as possible breaking changes while extending the query arguments and also that made a cleaner code in frontend and also generated types that could be used to type my graphql backend easily, since most custom types that are used in these apps are from its schema.

I Suggest using that input types should be wrapped in an object, to make such addition easier. I've also seen this suggestion in other blog posts, but with names that I can't remember right now (maybe in airbnb directives, I'll update this issue as I remember them)
It also provides clearer declaration of queries in front end, as explained in this blog post.

How we do this today?
We just add the parameters as the requisites change.
I've had to add a new argument to a query and this was my workflow:

  • Add new arg to query in schema
  • Add new arg to query in resolver (could benefit from input types, since type normally is the same that resolver received, its args signatures could be more clearer and semantic)
  • Add new arg to query client (could benefit from input types, since type normally is the same that resolver received and in this case would be easier to comply with our lint rule for at most three parameters per function)

Example: addition of filters arg, in https://github.com/vtex/catalog-graphql/pull/169/files

@rerissondaniel rerissondaniel changed the title Best way of defining GraphQL queries args How GraphQL queries args are defined Mar 23, 2020
@stale
Copy link

stale bot commented Mar 30, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is a discussion thread, the most voted option will be final. Thank you for your contributions.

@stale stale bot added the stale This will not be worked on label Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Something isn't working practices/patterns stale This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant