Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.

Allow specifying clientDirectives option (#370)

authored by

Jovi De Croock and committed by
GitHub
a372050d f56cec54

+15 -1
+5
.changeset/upset-hats-remain.md
··· 1 + --- 2 + '@0no-co/graphqlsp': minor 3 + --- 4 + 5 + Allow supplying a custom `clientDirectives` which will be mixed in with the base client directives
+1
README.md
··· 70 70 - `tadaOutputLocation` when using `gql.tada` this can be convenient as it automatically generates 71 71 an `introspection.ts` file for you, just give it the directory to output to and you're done 72 72 - `tadaDisablePreprocessing` this setting disables the optimisation of `tadaOutput` to a pre-processed TypeScript type, this is off by default. 73 + - `clientDirectives` this setting allows you to specify additional `clientDirectives` which won't be seen as a missing schema-directive. 73 74 74 75 ## Tracking unused fields 75 76
+1
packages/graphqlsp/README.md
··· 73 73 from usage tracking, so when they are unused in the component but used in i.e. the normalised cache you 74 74 won't get annoying warnings. (default `id`, `_id` and `__typename`, example: ['slug']) 75 75 - `tadaDisablePreprocessing` this setting disables the optimisation of `tadaOutput` to a pre-processed TypeScript type, this is off by default. 76 + - `clientDirectives` this setting allows you to specify additional `clientDirectives` which won't be seen as a missing schema-directive. 76 77 77 78 ## Tracking unused fields 78 79
+7 -1
packages/graphqlsp/src/diagnostics.ts
··· 31 31 } from './persisted'; 32 32 import { SchemaRef } from './graphql/getSchema'; 33 33 34 - const clientDirectives = new Set([ 34 + const BASE_CLIENT_DIRECTIVES = new Set([ 35 35 'populate', 36 36 'client', 37 + 'unmask', 37 38 '_unmask', 38 39 '_optional', 39 40 '_relayPagination', ··· 418 419 if (!schemaToUse) { 419 420 return undefined; 420 421 } 422 + 423 + const clientDirectives = new Set([ 424 + ...BASE_CLIENT_DIRECTIVES, 425 + ...(info.config.clientDirectives || []), 426 + ]); 421 427 422 428 const graphQLDiagnostics = getDiagnostics( 423 429 text,
+1
packages/graphqlsp/src/index.ts
··· 30 30 templateIsCallExpression?: boolean; 31 31 shouldCheckForColocatedFragments?: boolean; 32 32 template?: string; 33 + clientDirectives?: string[]; 33 34 trackFieldUsage?: boolean; 34 35 tadaOutputLocation?: string; 35 36 }