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

Allow specifying clientDirectives option (#370)

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