-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Seccafien
committed
May 27, 2022
1 parent
7d5b6a6
commit b60f164
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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. | ||
|
||
## 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. | ||
|
||
### Incorrect code | ||
|
||
```tsx | ||
import {gql} from 'graphql-tag'; | ||
|
||
function MyComponent() { | ||
const query = gql` | ||
//... | ||
` | ||
return ( | ||
//... | ||
); | ||
} | ||
``` | ||
|
||
### Correct code | ||
|
||
```tsx | ||
import {gql} from '@shopify/hydrogen'; | ||
|
||
function MyComponent() { | ||
const query = gql` | ||
//... | ||
` | ||
return ( | ||
//... | ||
); | ||
} | ||
``` |