Skip to content

How GraphQL queries args are defined #49

@rerissondaniel

Description

@rerissondaniel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions