- https://hasura.io/cloud/
- Login
- New Project ---> Free Tier ---> Create Free Project
- General ---> Name ---> Hogehoge
- Admin Secret ---> Copy
- Launch Console
- Data ---> Create Heroku Database ---> Heroku Icon Click
- Public ---> Create Table
yarn add @apollo/client graphql
yarn add -D @graphql-codegen/cli @graphql-codegen/typescript
- yarn graphql-codegen init
- What type of application are you building? Application built with React
- Where is your schema?: hasura API url
- Where are your operations and fragments?:
src/queries/**/*.ts
- Pick plugins: Y
- Where to write the output:
types/generated/graphql.tsx
- Do you want to generate an introspection file?: n
- How to name the config file?
codegen.yml
- What script in package.json should run the codegen? gen-types
mkdir src/queries
touch src/queries/queries.ts
... Writing Schemas.env.local
Edit- https://www.graphql-code-generator.com/docs/config-reference/require-field#customize-loaded-env-file
- Yaml上に定義した環境変数を読み込むためには、
--require dotenv/config
を自動生成実行オプションに追加する - デフォルトだと、
.env
しか読まないので、.env.local
を読み込ませるために、次のコマンドをNPMScriptに追記する. "gen-types": "DOTENV_CONFIG_PATH=\"./.env.local\" graphql-codegen --require dotenv/config --config codegen.yml"
- Yaml上に定義した環境変数を読み込むためには、
- https://www.graphql-code-generator.com/docs/config-reference/require-field#customize-loaded-env-file
yarn gen-types