graphql-codegen fails to load schema against docker based api

113 Views Asked by At

when running the graphql-codegen command from visual studio code against a dockerized api service. The command cannot connect to the live running server.

codegen.yml file

overwrite: true
watch: false
schema: "https://localhost:5237/graphql"
documents: "**/*.{gql,graphql}"
generates:
  src/graphql/generated/schema.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-react-apollo"

Postman and a direct link to the browser can return the result from a query or view the schema definition in a typical viewer such as bananacakepop.

If I disable the graphql-codegen command and just run yarn start and use the react ui to query against the same still running docker containerized graphql server then it works.

Below is the error from graphql-codegen

❯ Generate to src/graphql/generated/schema.ts

✖
        Failed to load schema from https://localhost:5237/graphql:

        fetch failed to https://localhost:5237/graphql
        TypeError: fetch failed
  …
◼ Load GraphQL documents
◼ Generate

Does the codegen.yml file require more arguments to work with a docker container? I have tried with and without the api service having authorization required and this did not work either. app.UseAuthorization();

0

There are 0 best solutions below