Skip to content

Commit 30403ad

Browse files
committed
feat(api): codegen for discussions
Signed-off-by: Adam Setch <[email protected]>
1 parent 4afeac9 commit 30403ad

File tree

11 files changed

+73
-134
lines changed

11 files changed

+73
-134
lines changed

.vscode/extensions.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"recommendations": [
33
"biomejs.biome",
44
"bradlc.vscode-tailwindcss",
5+
"GraphQL.vscode-graphql",
6+
"GraphQL.vscode-graphql-syntax",
57
"SonarSource.sonarlint-vscode"
68
]
79
}

codegen.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ const config: CodegenConfig = {
1313
},
1414
},
1515
},
16-
documents: [
17-
'src/renderer/utils/api/**/*.ts',
18-
'!src/renderer/utils/api/graphql/generated/**',
19-
'!src/renderer/utils/api/**/*.test.ts',
20-
],
16+
documents: ['src/renderer/utils/api/**/*.graphql'],
2117
generates: {
2218
'src/renderer/utils/api/graphql/generated/': {
2319
preset: 'client',
2420
config: {
2521
documentMode: 'string',
22+
useTypeImports: true,
2623
},
2724
},
2825
'src/renderer/utils/api/graphql/generated/schema.graphql': {

graphql.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { IGraphQLConfig } from 'graphql-config';
2+
3+
const config: IGraphQLConfig = {
4+
schema: './src/renderer/utils/api/graphql/generated/schema.graphql',
5+
};
6+
7+
export default config;

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"package:win": "electron-builder --win --config ./config/electron-builder.js",
2020
"lint:check": "biome check",
2121
"lint": "biome check --fix",
22-
"test": "TZ=UTC jest",
22+
"test": "jest",
2323
"start": "electron . --enable-logging",
2424
"prepare": "husky",
2525
"codegen": "graphql-codegen --config codegen.ts"
@@ -76,7 +76,6 @@
7676
"react-router-dom": "7.10.1"
7777
},
7878
"devDependencies": {
79-
"@0no-co/graphqlsp": "1.15.2",
8079
"@babel/core": "7.28.5",
8180
"@babel/preset-env": "7.28.5",
8281
"@biomejs/biome": "2.3.8",

pnpm-lock.yaml

Lines changed: 0 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
fragment AuthorFields on Actor {
2+
login
3+
url
4+
avatar_url: avatarUrl
5+
type: __typename
6+
}
7+
8+
fragment CommentFields on DiscussionComment {
9+
databaseId
10+
createdAt
11+
author {
12+
...AuthorFields
13+
}
14+
}
15+
16+
query fetchDiscussionByNumber(
17+
$owner: String!
18+
$name: String!
19+
$number: Int!
20+
$lastComments: Int
21+
$lastReplies: Int
22+
$firstLabels: Int
23+
$includeIsAnswered: Boolean!
24+
) {
25+
repository(owner: $owner, name: $name) {
26+
discussion(number: $number) {
27+
__typename
28+
number
29+
title
30+
stateReason
31+
isAnswered @include(if: $includeIsAnswered)
32+
url
33+
author {
34+
...AuthorFields
35+
}
36+
comments(last: $lastComments) {
37+
totalCount
38+
nodes {
39+
...CommentFields
40+
replies(last: $lastReplies) {
41+
nodes {
42+
...CommentFields
43+
}
44+
}
45+
}
46+
}
47+
labels(first: $firstLabels) {
48+
nodes {
49+
name
50+
}
51+
}
52+
}
53+
}
54+
}

src/renderer/utils/api/graphql/discussions.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/renderer/utils/api/graphql/generated/fragment-masking.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable */
2-
import { ResultOf, DocumentTypeDecoration } from '@graphql-typed-document-node/core';
3-
import { Incremental, TypedDocumentString } from './graphql';
2+
import type { ResultOf, DocumentTypeDecoration } from '@graphql-typed-document-node/core';
3+
import type { Incremental, TypedDocumentString } from './graphql';
44

55

66
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<

src/renderer/utils/api/graphql/generated/gql.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,16 @@ import * as types from './graphql';
1515
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
1616
*/
1717
type Documents = {
18-
"\n fragment AuthorFields on Actor {\n login\n url\n avatar_url: avatarUrl\n type: __typename\n }\n": typeof types.AuthorFieldsFragmentDoc,
19-
"\n fragment CommentFields on DiscussionComment {\n databaseId\n createdAt\n author {\n ...AuthorFields\n }\n }\n": typeof types.CommentFieldsFragmentDoc,
20-
"\n query fetchDiscussionByNumber(\n $owner: String!\n $name: String!\n $number: Int!\n $lastComments: Int\n $lastReplies: Int\n $firstLabels: Int\n $includeIsAnswered: Boolean!\n ) {\n repository(owner: $owner, name: $name) {\n discussion(number: $number) {\n __typename\n number\n title\n stateReason\n isAnswered @include(if: $includeIsAnswered)\n url\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n ...CommentFields\n replies(last: $lastReplies) {\n nodes {\n ...CommentFields\n }\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n }\n": typeof types.FetchDiscussionByNumberDocument,
18+
"fragment AuthorFields on Actor {\n login\n url\n avatar_url: avatarUrl\n type: __typename\n}\n\nfragment CommentFields on DiscussionComment {\n databaseId\n createdAt\n author {\n ...AuthorFields\n }\n}\n\nquery fetchDiscussionByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $lastReplies: Int, $firstLabels: Int, $includeIsAnswered: Boolean!) {\n repository(owner: $owner, name: $name) {\n discussion(number: $number) {\n __typename\n number\n title\n stateReason\n isAnswered @include(if: $includeIsAnswered)\n url\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n ...CommentFields\n replies(last: $lastReplies) {\n nodes {\n ...CommentFields\n }\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}": typeof types.AuthorFieldsFragmentDoc,
2119
};
2220
const documents: Documents = {
23-
"\n fragment AuthorFields on Actor {\n login\n url\n avatar_url: avatarUrl\n type: __typename\n }\n": types.AuthorFieldsFragmentDoc,
24-
"\n fragment CommentFields on DiscussionComment {\n databaseId\n createdAt\n author {\n ...AuthorFields\n }\n }\n": types.CommentFieldsFragmentDoc,
25-
"\n query fetchDiscussionByNumber(\n $owner: String!\n $name: String!\n $number: Int!\n $lastComments: Int\n $lastReplies: Int\n $firstLabels: Int\n $includeIsAnswered: Boolean!\n ) {\n repository(owner: $owner, name: $name) {\n discussion(number: $number) {\n __typename\n number\n title\n stateReason\n isAnswered @include(if: $includeIsAnswered)\n url\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n ...CommentFields\n replies(last: $lastReplies) {\n nodes {\n ...CommentFields\n }\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n }\n": types.FetchDiscussionByNumberDocument,
21+
"fragment AuthorFields on Actor {\n login\n url\n avatar_url: avatarUrl\n type: __typename\n}\n\nfragment CommentFields on DiscussionComment {\n databaseId\n createdAt\n author {\n ...AuthorFields\n }\n}\n\nquery fetchDiscussionByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $lastReplies: Int, $firstLabels: Int, $includeIsAnswered: Boolean!) {\n repository(owner: $owner, name: $name) {\n discussion(number: $number) {\n __typename\n number\n title\n stateReason\n isAnswered @include(if: $includeIsAnswered)\n url\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n ...CommentFields\n replies(last: $lastReplies) {\n nodes {\n ...CommentFields\n }\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}": types.AuthorFieldsFragmentDoc,
2622
};
2723

2824
/**
2925
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
3026
*/
31-
export function graphql(source: "\n fragment AuthorFields on Actor {\n login\n url\n avatar_url: avatarUrl\n type: __typename\n }\n"): typeof import('./graphql').AuthorFieldsFragmentDoc;
32-
/**
33-
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
34-
*/
35-
export function graphql(source: "\n fragment CommentFields on DiscussionComment {\n databaseId\n createdAt\n author {\n ...AuthorFields\n }\n }\n"): typeof import('./graphql').CommentFieldsFragmentDoc;
36-
/**
37-
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
38-
*/
39-
export function graphql(source: "\n query fetchDiscussionByNumber(\n $owner: String!\n $name: String!\n $number: Int!\n $lastComments: Int\n $lastReplies: Int\n $firstLabels: Int\n $includeIsAnswered: Boolean!\n ) {\n repository(owner: $owner, name: $name) {\n discussion(number: $number) {\n __typename\n number\n title\n stateReason\n isAnswered @include(if: $includeIsAnswered)\n url\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n ...CommentFields\n replies(last: $lastReplies) {\n nodes {\n ...CommentFields\n }\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n }\n"): typeof import('./graphql').FetchDiscussionByNumberDocument;
27+
export function graphql(source: "fragment AuthorFields on Actor {\n login\n url\n avatar_url: avatarUrl\n type: __typename\n}\n\nfragment CommentFields on DiscussionComment {\n databaseId\n createdAt\n author {\n ...AuthorFields\n }\n}\n\nquery fetchDiscussionByNumber($owner: String!, $name: String!, $number: Int!, $lastComments: Int, $lastReplies: Int, $firstLabels: Int, $includeIsAnswered: Boolean!) {\n repository(owner: $owner, name: $name) {\n discussion(number: $number) {\n __typename\n number\n title\n stateReason\n isAnswered @include(if: $includeIsAnswered)\n url\n author {\n ...AuthorFields\n }\n comments(last: $lastComments) {\n totalCount\n nodes {\n ...CommentFields\n replies(last: $lastReplies) {\n nodes {\n ...CommentFields\n }\n }\n }\n }\n labels(first: $firstLabels) {\n nodes {\n name\n }\n }\n }\n }\n}"): typeof import('./graphql').AuthorFieldsFragmentDoc;
4028

4129

4230
export function graphql(source: string) {

src/renderer/utils/api/graphql/generated/graphql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable */
2-
import { DocumentTypeDecoration } from '@graphql-typed-document-node/core';
2+
import type { DocumentTypeDecoration } from '@graphql-typed-document-node/core';
33
export type Maybe<T> = T | null;
44
export type InputMaybe<T> = T | null | undefined;
55
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };

0 commit comments

Comments
 (0)