Skip to content

Commit 95a92a6

Browse files
committed
fixes and cleanup
break to packages
1 parent 5d0736d commit 95a92a6

33 files changed

+84
-29
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,19 @@ This project works in the following way:
2222

2323
Most libraries supports `DocumentNode` as the type of the query object, but that's not enough to use this library.
2424

25+
Our goal is to get built-in support in major libraries, in order
26+
2527
In order to extend the behavior, we are using `patch-package` library internally, to add support for `TypedDocumentNode` and add the support for type inference.
2628

2729
The following patches are currently supported:
2830

31+
## Built-in
32+
33+
- `@apollo/client` (since `v3.2.0`)
34+
- `apollo-angular` (v2)
35+
36+
## With Patch
37+
2938
- `graphql` (`14.7.0`, `15.0.0`, `15.1.0`, `~15.2.0`)
3039
- `@apollo/client` (`~3.0.0`, `~3.1.0`)
3140
- `apollo-client` (`~2.6.10`, including `apollo-cache`)
@@ -69,7 +78,15 @@ generates:
6978
7079
3. Try to run codegen by using: `yarn graphql-codegen`, it should create the `./src/graphql-operations.ts` file for you, with the generated `TypedDocumentNode` objects.
7180

72-
4. Configure the patch CLI to run as `postinstall` script:
81+
If you are using a library that doesn't support `TypedDocumentNode` yet, you can apply a patch, by doing:
82+
83+
1. Install the patch-cli:
84+
85+
```
86+
yarn add -D @graphql-typed-document-node/patch-cli
87+
```
88+
89+
2. Configure the patch CLI to run as `postinstall` script:
7390

7491
```json
7592
{
@@ -79,6 +96,8 @@ generates:
7996
}
8097
```
8198

99+
5. Reinstall dependencies (using npm or yarn) - it will now patch the relevant libraries.
100+
82101
Now, after installing your projects' dependencies, it will make sure to patch all relevant packages and make it available for use with `TypedDocumentNode`.
83102

84103
## How can I support this in my library?

examples/apollo-client-3/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "apollo-client-example",
33
"private": true,
4-
"version": "2.0.0",
4+
"version": "2.1.0",
55
"scripts": {
66
"postinstall": "patch-typed-document-node && yarn generate",
77
"generate": "graphql-codegen",
@@ -12,8 +12,9 @@
1212
"@types/node": "14.0.23",
1313
"graphql": "15.3.0",
1414
"typescript": "3.9.7",
15-
"@apollo/client": "3.1.0",
16-
"@graphql-typed-document-node/core": "2.0.0",
15+
"@apollo/client": "3.1.2",
16+
"@graphql-typed-document-node/core": "2.1.0",
17+
"@graphql-typed-document-node/patch-cli": "2.1.0",
1718
"@graphql-codegen/typed-document-node": "1.17.7",
1819
"@graphql-codegen/cli": "1.17.7",
1920
"@graphql-codegen/typescript": "1.17.7",

examples/graphql/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "graphql-example",
33
"private": true,
4-
"version": "2.0.0",
4+
"version": "2.1.0",
55
"scripts": {
66
"postinstall": "patch-typed-document-node && yarn generate",
77
"generate": "graphql-codegen",
@@ -12,7 +12,8 @@
1212
"@types/node": "14.0.23",
1313
"graphql": "15.3.0",
1414
"typescript": "3.9.7",
15-
"@graphql-typed-document-node/core": "2.0.0",
15+
"@graphql-typed-document-node/core": "2.1.0",
16+
"@graphql-typed-document-node/patch-cli": "2.1.0",
1617
"@graphql-codegen/typed-document-node": "1.17.7",
1718
"@graphql-codegen/cli": "1.17.7",
1819
"@graphql-codegen/typescript": "1.17.7",

packages/core/package.json

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,19 @@
1111
"typescript": {
1212
"definition": "dist/index.d.ts"
1313
},
14-
"bin": {
15-
"patch-typed-document-node": "dist/patch-cli.js"
16-
},
1714
"scripts": {
1815
"test": "jest",
1916
"prepack": "bob prepack"
2017
},
21-
"dependencies": {
22-
"patch-package": "6.2.2",
23-
"semver": "7.3.2"
24-
},
2518
"devDependencies": {
2619
"bob-the-bundler": "1.1.0",
27-
"@types/tmp": "0.2.0",
28-
"tmp": "0.2.1",
29-
"@types/semver": "7.3.1",
30-
"@graphql-codegen/typed-document-node": "1.17.4",
31-
"@graphql-codegen/cli": "1.17.4",
32-
"@graphql-codegen/typescript": "1.17.4",
33-
"@graphql-codegen/typescript-operations": "1.17.4",
3420
"graphql": "15.3.0",
3521
"typescript": "3.9.7"
3622
},
3723
"peerDependencies": {
3824
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
3925
},
4026
"buildOptions": {
41-
"copy": [
42-
"src/patches/*.patch"
43-
],
44-
"bin": {
45-
"patch-typed-document-node": {
46-
"input": "src/patch-cli.ts"
47-
}
48-
},
4927
"input": "./src/index.ts"
5028
},
5129
"publishConfig": {

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { DocumentNode } from 'graphql';
22

3-
export interface TypedDocumentNode<Result = {}, Variables = {}> extends DocumentNode {}
3+
export interface TypedDocumentNode<Result = { [key: string]: any }, Variables = { [key: string]: any }> extends DocumentNode { }

packages/patch-cli/package.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "@graphql-typed-document-node/patch-cli",
3+
"version": "2.1.0",
4+
"repository": "git@github.com:dotansimha/graphql-typed-document-node.git",
5+
"author": "Dotan Simha <dotansimha@gmail.com>",
6+
"license": "MIT",
7+
"sideEffects": false,
8+
"main": "dist/index.cjs.js",
9+
"module": "dist/index.esm.js",
10+
"typings": "dist/index.d.ts",
11+
"typescript": {
12+
"definition": "dist/index.d.ts"
13+
},
14+
"bin": {
15+
"patch-typed-document-node": "dist/patch-cli.js"
16+
},
17+
"scripts": {
18+
"test": "jest",
19+
"prepack": "bob prepack"
20+
},
21+
"dependencies": {
22+
"patch-package": "6.2.2",
23+
"semver": "7.3.2"
24+
},
25+
"devDependencies": {
26+
"bob-the-bundler": "1.1.0",
27+
"@types/tmp": "0.2.0",
28+
"tmp": "0.2.1",
29+
"@types/semver": "7.3.1",
30+
"@graphql-codegen/typed-document-node": "1.17.4",
31+
"@graphql-codegen/cli": "1.17.4",
32+
"@graphql-codegen/typescript": "1.17.4",
33+
"@graphql-codegen/typescript-operations": "1.17.4",
34+
"graphql": "15.3.0",
35+
"typescript": "3.9.7"
36+
},
37+
"peerDependencies": {
38+
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
39+
},
40+
"buildOptions": {
41+
"copy": [
42+
"src/patches/*.patch"
43+
],
44+
"bin": {
45+
"patch-typed-document-node": {
46+
"input": "src/patch-cli.ts"
47+
}
48+
},
49+
"input": "./src/index.ts"
50+
},
51+
"publishConfig": {
52+
"access": "public"
53+
}
54+
}

packages/patch-cli/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './patch';
2+
export * from './patch-cli';

packages/core/src/patches/@apollo+client+~3.0.0.patch renamed to packages/patch-cli/src/patches/@apollo+client+~3.0.0.patch

File renamed without changes.

0 commit comments

Comments
 (0)