Skip to content

Commit 680ba5d

Browse files
committed
Simplify GraphQL setup
This removes the unified GraphQL cache, as invalidation is annoying. It also fixes inconsistent codegen behaviors.
1 parent 4a5bb5d commit 680ba5d

File tree

9 files changed

+36
-5195
lines changed

9 files changed

+36
-5195
lines changed

frontend/codegen.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66

77
import type { CodegenConfig } from "@graphql-codegen/cli";
88

9-
// Adds a comment to the top of generated files to ignore linting and formatting
10-
const lintIgnore = {
11-
add: {
12-
content: "/* prettier-ignore */\n/* eslint-disable */",
13-
},
14-
} as const;
15-
169
const config: CodegenConfig = {
1710
schema: "./schema.graphql",
1811
documents: ["src/**/*.{tsx,ts}", "!src/gql/**/*"],
@@ -21,17 +14,14 @@ const config: CodegenConfig = {
2114
"./src/gql/": {
2215
preset: "client",
2316
config: {
17+
useTypeImports: true,
2418
// By default, unknown scalars are generated as `any`. This is not ideal for catching potential bugs.
2519
defaultScalarType: "unknown",
2620
scalars: {
2721
DateTime: "string",
2822
Url: "string",
2923
},
3024
},
31-
plugins: [lintIgnore],
32-
},
33-
"./src/gql/schema.ts": {
34-
plugins: ["urql-introspection", lintIgnore],
3525
},
3626
},
3727
};

frontend/package-lock.json

Lines changed: 18 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"@tanstack/router-zod-adapter": "^1.70.0",
2626
"@urql/core": "^5.0.6",
2727
"@urql/devtools": "^2.0.3",
28-
"@urql/exchange-graphcache": "^7.2.0",
2928
"@urql/exchange-refocus": "^1.1.0",
3029
"@urql/exchange-request-policy": "^1.2.0",
3130
"@vector-im/compound-design-tokens": "1.8.0",
@@ -52,7 +51,7 @@
5251
"@codecov/vite-plugin": "^1.2.0",
5352
"@graphql-codegen/add": "^5.0.3",
5453
"@graphql-codegen/cli": "^5.0.3",
55-
"@graphql-codegen/client-preset": "4.3.3",
54+
"@graphql-codegen/client-preset": "^4.4.0",
5655
"@graphql-codegen/urql-introspection": "^3.0.0",
5756
"@storybook/addon-essentials": "^8.3.5",
5857
"@storybook/react": "^8.3.5",

frontend/src/gql/fragment-masking.ts

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

66

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

frontend/src/gql/gql.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable */
22
import * as types from './graphql';
3-
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
3+
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
44

55
/**
66
* Map of all GraphQL operations in the project.
@@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
1111
* 3. It does not support dead code elimination, so it will add unused operations.
1212
*
1313
* Therefore it is highly recommended to use the babel or swc plugin for production.
14+
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
1415
*/
1516
const documents = {
1617
"\n fragment PasswordChange_siteConfig on SiteConfig {\n id\n passwordChangeAllowed\n }\n": types.PasswordChange_SiteConfigFragmentDoc,

0 commit comments

Comments
 (0)