···
export const MISSING_OPERATION_NAME_CODE = 52002;
export const USING_DEPRECATED_FIELD_CODE = 52004;
-
let isGeneratingTypes = false;
const cache = new LRUCache<number, ts.Diagnostic[]>({
// how long to live in ms
···
: texts.join('-') + schema.version
if (cache.has(cacheKey)) {
-
return cache.get(cacheKey)!;
-
const tsDiagnostics = runDiagnostics(
cache.set(cacheKey, tsDiagnostics);
···
-
const shouldCheckForColocatedFragments =
-
info.config.shouldCheckForColocatedFragments ?? true;
-
let fragmentDiagnostics: ts.Diagnostic[] = [];
-
if (shouldCheckForColocatedFragments) {
-
const moduleSpecifierToFragments = getColocatedFragmentNames(
-
const usedFragments = new Set();
-
nodes.forEach(node => {
-
const parsed = parse(node.getText().slice(1, -1), {
-
FragmentSpread: node => {
-
usedFragments.add(node.name.value);
-
Object.keys(moduleSpecifierToFragments).forEach(moduleSpecifier => {
-
fragments: fragmentNames,
-
} = moduleSpecifierToFragments[moduleSpecifier];
-
const missingFragments = Array.from(
-
new Set(fragmentNames.filter(x => !usedFragments.has(x)))
-
if (missingFragments.length) {
-
fragmentDiagnostics.push({
-
category: ts.DiagnosticCategory.Warning,
-
code: MISSING_FRAGMENT_CODE,
-
messageText: `Unused co-located fragment definition(s) "${missingFragments.join(
-
)}" in ${moduleSpecifier}`,
-
return [...tsDiagnostics, ...usageDiagnostics, ...fragmentDiagnostics];
···
export const MISSING_OPERATION_NAME_CODE = 52002;
export const USING_DEPRECATED_FIELD_CODE = 52004;
const cache = new LRUCache<number, ts.Diagnostic[]>({
// how long to live in ms
···
: texts.join('-') + schema.version
if (cache.has(cacheKey)) {
+
tsDiagnostics = cache.get(cacheKey)!;
+
tsDiagnostics = runDiagnostics(source, { nodes, fragments }, schema, info);
cache.set(cacheKey, tsDiagnostics);
+
const shouldCheckForColocatedFragments =
+
info.config.shouldCheckForColocatedFragments ?? true;
+
let fragmentDiagnostics: ts.Diagnostic[] = [];
+
if (isCallExpression && shouldCheckForColocatedFragments) {
+
const moduleSpecifierToFragments = getColocatedFragmentNames(source, info);
+
const usedFragments = new Set();
+
nodes.forEach(node => {
+
const parsed = parse(node.getText().slice(1, -1), {
+
FragmentSpread: node => {
+
usedFragments.add(node.name.value);
+
Object.keys(moduleSpecifierToFragments).forEach(moduleSpecifier => {
+
fragments: fragmentNames,
+
} = moduleSpecifierToFragments[moduleSpecifier];
+
const missingFragments = Array.from(
+
new Set(fragmentNames.filter(x => !usedFragments.has(x)))
+
if (missingFragments.length) {
+
fragmentDiagnostics.push({
+
category: ts.DiagnosticCategory.Warning,
+
code: MISSING_FRAGMENT_CODE,
+
messageText: `Unused co-located fragment definition(s) "${missingFragments.join(
+
)}" in ${moduleSpecifier}`,
+
return [...tsDiagnostics, ...fragmentDiagnostics];
···
+
return [...tsDiagnostics, ...usageDiagnostics];