Skip to content

Commit bdd6573

Browse files
committed
Setup gql.tada
1 parent 4f1389d commit bdd6573

File tree

8 files changed

+131
-3
lines changed

8 files changed

+131
-3
lines changed

.eslintrc.cjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ const restrictedImports = [
9393
kind: 'value',
9494
message: 'Be sure to specify the `type` modifier',
9595
},
96+
{
97+
importNames: ['ResultOf', 'VariablesOf'],
98+
path: '@graphql-typed-document-node/core',
99+
replacement: { path: '~/graphql' },
100+
},
101+
{
102+
importNames: ['FragmentOf', 'ResultOf', 'VariablesOf'],
103+
path: 'gql.tada',
104+
replacement: { path: '~/graphql' },
105+
},
96106
];
97107

98108
const namingConvention = [

.github/workflows/lint.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ jobs:
2121
- name: Check for no duplicate dependencies
2222
run: yarn dedupe --check
2323

24+
- name: Generate GQL Schema
25+
run: yarn start -- --gen-schema && yarn gql-tada generate output
26+
2427
- name: Check TypeScript
2528
run: yarn type-check
2629

27-
- name: Generate GQL Schema
28-
run: yarn start -- --gen-schema
2930
- name: Upload GQL Schema
3031
uses: actions/upload-artifact@v4
3132
with:

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
- name: Gel Setup
1919
uses: ./.github/actions/gel-setup
2020

21+
- name: Generate GQL Schema
22+
run: yarn start -- --gen-schema && yarn gql-tada generate output
23+
2124
- name: Tests
2225
run: yarn test --reporters=github-actions
2326

@@ -59,6 +62,9 @@ jobs:
5962
- name: Gel Setup
6063
uses: ./.github/actions/gel-setup
6164

65+
- name: Generate GQL Schema
66+
run: yarn start -- --gen-schema && yarn gql-tada generate output
67+
6268
- name: E2E Tests
6369
run: yarn test:e2e --shard=${{ matrix.shard }}/6 --reporters=github-actions
6470
env:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
src/core/gel/generated-client
88
src/core/gel/schema.ts
99
src/**/*.edgeql.ts
10+
*.generated.*
1011

1112
# Yarn / NPM
1213
.yarn/cache

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"gel": "^2.1.0-canary.20250319T143140",
7575
"glob": "^11.0.2",
7676
"got": "^14.3.0",
77+
"gql.tada": "^1.8.10",
7778
"graphql": "^16.9.0",
7879
"graphql-parse-resolve-info": "^4.14.0",
7980
"graphql-scalars": "^1.22.4",

src/graphql.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* eslint-disable @seedcompany/no-restricted-imports */
2+
import { initGraphQLTada, type VariablesOf } from 'gql.tada';
3+
import { type ID } from '~/common';
4+
import type { introspection } from './graphql-env.generated';
5+
6+
export const graphql = initGraphQLTada<{
7+
introspection: introspection;
8+
scalars: {
9+
ID: ID;
10+
Date: string;
11+
DateTime: string;
12+
InlineMarkdown: string;
13+
Markdown: string;
14+
RichText: object;
15+
URL: string;
16+
};
17+
disableMasking: true;
18+
}>();
19+
20+
export type { FragmentOf, ResultOf, VariablesOf } from 'gql.tada';
21+
export { readFragment } from 'gql.tada';
22+
23+
export type InputOf<T> = VariablesOf<T> extends { input: infer Input }
24+
? Input
25+
: never;

tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
"plugins": [
3838
{ "transform": "typescript-transform-paths" },
3939
{ "transform": "./src/core/resources/plugin/index.js" },
40+
{
41+
"name": "gql.tada/ts-plugin",
42+
"schema": "./schema.graphql",
43+
"tadaOutputLocation": "./src/graphql-env.generated.d.ts",
44+
"tadaTurboLocation": "./src/graphql-op-cache.generated.d.ts",
45+
},
4046
],
4147

4248
// Path resolution
@@ -46,6 +52,7 @@
4652
"~/common/*": ["./src/common/*"],
4753
"~/core": ["./src/core"],
4854
"~/core/*": ["./src/core/*"],
55+
"~/graphql": ["./src/graphql"],
4956
},
5057

5158
// Compilation

yarn.lock

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,31 @@ __metadata:
55
version: 8
66
cacheKey: 10c0
77

8+
"@0no-co/graphql.web@npm:^1.0.5":
9+
version: 1.1.2
10+
resolution: "@0no-co/graphql.web@npm:1.1.2"
11+
peerDependencies:
12+
graphql: ^14.0.0 || ^15.0.0 || ^16.0.0
13+
peerDependenciesMeta:
14+
graphql:
15+
optional: true
16+
checksum: 10c0/7074de29681f0563cb9a90d702c7cda4443dce858e09f9a09adbafe32c302890cab81959ccba4ed7ac3e332423b2928a1dc95dd4a5004e6a5c156b733caa349a
17+
languageName: node
18+
linkType: hard
19+
20+
"@0no-co/graphqlsp@npm:^1.12.13":
21+
version: 1.12.16
22+
resolution: "@0no-co/graphqlsp@npm:1.12.16"
23+
dependencies:
24+
"@gql.tada/internal": "npm:^1.0.0"
25+
graphql: "npm:^15.5.0 || ^16.0.0 || ^17.0.0"
26+
peerDependencies:
27+
graphql: ^15.5.0 || ^16.0.0 || ^17.0.0
28+
typescript: ^5.0.0
29+
checksum: 10c0/e802fe7c719d68e1279f98da161d2b619f93a6768e82dee331af3d35b03b711f1e2b10911d0acae0dbd6fc72a3fea441fbc6c58aae6f75f269d9d4a48a2069bf
30+
languageName: node
31+
linkType: hard
32+
833
"@ampproject/remapping@npm:^2.2.0":
934
version: 2.3.0
1035
resolution: "@ampproject/remapping@npm:2.3.0"
@@ -1551,6 +1576,40 @@ __metadata:
15511576
languageName: node
15521577
linkType: hard
15531578

1579+
"@gql.tada/cli-utils@npm:1.6.3":
1580+
version: 1.6.3
1581+
resolution: "@gql.tada/cli-utils@npm:1.6.3"
1582+
dependencies:
1583+
"@0no-co/graphqlsp": "npm:^1.12.13"
1584+
"@gql.tada/internal": "npm:1.0.8"
1585+
graphql: "npm:^15.5.0 || ^16.0.0 || ^17.0.0"
1586+
peerDependencies:
1587+
"@0no-co/graphqlsp": ^1.12.13
1588+
"@gql.tada/svelte-support": 1.0.1
1589+
"@gql.tada/vue-support": 1.0.1
1590+
graphql: ^15.5.0 || ^16.0.0 || ^17.0.0
1591+
typescript: ^5.0.0
1592+
peerDependenciesMeta:
1593+
"@gql.tada/svelte-support":
1594+
optional: true
1595+
"@gql.tada/vue-support":
1596+
optional: true
1597+
checksum: 10c0/5a2a8e8c082fc63ae497d569e6ffec8ff2e4a58456b92c7d0b82ab3f68f5ac2a63c011f5fcd046f161240cb2661f9c3ab152cc0d977f33fa5016ea341d20c22b
1598+
languageName: node
1599+
linkType: hard
1600+
1601+
"@gql.tada/internal@npm:1.0.8, @gql.tada/internal@npm:^1.0.0":
1602+
version: 1.0.8
1603+
resolution: "@gql.tada/internal@npm:1.0.8"
1604+
dependencies:
1605+
"@0no-co/graphql.web": "npm:^1.0.5"
1606+
peerDependencies:
1607+
graphql: ^15.5.0 || ^16.0.0 || ^17.0.0
1608+
typescript: ^5.0.0
1609+
checksum: 10c0/dd9b34296160f7eb4374b1791dd9353fd4147f4d7e2a3a8e2974c2319dc6165a4458c19d9b517a3f7764da4e7a4401c099fdf1936841de02c0e565db95d64a5d
1610+
languageName: node
1611+
linkType: hard
1612+
15541613
"@graphql-hive/cli@npm:>=0.44":
15551614
version: 0.49.1
15561615
resolution: "@graphql-hive/cli@npm:0.49.1"
@@ -5883,6 +5942,7 @@ __metadata:
58835942
gel: "npm:^2.1.0-canary.20250319T143140"
58845943
glob: "npm:^11.0.2"
58855944
got: "npm:^14.3.0"
5945+
gql.tada: "npm:^1.8.10"
58865946
graphql: "npm:^16.9.0"
58875947
graphql-parse-resolve-info: "npm:^4.14.0"
58885948
graphql-scalars: "npm:^1.22.4"
@@ -8035,6 +8095,23 @@ __metadata:
80358095
languageName: node
80368096
linkType: hard
80378097

8098+
"gql.tada@npm:^1.8.10":
8099+
version: 1.8.10
8100+
resolution: "gql.tada@npm:1.8.10"
8101+
dependencies:
8102+
"@0no-co/graphql.web": "npm:^1.0.5"
8103+
"@0no-co/graphqlsp": "npm:^1.12.13"
8104+
"@gql.tada/cli-utils": "npm:1.6.3"
8105+
"@gql.tada/internal": "npm:1.0.8"
8106+
peerDependencies:
8107+
typescript: ^5.0.0
8108+
bin:
8109+
gql-tada: bin/cli.js
8110+
gql.tada: bin/cli.js
8111+
checksum: 10c0/b0485a9cfcd5bfd327bc3d7533654184808eadbf6d47bcb8cdc8655f2dc3928ec0b1a8ffb5f57345f0902370dc0c249f85827644fa5f9eace0817a1f812b1dc2
8112+
languageName: node
8113+
linkType: hard
8114+
80388115
"graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6, graceful-fs@npm:^4.2.9":
80398116
version: 4.2.11
80408117
resolution: "graceful-fs@npm:4.2.11"
@@ -8125,7 +8202,7 @@ __metadata:
81258202
languageName: node
81268203
linkType: hard
81278204

8128-
"graphql@npm:^16.8.1, graphql@npm:^16.9.0":
8205+
"graphql@npm:^15.5.0 || ^16.0.0 || ^17.0.0, graphql@npm:^16.8.1, graphql@npm:^16.9.0":
81298206
version: 16.11.0
81308207
resolution: "graphql@npm:16.11.0"
81318208
checksum: 10c0/124da7860a2292e9acf2fed0c71fc0f6a9b9ca865d390d112bdd563c1f474357141501c12891f4164fe984315764736ad67f705219c62f7580681d431a85db88

0 commit comments

Comments
 (0)