Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing setter to loc property #400

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading