Last active
April 4, 2020 01:56
-
-
Save timbophillips/b430c8241cdd6fe62a683e79b4845a9f to your computer and use it in GitHub Desktop.
codegen angular apollog hasura graphql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://github.com/dotansimha/graphql-code-generator/issues/2043 | |
| https://medium.com/angular-in-depth/configuring-a-angular-cli-project-with-graphql-37217f66d419 | |
| https://github.com/dotansimha/graphql-code-generator/issues/2043#issuecomment-508540316 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CLI commands:
ng new graphql3 cd graphql3 ng add apollo-angular npm install -s apollo-link-ws subscriptions-transport-wsModify
angular.jsonto add pointer to proxy config fileadd a new file
src/proxy.conf.jsonwith proxy settings:modify
src/app/graphql.nodule.tsto differentiate websocket requests, modify the url, and access via proxy:back to the command line
add / modify package scripts in
package.json:run the update-schema script:
install GraphQL Codegen CLI
run it:
npx graphql-codegen init Welcome to GraphQL Code Generator! Answer few questions and we will setup everything for you. ? What type of application are you building? Application built with Angular ? Where is your schema?: (path or url) schema.graphql ? Where are your operations and fragments?: src/**/*.graphql ? Pick plugins: TypeScript (required by other typescript plugins), TypeScript Operations (operations and fragments), Ty peScript Apollo Angular (typed GQL services) ? Where to write the output: src/generated/types.graphql-gen.ts ? Do you want to generate an introspection file? No ? How to name the config file? codegen.yml ? What script in package.json should run the codegen? gql:codegenadd an ignore line to
.gitignoreinstall a npm app that lets us run more than one watch script
create a GraphQL file and put it in the
src/appfoldermodify the
src/app/app.component.tsfile to create a "testing page":command line