Skip to content

Commit

Permalink
add comments to generated code; fix doc watch command
Browse files Browse the repository at this point in the history
  • Loading branch information
mipyykko committed Aug 12, 2022
1 parent 8147f01 commit 03f8e71
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 35 deletions.
2 changes: 1 addition & 1 deletion backend/graphql/Completion/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated Mon Jul 11 2022 17:59:37 GMT+0300 (Itä-Euroopan kesäaika)
// generated Thu Aug 11 2022 17:12:07 GMT+0300 (Itä-Euroopan kesäaika)

export * from "./input"
export * from "./model"
Expand Down
2 changes: 1 addition & 1 deletion backend/graphql/Course/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated Mon Jul 11 2022 17:59:37 GMT+0300 (Itä-Euroopan kesäaika)
// generated Thu Aug 11 2022 17:12:07 GMT+0300 (Itä-Euroopan kesäaika)

export * from "./input"
export * from "./model"
Expand Down
2 changes: 1 addition & 1 deletion backend/graphql/StudyModule/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated Mon Jul 11 2022 17:59:37 GMT+0300 (Itä-Euroopan kesäaika)
// generated Thu Aug 11 2022 17:12:07 GMT+0300 (Itä-Euroopan kesäaika)

export * from "./input"
export * from "./model"
Expand Down
2 changes: 1 addition & 1 deletion backend/graphql/User/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated Mon Jul 11 2022 17:59:37 GMT+0300 (Itä-Euroopan kesäaika)
// generated Thu Aug 11 2022 17:12:07 GMT+0300 (Itä-Euroopan kesäaika)

export * from "./input"
export * from "./model"
Expand Down
2 changes: 1 addition & 1 deletion backend/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated Mon Jul 11 2022 17:59:37 GMT+0300 (Itä-Euroopan kesäaika)
// generated Thu Aug 11 2022 17:12:07 GMT+0300 (Itä-Euroopan kesäaika)

export * from "./ABEnrollment"
export * from "./ABStudy"
Expand Down
2 changes: 1 addition & 1 deletion docs/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If you make changes to the GraphQL schema, resolvers etc. in the backend and/or

Ensure you have a fresh GraphQL schema by running `npm run generate` in the backend folder.

Then run `npm run graphql-codegen` in the frontend folder. You can also run `npm run graphql-codegen --watch` to watch for changes and regenerate the frontend types automatically.
Then run `npm run graphql-codegen` in the frontend folder. You can also run `npm run graphql-codegen:watch` to watch for changes and regenerate the frontend types automatically.

## Detailed example from backend to frontend:

Expand Down
11 changes: 1 addition & 10 deletions frontend/apollo.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
const path = require("path")
module.exports = {
client: {
tagName: "gql",
includes: [
"./components/**/*.tsx",
"./pages/**/*.tsx",
"./components/**/*.ts",
"./pages/**/*.ts",
"./graphql/**/*.ts",
"./lib/**/*.tsx",
"./lib/**/*.ts",
],
includes: ["./graphql/**/*.graphql"],
excludes: ["node_modules"],
service: {
name: "backend",
Expand Down
17 changes: 12 additions & 5 deletions frontend/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@ config:
avoidOptionals:
field: true
nonOptionalTypeName: true
dedupeFragments: true
hooks:
afterAllFileWrite:
- prettier --write
generates:
./graphql/generated/index.ts:
pluckConfig:
modules:
- name: "@apollo/client"
identifier: gql
config:
dedupeFragments: true
plugins:
- add:
placement: "prepend"
content:
- "/**"
- " * This is an automatically generated file."
- " * Run `npm run graphql-codegen` to regenerate."
- " **/"
- time
- typescript
- typescript-operations
- fragment-matcher
- typed-document-node
hooks:
afterOneFileWrite:
- prettier --write
7 changes: 7 additions & 0 deletions frontend/graphql/generated/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* This is an automatically generated file.
* Run `npm run graphql-codegen` to regenerate.
**/

import { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core"

export type Maybe<T> = T | null
Expand All @@ -11,6 +16,8 @@ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
[SubKey in K]: Maybe<T[SubKey]>
}
// Generated on 2022-08-12T12:58:30+03:00

/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string
Expand Down
53 changes: 39 additions & 14 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@
"yup": "^0.32.11"
},
"devDependencies": {
"@graphql-codegen/add": "^3.2.1",
"@graphql-codegen/cli": "2.11.3",
"@graphql-codegen/fragment-matcher": "^3.3.0",
"@graphql-codegen/gql-tag-operations-preset": "^1.5.3",
"@graphql-codegen/time": "^3.2.1",
"@graphql-codegen/typescript": "2.7.2",
"@graphql-codegen/typescript-document-nodes": "^2.3.2",
"@graphql-codegen/typescript-operations": "^2.5.2",
Expand Down

0 comments on commit 03f8e71

Please sign in to comment.