Graphql Apollo angular code gen with Authorization

Hi all,
just if someone struggles with the codegen config file for generation typescript types for the angular client:



.graphqlrc.yml:

overwrite: true
schema: "http://localhost:5000/api/content/{YOUR_APP}/graphql"
headers:
    Authorization: "Bearer {YOUR TOKEN}"
documents: "src/**/*.graphql"
generates:
  src/generated/graphql.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-apollo-angular"
  ./graphql.schema.json:
    plugins:
      - "introspection"

Cheers Mirko

package.json:

  "dependencies": {
    "@angular/animations": "~9.1.0",
    "@angular/cdk": "^8.0.0",
    "@angular/common": "~9.1.0",
    "@angular/compiler": "~9.1.0",
    "@angular/core": "~9.1.0",
    "@angular/forms": "~9.1.0",
    "@angular/platform-browser": "~9.1.0",
    "@angular/platform-browser-dynamic": "~9.1.0",
    "@angular/router": "~9.1.0",
    "@graphql-codegen/introspection": "^1.13.2",
    "@graphql-codegen/schema-ast": "^1.13.2",
    "@graphql-codegen/typescript-apollo-angular": "^1.13.2",
    "@test-graphql-cli/codegen": "^4.0.1-beta.3",
    "apollo-angular": "^1.8.0",
    "apollo-angular-link-http": "^1.9.0",
    "apollo-cache-inmemory": "^1.6.0",
    "apollo-client": "^2.6.0",
    "apollo-link": "^1.2.13",
    "devextreme": "19.2.7",
    "devextreme-angular": "19.2.7",
    "devextreme-schematics": "^1.1.12",
    "graphql": "^14.5.0",
    "graphql-tag": "^2.10.0",
    "rxjs": "^6.5.5",
    "tslib": "^1.10.0",
    "watchman": "^1.0.0",
    "zone.js": "~0.10.2"
  },
1 Like