graphql-cli plugin for validating all queries in a Magento 2 PWA project
npm install graphql-cli-validate-magento-pwa-queries 
Validate your project's GraphQL queries against a schema.
```
yarn add graphql-cli graphql-cli-validate-magento-pwa-queries
Given the following .graphqlconfig:
``
{
"projects": {
"myApp": {
"schemaPath": "mySchema.json",
"extensions": {
"endpoints": {
"default": "https://myEndpoint.com/graphql"
},
"validate-magento-pwa-queries": {
"clients": ["apollo", "literal"],
"filesGlob": "src/*/.{js,graphql,gql}"
}
}
}
}
}
The command
``
graphql-cli get-schema --project myApphttps://myEndpoint.com/graphql
will download the GraphQL schema
from and store it in mySchema.json.
Then the command
``
graphql-cli validate-magento-pwa-queries --project myApp
will validate all apollo and literal GraphQL queries it finds in .js, .graphql, or .gql files in the src/ directory
against that schema.
This plugin supports the following command line options:
| Option | Description | Type | Default |
| --- | --- | --- | --- |
| --project, -p | The project name as specified in .graphqlconfig. | string | "" |
You can also specifiy the following options in your .graphqlconfig:
| Option | Description | Type |
| --- | --- | --- |
| --clients, -c | GraphQL clients in use in this project. | array |--filesGlob
| , -f | A glob used to target files for validation. | string` |
* graphql-config
* graphql-cli
* eslint-plugin-graphql
* graphql/no-deprecated-fields rule