gql
Graphql sevice which watches project files and provides useful information.
Installation
- Install node package
yarn add @playlyfe/gql --dev
ornpm install @playlyfe/gql --dev
- Make sure watchman is installed.
- Create .gqlconfig file in project root.
.gqlconfig
Configuration file in json5 format.
type GQLConfig = schema: files: FileMatchConfig validate?: ValidateConfig query?: // query optional files: Array< match: FileMatchConfig // match files parser: QueryParser isRelay?: boolean validate?: ValidateConfig > ; type FileMatchConfig = Globs | include: Globs ignore?: Globs ;type Globs = string | Array<string>; // eg **/*.js **/*.gql type QueryParser = 'QueryParser' | 'EmbeddedQueryParser' startTag: regexpStr endTag: regexpStr ;; type ValidateConfig = extends: 'gql-rules-schema' | 'gql-rules-query' | 'gql-rules-query-relay' rules?: ruleName: string: 'off' | 'warn' | 'error' ;
// .gqlconfig (only schema) schema: files: 'schema/**/*.gql'
// .gqlconfig (with query) schema: files: 'schema/**/*.gql' query: files: // query gql files match: 'path/to/files/**/*.gql' parser: 'QueryParser' // [Embedded queries] relay files match: include: 'path/to/code/**/*.js' ignore: '**/tests/**/*.js' parser: 'EmbeddedQueryParser' startTag: 'Relay\\.QL`' endTag: '`' isRelay: true // [Embedded queries] gql tag files match: include: 'path/to/code/**/*.js' ignore: '**/tests/**/*.js' parser: 'EmbeddedQueryParser' startTag: 'gql`' endTag: '`' // [Embedded queries] some other tags match: 'path/to/code/**/*.xyz' parser: 'EmbeddedQueryParser' startTag: '"""' endTag: '"""' // [Embedded queries] some other tags and modify validation rules match: 'path/to/code/**/*.xyz' parser: 'EmbeddedQueryParser' startTag: '"""' endTag: '"""' validate: extends: 'gql-rules-query' rules: LoneAnonymousOperation: 'off' NoUnusedVariables: 'warn'
Plugins
- vscode: graphql-for-vscode
- SublimeText: @TODO
- cli: @TODO
Features
Schema
- Validation
- Autocompletion
- Get Defintion
- Find References
- Get Info of symbol at position.
- Watch files and auto update
Query
- Validation
- Autocompletion
- Get Definition
- Support Embedded queries (Relay.QL, gql, others)
- Get Info of symbol
- Find References
- Provide query schema dependency graph.
API