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: Update useBranches schema to make branches nullable #3802

Merged
Merged
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
79 changes: 40 additions & 39 deletions src/services/branches/useBranches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ const GetBranchesSchema = z.object({
repository: z.discriminatedUnion('__typename', [
z.object({
__typename: z.literal('Repository'),
branches: z.object({
edges: z.array(
z
.object({
node: BranchSchema,
})
.nullable()
),
pageInfo: PageInfoSchema,
}),
branches: z
.object({
edges: z.array(
z
.object({
node: BranchSchema,
})
.nullable()
),
pageInfo: PageInfoSchema,
})
.nullable(),
}),
RepoNotFoundErrorSchema,
RepoOwnerNotActivatedErrorSchema,
Expand All @@ -53,41 +55,40 @@ const GetBranchesSchema = z.object({
.nullable(),
})

const query = `
query GetBranches(
$owner: String!
$repo: String!
$after: String
$filters: BranchesSetFilters
) {
owner(username: $owner) {
repository(name: $repo) {
__typename
... on Repository {
branches(first: 20, after: $after, filters: $filters) {
edges {
node {
name
head {
commitid
}
const query = `query GetBranches(
$owner: String!
$repo: String!
$after: String
$filters: BranchesSetFilters
) {
owner(username: $owner) {
repository(name: $repo) {
__typename
... on Repository {
branches(first: 20, after: $after, filters: $filters) {
edges {
node {
name
head {
commitid
}
}
pageInfo {
hasNextPage
endCursor
}
}
pageInfo {
hasNextPage
endCursor
}
}
... on NotFoundError {
message
}
... on OwnerNotActivatedError {
message
}
}
... on NotFoundError {
message
}
... on OwnerNotActivatedError {
message
}
}
}`
}
}`

type GetBranchesReturn = { branches: Branch[]; pageInfo: PageInfo | null }

Expand Down