graphql-inspector icon indicating copy to clipboard operation
graphql-inspector copied to clipboard

diff: Unable to find any GraphQL type definitions for the following pointers: file-without-graphql-extension

Open LastDragon-ru opened this issue 2 years ago • 5 comments

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • [ ] 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the Codegen and plugins version under package.json matches yours.

  • [ ] 2. A failing test has been provided
  • [ ] 3. A local solution has been provided
  • [ ] 4. A pull request is pending review

Describe the bug

The diff command fails if path doesn't have graphql extension

error Error: 
      Unable to find any GraphQL type definitions for the following pointers:

          - ./test-schema

To Reproduce Steps to reproduce the behavior:

  1. Create any schema
  2. Save it into test-schema
  3. graphql-inspector diff ./test-schema ./test-schema

Expected behavior

It should work

Environment:

  • OS: Ubuntu 20
  • @graphql-inspector/cli: ^3.4.0
  • graphql: ^16.6.0
  • NodeJS: v14.20.0

Additional context

LastDragon-ru avatar Oct 06 '22 06:10 LastDragon-ru

@LastDragon-ru Curious if you've found any workaround. I'm also stuck at this, and haven't found much online to resolve.

Even after an npm install graphql-cli and which graphql returning a command, I don't get this to run 🤔

er9781 avatar Jul 02 '23 03:07 er9781

@er9781 I think you just need to rename the file to add .graphql extension.

LastDragon-ru avatar Jul 02 '23 04:07 LastDragon-ru

Hm, I'd need to put together a minimal reproduction but I had two schemas with .graphql extension.

graphql-inspector diff ./schema-old.graphql ./schema.graphql

With error output

error Error:
      Unable to find any GraphQL type definitions for the following pointers:

          - ./schema-old.graphql

    at prepareResult (/Users/simon/co/acuity/hasura/node_modules/@graphql-tools/load/cjs/load-typedefs.js:95:15)
    at loadTypedefs (/Users/simon/co/acuity/hasura/node_modules/@graphql-tools/load/cjs/load-typedefs.js:44:20)
    at async loadSchema (/Users/simon/co/acuity/hasura/node_modules/@graphql-tools/load/cjs/schema.js:15:21)
    at async Object.handler (/Users/simon/co/acuity/hasura/node_modules/@graphql-inspector/diff-command/cjs/index.js:95:35)

Maybe I'm mis-understanding but I'd expect to be able to compare two introspection query results but maybe I need to combine something about collecting .graphql queries & mutations as well?

Maybe my issue is different and I should maybe open a separate issue (I poked at some code underneath but didn't get that far).

I will say for the issue you mention about extensions in particular, it doesn't surprise me the extension is needed given there's a bunch of different schema sources eg json, graphql, endpoints, git, and it'd be harder to differentiate without the extension? At a minimum an error could be provided though if it's not a recognized format?

er9781 avatar Jul 02 '23 13:07 er9781

Hi, were you able to fix this issue? I am getting the same error when trying out the cli commands locally.

sidarth164 avatar Mar 22 '24 15:03 sidarth164

The document path is expected to be in quotes. This is documented in validate command, but I think this also applies to other command, because I also have trouble to execute coverage without the quoted document path. Either the CLI should expect unquoted document path, or the docs should be updated for each command.

Make sure to wrap the document in quotes.

Looooong avatar May 31 '24 15:05 Looooong