Skip to content

fetching schema with http without explicitly specifying method causes unexpected 'No GraphQL schema.' error #112

@f4z3k4s

Description

@f4z3k4s

Describe the bug
Not explicitly defining "method": "POST" in tsconfig.json causes npx ts-graphql-plugin validate --verbose to fail. On top of that, it fails with a wrong error message so it took me a good half hour to figure out. It fails with the following error message:

error: No GraphQL schema. Confirm your ts-graphql-plugin's "schema" configuration at tsconfig.json's compilerOptions.plugins section.

To Reproduce
Use schema over http without explicitly specifying method, like:

"plugins": [
      {
        "name": "ts-graphql-plugin",
        "schema": {
          "http": {
            "url": "http://xy.com/graphql", // whatever your graphql endpoint is
            // "method": "POST"  // do not specify it explicitly and it will fail
          }
        },
        "tag": "gql"
      }
    ]

Expected behavior
I've read in the documentation that one can omit "method": "POST" from tsconfig.json since that is the default. If that is not explicitly written in config, plugin silently fails, even with verbose flag. Either the documentation could be updated (willing to do a PR if needed) and error message could be updated, or it should be fixed in the package to fallback to POST even if not explicitly defined.

PS: great plugin and keep it going, thanks for your work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions