diff --git a/.changeset/forty-paws-yawn.md b/.changeset/forty-paws-yawn.md new file mode 100644 index 00000000..e8cc4023 --- /dev/null +++ b/.changeset/forty-paws-yawn.md @@ -0,0 +1,5 @@ +--- +'gql.tada': patch +--- + +Add missing setter to `loc` property diff --git a/src/api.ts b/src/api.ts index a159b2fe..67e75883 100644 --- a/src/api.ts +++ b/src/api.ts @@ -339,6 +339,7 @@ export function initGraphQLTada(): init ); } + let loc: Location | undefined; return { kind: Kind.DOCUMENT, definitions, @@ -346,7 +347,7 @@ export function initGraphQLTada(): init // NOTE: This is only meant for graphql-tag compatibility. When fragment documents // are interpolated into other documents, graphql-tag blindly reads `document.loc` // without checking whether it's `undefined`. - if (isFragment) { + if (!loc && isFragment) { const body = input + concatLocSources(fragments || []); return { start: 0, @@ -358,6 +359,10 @@ export function initGraphQLTada(): init }, }; } + return loc; + }, + set loc(_loc: Location) { + loc = _loc; }, } satisfies DocumentNode; }