Skip to content

Commit ccc93b3

Browse files
committed
fix language data type
1 parent 3f54c41 commit ccc93b3

File tree

2 files changed

+82
-4
lines changed

2 files changed

+82
-4
lines changed

packages/github-api/src/graphql/to-graphql.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ export function toGraphql<T extends keyof (DataSchemas | GraphQLData)>(
128128
},
129129
// @ts-expect-error type mismatch as it doesn't perfectly align with *Connection
130130
languages(pageArgs: PageArgs) {
131-
// TODO fill in all languages instead of just primary
132-
return applyRelayPagination([repo.language], pageArgs, (l) => ({
133-
name: l,
134-
}));
131+
return applyRelayPagination(
132+
repo.language ? [{ id: repo.language, name: repo.language }] : [],
133+
pageArgs
134+
);
135135
},
136136
// @ts-expect-error type mismatch as it doesn't perfectly align with *Connection
137137
repositoryTopics(pageArgs: PageArgs) {

packages/github-api/tests/graphql.test.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,84 @@ describe.sequential("graphql queries", () => {
433433
});
434434
});
435435

436+
describe("getOrganizationRepository With Fragment", () => {
437+
const query = gql`
438+
fragment RepositoryNode on Repository {
439+
url
440+
defaultBranchRef {
441+
name
442+
}
443+
... on Repository {
444+
__typename
445+
isArchived
446+
visibility
447+
name
448+
nameWithOwner
449+
url
450+
description
451+
languages(first: 10) {
452+
nodes {
453+
__typename
454+
name
455+
}
456+
}
457+
repositoryTopics(first: 10) {
458+
nodes {
459+
__typename
460+
topic {
461+
name
462+
}
463+
}
464+
}
465+
owner {
466+
... on Organization {
467+
__typename
468+
login
469+
}
470+
... on User {
471+
__typename
472+
login
473+
}
474+
}
475+
}
476+
}
477+
query repositories($cursor: String, $org: String!, $first: Int) {
478+
repositoryOwner(login: $org) {
479+
repositories(first: $first, after: $cursor, isFork: false) {
480+
totalCount
481+
nodes {
482+
...RepositoryNode
483+
}
484+
pageInfo {
485+
hasNextPage
486+
endCursor
487+
}
488+
}
489+
}
490+
}
491+
`;
492+
const variables = {
493+
org: "lovely-org",
494+
};
495+
it("responds successfully to fetch", async () => {
496+
let request = await fetch(`${url}/graphql`, {
497+
method: "POST",
498+
headers,
499+
body: JSON.stringify({
500+
query,
501+
variables,
502+
}),
503+
});
504+
let response = await request.json();
505+
expect(request.status).toEqual(200);
506+
expect(response.errors).toBe(undefined);
507+
});
508+
it("responds successfully to graphql client", async () => {
509+
let request = await client(query, variables);
510+
expect(request).toBeDefined();
511+
});
512+
});
513+
436514
describe("getTeamMembers", () => {
437515
const query = gql`
438516
query members($org: String!, $teamSlug: String!, $cursor: String) {

0 commit comments

Comments
 (0)