-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Meta: Use variables in GraphQL #6674
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
Conversation
|
JMHO, on any non simple query I think this lowers readability |
|
It’s definitely more verbose but there’s no alternative if we want to extract the queries: Once extracted we’ll have syntax highlighting and potentially some validation, as well as proper types for v4 calls. I think it’s worth it, even if the query ends up being in a different file. |
fregante
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything here was tested. Some features were even restored, some tickets were created.
In a future PR:
- Extract to .gql files
- Update every query (I ignored the simple ones without additional variables, although they're still affected by this change)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see what the usage of .gql files will look like in list-prs-for-file
Missing:
- TypeScript integration that will help us use the results in the file
- GraphQL autocomplete in the IDE thanks to the schema
- Typed
variablesthat make TypeScript complain if one is missing or unused - Prettier/formatter for GQL support (we have a .prettierignore file)
| field: UPDATED_AT, | ||
| direction: DESC | ||
| } | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Demo extracted GQL file
| } | ||
| `); | ||
| debugger; | ||
| const {repository} = await api.v4(listPrsForFileQuery, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Demo feature with extracted query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Can we put this in a new pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind just saw your post
This PR
This is harder than anticipated:
Test
Extensions suggested: