Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Michelle Vinci <[email protected]>
  • Loading branch information
Matt Seccafien and mcvinci committed May 28, 2022
1 parent 7b2e036 commit a8b1b46
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/eslint-plugin/src/rules/prefer-gql/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Prefer using the `gql` utility from Hydrogen

Projects that consume a GraphQL API will often use utility to help write GraphQL queries to parse the queries into an AST for the project's GraphQL client library and/or provide syntax highlighting. In hydrogen, we do not require to parse the GraphQL queries and provide a lightweight `gql` utility that is optimized for use within Hydrogen projects.
Projects that consume a GraphQL API typically use a utility that parses GraphQL queries into ASTNodes for the projects' GraphQL client library or provides syntax highlighting.

In Hydrogen, you don't need to parse GraphQL queries. Instead, you can use Hydrogen's light-weight [`gql` utility](https://shopify.dev/api/hydrogen/utilities/gql) that adds syntax highlighting to your GraphQL queries.

Using the `gql` utility makes your production bundle smaller by dropping certain AST-related dependencies. In development, however, the `gql` utility uses ASTNodes to provide better errors in your queries.

## Rule details

This rule is used to detect usages of `gql` utility other than the one provided by Hydrogen and suggests the utility from `@shopify/hydrogen`instead.
This rule is used to detect the use of a GraphQL utility other than the one provided by Hydrogen. If another GraphQL utility is being used, then the `gql` utility from `@shopify/hydrogen` is suggested.

### Incorrect code

Expand Down

0 comments on commit a8b1b46

Please sign in to comment.