Skip to content

Commit 43ffcba

Browse files
committed
Change to codegenTypes.d.ts in general
1 parent 529073b commit 43ffcba

17 files changed

+78
-68
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
examples/**/apolloMock.js
22
examples/**/codegenTypedDocuments.d.ts
3-
examples/**/codegenTypes.ts
3+
examples/**/codegenTypes.d.ts

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
examples/**/apolloMock.js
22
examples/**/codegenTypedDocuments.d.ts
3-
examples/**/codegenTypes.ts
3+
examples/**/codegenTypes.d.ts
4+
README.md

README.md

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,20 @@ The difference is that is uses generic types, so that you have type safety with
2525
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/codegenTypedDocuments.yml) -->
2626
<!-- The below code snippet is automatically added from ./examples/docs/codegenTypedDocuments.yml -->
2727
```yml
28-
schema: ./schema.graphql
29-
documents: ./documents/*.graphql
28+
schema: schema.graphql
29+
documents: src/**/*.graphql
3030
generates:
31-
./codegenTypedDocuments.d.ts:
31+
./src/codegenTypedDocuments.d.ts:
3232
plugins:
3333
- apollo-typed-documents/lib/codegenTypedDocuments
3434
config:
3535
typesModule: "@codegen-types"
36-
./codegenTypes.ts:
36+
./src/codegenTypes.d.ts:
3737
plugins:
38+
- add: 'declare module "@codegen-types" {'
39+
- add:
40+
placement: append
41+
content: "}"
3842
- typescript
3943
- typescript-operations
4044
```
@@ -67,10 +71,10 @@ the configuration needs to have more options set: [reference](examples/docs/tsco
6771

6872
### Example
6973

70-
`./documents/authors.graphql`:
74+
`src/authors.graphql`:
7175

72-
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/documents/authors.graphql) -->
73-
<!-- The below code snippet is automatically added from ./examples/docs/documents/authors.graphql -->
76+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/src/authors.graphql) -->
77+
<!-- The below code snippet is automatically added from ./examples/docs/src/authors.graphql -->
7478
```graphql
7579
query authors {
7680
authors {
@@ -86,10 +90,10 @@ query authors {
8690
```
8791
<!-- AUTO-GENERATED-CONTENT:END -->
8892

89-
`./documents/createAuthor.graphql`:
93+
`src/createAuthor.graphql`:
9094

91-
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/documents/createAuthor.graphql) -->
92-
<!-- The below code snippet is automatically added from ./examples/docs/documents/createAuthor.graphql -->
95+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/src/createAuthor.graphql) -->
96+
<!-- The below code snippet is automatically added from ./examples/docs/src/createAuthor.graphql -->
9397
```graphql
9498
mutation createAuthor($input: AuthorInput!) {
9599
createAuthor(input: $input) {
@@ -105,10 +109,10 @@ mutation createAuthor($input: AuthorInput!) {
105109
```
106110
<!-- AUTO-GENERATED-CONTENT:END -->
107111

108-
`./codegenTypedDocuments.d.ts` (generated):
112+
`src/codegenTypedDocuments.d.ts` (generated):
109113

110-
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/codegenTypedDocuments.d.ts) -->
111-
<!-- The below code snippet is automatically added from ./examples/docs/codegenTypedDocuments.d.ts -->
114+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/src/codegenTypedDocuments.d.ts) -->
115+
<!-- The below code snippet is automatically added from ./examples/docs/src/codegenTypedDocuments.d.ts -->
112116
```ts
113117
declare module "*/authors.graphql" {
114118
import { TypedDocumentNode } from "apollo-typed-documents";
@@ -126,16 +130,16 @@ declare module "*/createAuthor.graphql" {
126130
```
127131
<!-- AUTO-GENERATED-CONTENT:END -->
128132

129-
`./AuthorList.js`:
133+
`src/AuthorList.js`:
130134

131-
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/AuthorList.js) -->
132-
<!-- The below code snippet is automatically added from ./examples/docs/AuthorList.js -->
135+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/src/AuthorList.js) -->
136+
<!-- The below code snippet is automatically added from ./examples/docs/src/AuthorList.js -->
133137
```js
134138
import { useMutation, useQuery } from "@apollo/react-hooks";
135139
import React from "react";
136140
137-
import authorsQuery from "./documents/authors.graphql";
138-
import createAuthorMutation from "./documents/createAuthor.graphql";
141+
import authorsQuery from "./authors.graphql";
142+
import createAuthorMutation from "./createAuthor.graphql";
139143
140144
const AuthorList = () => {
141145
// Type of `data` is inferred (AuthorsQuery)
@@ -275,18 +279,18 @@ When used together with `codegenTypedDocuments` the data and variables are type
275279
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/codegenApolloMock.yml) -->
276280
<!-- The below code snippet is automatically added from ./examples/docs/codegenApolloMock.yml -->
277281
```yml
278-
schema: ./schema.graphql
279-
documents: ./documents/*.graphql
282+
schema: schema.graphql
283+
documents: src/**/*.graphql
280284
generates:
281-
./apolloMock.js:
285+
./src/apolloMock.js:
282286
plugins:
283287
- apollo-typed-documents/lib/codegenApolloMock
284288
```
285289
<!-- AUTO-GENERATED-CONTENT:END -->
286290
287291
### Example
288292
289-
`./schema.graphql`:
293+
`schema.graphql`:
290294

291295
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/schema.graphql) -->
292296
<!-- The below code snippet is automatically added from ./examples/docs/schema.graphql -->
@@ -328,10 +332,10 @@ schema {
328332
```
329333
<!-- AUTO-GENERATED-CONTENT:END -->
330334

331-
`./documents/authors.graphql`:
335+
`src/authors.graphql`:
332336

333-
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/documents/authors.graphql) -->
334-
<!-- The below code snippet is automatically added from ./examples/docs/documents/authors.graphql -->
337+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/src/authors.graphql) -->
338+
<!-- The below code snippet is automatically added from ./examples/docs/src/authors.graphql -->
335339
```graphql
336340
query authors {
337341
authors {
@@ -347,10 +351,10 @@ query authors {
347351
```
348352
<!-- AUTO-GENERATED-CONTENT:END -->
349353

350-
`./documents/createAuthor.graphql`:
354+
`src/createAuthor.graphql`:
351355

352-
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/documents/createAuthor.graphql) -->
353-
<!-- The below code snippet is automatically added from ./examples/docs/documents/createAuthor.graphql -->
356+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/src/createAuthor.graphql) -->
357+
<!-- The below code snippet is automatically added from ./examples/docs/src/createAuthor.graphql -->
354358
```graphql
355359
mutation createAuthor($input: AuthorInput!) {
356360
createAuthor(input: $input) {
@@ -366,18 +370,18 @@ mutation createAuthor($input: AuthorInput!) {
366370
```
367371
<!-- AUTO-GENERATED-CONTENT:END -->
368372

369-
`./apolloMock.js` (generated):
373+
`src/apolloMock.js` (generated):
370374

371-
See: [reference](examples/docs/apolloMock.js)
375+
See: [reference](examples/docs/src/apolloMock.js)
372376

373-
`./apolloMock.test.js`:
377+
`src/apolloMock.test.js`:
374378

375-
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/apolloMock.test.js) -->
376-
<!-- The below code snippet is automatically added from ./examples/docs/apolloMock.test.js -->
379+
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/docs/src/apolloMock.test.js) -->
380+
<!-- The below code snippet is automatically added from ./examples/docs/src/apolloMock.test.js -->
377381
```js
378382
import apolloMock from "./apolloMock";
379-
import authors from "./documents/authors.graphql";
380-
import createAuthor from "./documents/createAuthor.graphql";
383+
import authors from "./authors.graphql";
384+
import createAuthor from "./createAuthor.graphql";
381385
382386
describe("apolloMock", () => {
383387
it("produces the minimal output that is valid according to graphql schema", () => {

examples/cra/codegen.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
schema: ../docs/schema.graphql
22
documents: src/**/*.graphql
33
generates:
4-
./codegenTypedDocuments.d.ts:
4+
./src/codegenTypedDocuments.d.ts:
55
plugins:
66
- apollo-typed-documents/lib/codegenTypedDocuments
77
config:
88
typesModule: "@codegen-types"
9-
./codegenTypes.ts:
9+
./src/codegenTypes.d.ts:
1010
plugins:
11+
- add: 'declare module "@codegen-types" {'
12+
- add:
13+
placement: append
14+
content: "}"
1115
- typescript
1216
- typescript-operations
1317
./src/apolloMock.js:

examples/cra/codegenTypes.ts renamed to examples/cra/src/codegenTypes.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
declare module "@codegen-types" {
12
export type Maybe<T> = T | null;
3+
4+
25
/** All built-in and custom scalars, mapped to their actual values */
36
export type Scalars = {
47
ID: string;
@@ -78,3 +81,5 @@ export type CreateAuthorMutation = (
7881
)> }
7982
) }
8083
);
84+
85+
}

examples/cra/src/tsconfig.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@
55
"checkJs": true,
66
"strict": true,
77
"jsx": "react",
8-
"esModuleInterop": true,
9-
"baseUrl": ".",
10-
"paths": {
11-
"@codegen-types": ["../codegenTypes.ts"],
12-
"@apollo/react-hooks": ["../../../lib/reactHooks.d.ts"]
13-
}
8+
"esModuleInterop": true
149
},
15-
"include": [
16-
".",
17-
"../codegenTypedDocuments.d.ts",
18-
"../node_modules/@testing-library/jest-dom/extend-expect.d.ts"
19-
]
10+
"include": [".", "../../../lib/reactHooks.d.ts"]
2011
}

examples/docs/codegenApolloMock.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
schema: ./schema.graphql
2-
documents: ./documents/*.graphql
1+
schema: schema.graphql
2+
documents: src/**/*.graphql
33
generates:
4-
./apolloMock.js:
4+
./src/apolloMock.js:
55
plugins:
66
- apollo-typed-documents/lib/codegenApolloMock
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
schema: ./schema.graphql
2-
documents: ./documents/*.graphql
1+
schema: schema.graphql
2+
documents: src/**/*.graphql
33
generates:
4-
./codegenTypedDocuments.d.ts:
4+
./src/codegenTypedDocuments.d.ts:
55
plugins:
66
- apollo-typed-documents/lib/codegenTypedDocuments
77
config:
88
typesModule: "@codegen-types"
9-
./codegenTypes.ts:
9+
./src/codegenTypes.d.ts:
1010
plugins:
11+
- add: 'declare module "@codegen-types" {'
12+
- add:
13+
placement: append
14+
content: "}"
1115
- typescript
1216
- typescript-operations

examples/docs/AuthorList.js renamed to examples/docs/src/AuthorList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useMutation, useQuery } from "@apollo/react-hooks";
22
import React from "react";
33

4-
import authorsQuery from "./documents/authors.graphql";
5-
import createAuthorMutation from "./documents/createAuthor.graphql";
4+
import authorsQuery from "./authors.graphql";
5+
import createAuthorMutation from "./createAuthor.graphql";
66

77
const AuthorList = () => {
88
// Type of `data` is inferred (AuthorsQuery)

0 commit comments

Comments
 (0)