Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Seccafien committed May 27, 2022
1 parent 7d5b6a6 commit b60f164
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/eslint-plugin/src/rules/prefer-gql/README.md
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 (
//...
);
}
```

0 comments on commit b60f164

Please sign in to comment.