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

Port slonik-dataloaders #599

Merged
merged 25 commits into from
May 13, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
remove __typename from edge fields
  • Loading branch information
gajus committed May 13, 2024
commit 55bc3f33731cf3d0db4f4112dac6120ee025a34e
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export const createConnectionLoaderClass = <T extends ZodTypeAny>(config: {
const cursorValues: string[] = [];

let index = 0;

while (true) {
const value = record[SORT_COLUMN_ALIAS]?.[index];
if (value === undefined) {
Expand All @@ -226,8 +227,14 @@ export const createConnectionLoaderClass = <T extends ZodTypeAny>(config: {
}
}

// TODO add a test for this
// Strip out `__typename`, otherwise if the connection object is returned inside a resolver,
// GraphQL will throw an error because the typename won't match the edge type
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention
const { __typename, ...edgeFields } = record;

return {
...record,
...edgeFields,
cursor: toCursor(cursorValues),
node: record,
};
Expand Down