Skip to content

Commit a992d8f

Browse files
committed
Add apollo-typed-documents as dependency to examples
1 parent 43ffcba commit a992d8f

File tree

10 files changed

+38
-20
lines changed

10 files changed

+38
-20
lines changed

README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,24 @@ generates:
4646
4747
`tsconfig.json`:
4848

49+
Add `node_modules/apollo-typed-documents/lib/reactHooks.d.ts` in `include` to override the typings for `@apollo/react-hooks`, so that types can be inferred from typed documents.
50+
51+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/tsconfig.json) -->
52+
<!-- The below code snippet is automatically added from ./examples/docs/tsconfig.json -->
4953
```json
5054
{
5155
"compilerOptions": {
52-
"baseUrl": ".",
53-
"paths": {
54-
"@codegen-types": ["codegenTypes.ts"],
55-
"@apollo/react-hooks": [
56-
"./node_modules/apollo-typed-documents/lib/reactHooks.d.ts"
57-
]
58-
}
59-
}
56+
"noEmit": true,
57+
"allowJs": true,
58+
"checkJs": true,
59+
"strict": true,
60+
"jsx": "react",
61+
"esModuleInterop": true
62+
},
63+
"include": ["src", "node_modules/apollo-typed-documents/lib/reactHooks.d.ts"]
6064
}
6165
```
62-
63-
`@codegen-types` points to the output of `typescript-operations` graphql-codegen plugin.
64-
65-
This alias is required, because in ambient module declarations (`.d.ts`) only non relative imports are allowed.
66-
67-
`@apollo/react-hooks` overrides the types to have generic hooks in your code: [reference](src/reactHooks.ts)
68-
69-
If you don't have a TypeScript project but instead just want to get type safety and code completion,
70-
the configuration needs to have more options set: [reference](examples/docs/tsconfig.json)
66+
<!-- AUTO-GENERATED-CONTENT:END -->
7167

7268
### Example
7369

examples/cra-ts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@types/node": "^12.0.0",
1313
"@types/react": "^16.9.0",
1414
"@types/react-dom": "^16.9.0",
15+
"apollo-typed-documents": "link:../..",
1516
"babel-plugin-import-graphql": "^2.7.0",
1617
"customize-cra": "^0.9.1",
1718
"react": "^16.13.1",

examples/cra-ts/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
"noEmit": true,
1616
"jsx": "react"
1717
},
18-
"include": ["src", "../../lib/reactHooks.d.ts"]
18+
"include": ["src", "node_modules/apollo-typed-documents/lib/reactHooks.d.ts"]
1919
}

examples/cra-ts/yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,10 @@ anymatch@~3.1.1:
19031903
normalize-path "^3.0.0"
19041904
picomatch "^2.0.4"
19051905

1906+
"apollo-typed-documents@link:../..":
1907+
version "0.0.0"
1908+
uid ""
1909+
19061910
aproba@^1.1.1:
19071911
version "1.2.0"
19081912
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"

examples/cra/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@testing-library/jest-dom": "^4.2.4",
99
"@testing-library/react": "^9.3.2",
1010
"@testing-library/user-event": "^7.1.2",
11+
"apollo-typed-documents": "link:../..",
1112
"babel-plugin-import-graphql": "^2.7.0",
1213
"customize-cra": "^0.9.1",
1314
"react": "^16.13.1",

examples/cra/src/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"jsx": "react",
88
"esModuleInterop": true
99
},
10-
"include": [".", "../../../lib/reactHooks.d.ts"]
10+
"include": [".", "../node_modules/apollo-typed-documents/lib/reactHooks.d.ts"]
1111
}

examples/cra/yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,10 @@ anymatch@~3.1.1:
18911891
normalize-path "^3.0.0"
18921892
picomatch "^2.0.4"
18931893

1894+
"apollo-typed-documents@link:../..":
1895+
version "0.0.0"
1896+
uid ""
1897+
18941898
aproba@^1.1.1:
18951899
version "1.2.0"
18961900
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"

examples/docs/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"apollo-typed-documents": "link:../.."
4+
}
5+
}

examples/docs/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"jsx": "react",
88
"esModuleInterop": true
99
},
10-
"include": ["src", "../../lib/reactHooks.d.ts"]
10+
"include": ["src", "node_modules/apollo-typed-documents/lib/reactHooks.d.ts"]
1111
}

examples/docs/yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"apollo-typed-documents@link:../..":
6+
version "0.0.0"
7+
uid ""

0 commit comments

Comments
 (0)