From 529181c021921e1a6b270f415d024d01b4caeb7a Mon Sep 17 00:00:00 2001 From: "mirlan.maksitaliev" Date: Mon, 1 Jun 2020 20:37:36 +0600 Subject: [PATCH] chore: added code generation config --- codegen.yml | 22 ++++++++++++++++++++++ package.json | 16 +++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 codegen.yml diff --git a/codegen.yml b/codegen.yml new file mode 100644 index 00000000..7801e848 --- /dev/null +++ b/codegen.yml @@ -0,0 +1,22 @@ +overwrite: true +schema: '' +documents: src/api/operations/**/*.graphql +generates: + src/types/index.tsx: + plugins: + - typescript + src/: + preset: + near-operation-file + presetConfig: + extension: .tsx + baseTypesPath: types + plugins: + - typescript-operations + - typescript-react-apollo + config: + withComponent: false + withHOC: false + withHooks: true +config: + typesPrefix: T diff --git a/package.json b/package.json index a4d7cab2..f1c2b61c 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,19 @@ "version": "0.1.0", "private": true, "scripts": { + "prestart ": "yarn generate", "start": "react-scripts start", "build": "GENERATE_SOURCEMAP=false react-scripts build && gzipper --verbose ./build", "test": "react-scripts test --passWithNoTests --watchAll=false", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "generate": "graphql-codegen --config codegen.yml" }, "dependencies": { + "@apollo/react-common": "^3.1.4", + "@apollo/react-hooks": "^3.1.5", + "apollo-boost": "^0.4.9", + "graphql": "^15.0.0", + "lodash": "^4.17.15", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.1" @@ -16,10 +23,17 @@ "devDependencies": { "@commitlint/cli": "^8.3.5", "@commitlint/config-conventional": "^8.3.4", + "@graphql-codegen/cli": "1.15.0", + "@graphql-codegen/import-types-preset": "^1.15.0", + "@graphql-codegen/near-operation-file-preset": "^1.15.0", + "@graphql-codegen/typescript": "1.15.0", + "@graphql-codegen/typescript-operations": "1.15.0", + "@graphql-codegen/typescript-react-apollo": "1.15.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "@types/jest": "^24.0.0", + "@types/lodash": "^4.14.154", "@types/node": "^12.0.0", "@types/react": "^16.9.0", "@types/react-dom": "^16.9.0",