Skip to content
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
32 changes: 20 additions & 12 deletions codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ const generates: CodegenConfig['generates'] = {
};

if (process.env.GITHUB_TOKEN) {
generates['src/renderer/utils/forges/github/graphql/generated/graphql.ts'] = {
schema: {
'https://api.github.com/graphql': {
headers: {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
// Hierarchy and issue fields each require their GraphQL schema feature.
'GraphQL-Features': 'sub_issues,issue_fields',
},
// GitHub's live schema currently fails graphql-js's stricter
// interface-deprecation-consistency validation (added in graphql v17).
// Skip validation so introspection can still succeed.
assumeValid: true,
const githubSchema: CodegenConfig['schema'] = {
'https://api.github.com/graphql': {
headers: {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
// Hierarchy and issue fields each require their GraphQL schema feature.
'GraphQL-Features': 'sub_issues,issue_fields',
},
// GitHub's live schema currently fails graphql-js's stricter
// interface-deprecation-consistency validation (added in graphql v17).
// Skip validation so introspection can still succeed.
assumeValid: true,
},
};

generates['src/renderer/utils/forges/github/graphql/generated/graphql.ts'] = {
schema: githubSchema,
documents: ['src/renderer/utils/forges/github/**/*.graphql'],
plugins: ['typescript-operations', 'typed-document-node'],
config: {
Expand All @@ -55,6 +57,12 @@ if (process.env.GITHUB_TOKEN) {
useTypeImports: true,
},
};

// Schema snapshot the GraphQL editor loads offline (see graphql.config.ts).
generates['src/renderer/utils/forges/github/graphql/generated/schema.graphql'] = {
schema: githubSchema,
plugins: ['schema-ast'],
};
} else {
// oxlint-disable-next-line no-console -- CLI script output
console.warn(
Expand Down
12 changes: 10 additions & 2 deletions graphql.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import type { IGraphQLConfig } from 'graphql-config';

const config: IGraphQLConfig = {
schema: './src/renderer/utils/api/graphql/generated/schema.graphql',
documents: ['src/renderer/utils/api/**/*.graphql'],
projects: {
github: {
schema: './src/renderer/utils/forges/github/graphql/generated/schema.graphql',
documents: ['src/renderer/utils/forges/github/**/*.graphql'],
},
bitbucket: {
schema: 'https://developer.atlassian.com/gateway/api/graphql',
documents: ['src/renderer/utils/forges/bitbucket/**/*.graphql'],
},
},
};

export default config;
Loading