js-graphql-intellij-plugin icon indicating copy to clipboard operation
js-graphql-intellij-plugin copied to clipboard

Unknown field "x" on object type "Query". Did you mean "x"?

Open Handiwork opened this issue 5 years ago • 3 comments
trafficstars

Before you create the issue

  • Please search the existing issues at https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues?q=sort%3Aupdated-desc before opening a new issue.
  • Read the FAQ at https://github.com/jimkyndemeyer/js-graphql-intellij-plugin#faq
  • If you're using an EAP, try with a stable version. If that works, please mention it in the issue along with both versions.

Version and Environment Details

Operation system: Windows 10 1909

IDE name and version: IntelliJ IDEA 2019.3 (Ultimate Edition) Build #IU-193.5233.102, built on November 28, 2019

Plugin version: 2.3.0

Expected Behaviour

No Errors

Actual Behaviour

Red Words

Steps to Reproduce / Link to Repo with Reproduction and Instructions

schema.json schema.zip

error

Handiwork avatar Dec 23 '19 15:12 Handiwork

Hi,

Thanks for using the plugin.

JSON files are not automatically included in schema discovery as they may contain non-graphql content.

You have to set your schemaPath to your schema.json file in a .graphqlconfig file. The quickest way to create the config file is right click, "New", "GraphQL Configuration File" in your project root. Then update the schemaPath.

The plugin should then pick up your Query type and the fields should not longer be shown as unresolved/red.

If you're doing introspection to fetch the schema from an endpoint, I recommend you follow the setup in https://github.com/jimkyndemeyer/graphql-config-examples/tree/master/remote-schema-introspection as this performs better in the plugin than using a JSON file.

jimkyndemeyer avatar Dec 28 '19 18:12 jimkyndemeyer

Thanks.

I tried to fetch the schema with this plugin and the new file works well.

The schema.json file I've attached above was generated by apollo client, and one difference between two file as I observed is, that the new file wraps "__schema" with "data" while in my old file the "__schema" is a top field.

But I'm still confused of the advice when I using my old file. did you mean did you mean 2 Since it looks ok in this pane. ok

Handiwork avatar Dec 29 '19 02:12 Handiwork

I can confirm that using "schemaPath": "schema.json" (and then fetching the schema) will not work but using "schemaPath": "schema.graphql" (and re-fetching the schema) does work, with the GitHub api.

However if I just remove the "data" in the schema.json such that the "__schema" becomes top level that doesn't solve anything, so there must be a different problem still in the json file.

I see no reason for me to want the json, but a little bit confusing it is.

PHPirates avatar Jan 16 '20 17:01 PHPirates