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: Change fragmentRefs output to use typename string literal rather than $tada.ref #126

Merged
merged 3 commits into from
Mar 11, 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/chilly-cats-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gql.tada': patch
---

Replace redundant `$tada.ref` value on `$tada.fragmentRefs` definitions for masked fragments with typename string literal. The record for fragment masks is already namespaced, so there wasn't a need to use a symbol value here, and this further increases readability and usefulness.
4 changes: 2 additions & 2 deletions src/__tests__/api.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ describe('graphql()', () => {

expectTypeOf<FragmentOf<typeof fragment>>().toEqualTypeOf<{
[$tada.fragmentRefs]: {
Fields: $tada.ref;
Fields: 'Todo';
};
}>();

expectTypeOf<ResultOf<typeof query>>().toEqualTypeOf<{
todos:
| ({
[$tada.fragmentRefs]: {
Fields: $tada.ref;
Fields: 'Todo';
};
} | null)[]
| null;
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('declare setupSchema configuration', () => {
id: string | number;
complete: boolean | null;
[$tada.fragmentRefs]: {
TodoData: $tada.ref;
TodoData: 'Todo';
};
} | null)[] | null;
}>();
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('initGraphQLTada configuration', () => {
id: string | number;
complete: boolean | null;
[$tada.fragmentRefs]: {
TodoData: $tada.ref;
TodoData: 'Todo';
};
} | null)[] | null;
}>();
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/namespace.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('getFragmentsOfDocumentsRec', () => {
};
[$tada.ref]: {
[$tada.fragmentRefs]: {
TodoFragment: $tada.ref;
TodoFragment: 'Todo';
};
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ type makeFragmentRef<Document> = Document extends { [$tada.definition]?: infer D
? Result
: {
[$tada.fragmentRefs]: {
[Name in Definition['fragment']]: $tada.ref;
[Name in Definition['fragment']]: Definition['on'];
};
}
: {
[$tada.fragmentRefs]: {
[Name in Definition['fragment']]: $tada.ref;
[Name in Definition['fragment']]: Definition['on'];
};
}
: never
Expand Down
Loading