cjoudrey / graphql-schema-linter

Validate GraphQL schema definitions against a set of rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not support interfaces implementing other interfaces

moberegger opened this issue · comments

The latest version of the spec allows you to have an interface extend another interface. This feature was also added to version 15 of graphql.

The example provided in the spec would allow you to do something like

interface Node {
  id: ID!
}

interface Resource implements Node {
  id: ID!
  url: String
}

interface Image implements Resource & Node {
  id: ID!
  url: String
  thumbnail: String
}

If you were to run the linter on a schema containing this, you will receive an error:

SyntaxError: Syntax Error: Unexpected Name "implements"

Perhaps of note is that this project upgraded to V15 not too long ago, but I suppose the linting of this new feature wasn't something that came along for free with the upgrade.

Hey @moberegger! Thanks for opening this issue. 😄

Out of curiosity, what version of graphql-schema-linter are you using?

I'm asking because this should be supported by > v0.3.0.

Hmmm... I made sure to upgrade to the latest version (0.4.0), but maybe I goofed. I can follow up with you next week if you don't mind waiting a bit.

No worries at all!

So the project I am seeing this happen in is definitely using version 0.4.0.

graphql-schema-linter --version
0.4.0

I tried making a smaller repo to show the issue, but can't actually reproduce it. No idea what's going on. Only differences that are obvious to me:

  • The project it doesn't work in has a config file with some rules disabled (nothing that looks like it would disable an "interfaces can extend other interfaces" rule, though)
  • The project it doesn't work in uses the lint-staged setup (it's on the git commit I see the issue)
  • The project it doesn't work in has the schema spread over multiple files

I'm trying to make a repo with just a single .graphql file, but can't reproduce. Unfortunately, I can't share the project with the issue.

I'll keep trying, but it looks like the problem is unique to us right now :(

same issue like @moberegger , need to downgrade graphql lib

e.g
type Tag implements Node , Deletable ==> error

type Tag implements Node & Deletable ==> ok !

downgrade graphql 15-> "graphql": "^14.6.0",
"graphql-schema-linter": "^0.4.0",


next step , after linting in createServerApollo ( ts )
const parseOptions: GraphQLParseOptions = { allowLegacySDLImplementsInterfaces: true };
const schema = makeExecutableSchema({ typeDefs, resolvers, ,parseOptions});

@engiwip We're having different issues. I have no issues linting something like type Tag implements Node & Deletable, just having issues with interface Resource implements Node. The former works for me on graphql@15 and graphql-schema-linter@0.4.

I am not confident my problem is an issue with this project. I have been trying to isolate it but haven't been able to reproduce it outside of my one project (which I cannot share).

If I can't figure anything out, I'll close this issue at the end of the week.... unless you have any ideas/leads about something I could look at @cjoudrey?🤞 I don't want to take up your time looking into a problem that might not even exist.

@engiwip you should be able to use the --old-implements-syntax option to support the old implements syntax. If that doesn't work, feel free to open a new issue. This isn't the same issue as @moberegger is describing.

If I can't figure anything out, I'll close this issue at the end of the week.... unless you have any ideas/leads about something I could look at @cjoudrey?🤞 I don't want to take up your time looking into a problem that might not even exist.

The only thing I can think of is a dependency issue happening in your project that would cause you to be running an older version of graphql-schema-linter or an older version of graphql-js.

Gonna close this because I can't reproduce it and don't want to blame this project for the issue I am having. If I figure out more details, I will reopen with a proper repro.

For anyone seeing this in the future with the same problem, the root cause of the issue for us was actually prettier! Bumping from 2.0.2 to 2.0.5 resolved our problem.

Prettier actually has a dependency on graphql which I had no idea about. Looks like it was using an older version which got bumped in one of the patches.