Skip to content

Commit

Permalink
fix: Add missing setter to loc property (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten authored Sep 20, 2024
1 parent 331afc5 commit 062d4ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/forty-paws-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gql.tada': patch
---

Add missing setter to `loc` property
7 changes: 6 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,15 @@ export function initGraphQLTada<const Setup extends AbstractSetupSchema>(): init
);
}

let loc: Location | undefined;
return {
kind: Kind.DOCUMENT,
definitions,
get loc(): Location {
// 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,
Expand All @@ -358,6 +359,10 @@ export function initGraphQLTada<const Setup extends AbstractSetupSchema>(): init
},
};
}
return loc;
},
set loc(_loc: Location) {
loc = _loc;
},
} satisfies DocumentNode;
}
Expand Down

0 comments on commit 062d4ba

Please sign in to comment.