···11+---
22+'@0no-co/graphqlsp': minor
33+---
44+55+Add way to provide additional reserved keys for field-usage tracking by means of the `reservedKeys` config property which accepts an array of strings
+3-1
packages/graphqlsp/README.md
···6969 unused fields within the same file. (only works with call-expressions, default: true)
7070- `tadaOutputLocation` when using `gql.tada` this can be convenient as it automatically generates
7171 an `introspection.ts` file for you, just give it the directory to output to and you're done
7272-7272+- `reservedKeys` this setting will affect `trackFieldUsage`, you can enter keys here that will be ignored
7373+ from usage tracking, so when they are unused in the component but used in i.e. the normalised cache you
7474+ won't get annoying warnings. (default `id`, `_id` and `__typename`, example: ['slug'])
73757476## Tracking unused fields
7577
+5-2
packages/graphqlsp/src/fieldUsage.ts
···255255 const shouldTrackFieldUsage = info.config.trackFieldUsage ?? true;
256256 if (!shouldTrackFieldUsage) return diagnostics;
257257258258+ const defaultReservedKeys = ['id', '_id', '__typename'];
259259+ const additionalKeys = info.config.reservedKeys ?? [];
260260+ const reservedKeys = new Set([...defaultReservedKeys, ...additionalKeys]);
261261+258262 try {
259263 nodes.forEach(node => {
260264 const nodeText = node.getText();
···275279 const allAccess: string[] = [];
276280 const inProgress: string[] = [];
277281 const allPaths: string[] = [];
278278- const reserved = ['id', '__typename'];
279282 const fieldToLoc = new Map<string, { start: number; length: number }>();
280283 // This visitor gets all the leaf-paths in the document
281284 // as well as all fields that are part of the document
···285288 visit(parse(node.getText().slice(1, -1)), {
286289 Field: {
287290 enter: node => {
288288- if (!node.selectionSet && !reserved.includes(node.name.value)) {
291291+ if (!node.selectionSet && !reservedKeys.has(node.name.value)) {
289292 let p;
290293 if (inProgress.length) {
291294 p = inProgress.join('.') + '.' + node.name.value;