graphql-schema-linter
graphql-schema-linter copied to clipboard
Interfaces cannot end with `Connection`
I'm trying to create an interface that specifies what a Connection
must implement. However, the rule relay-connection-types-spec
prevents this from happening. The following schema seems perfectly valid to me. I would prefer to rely on my schema for ensuring my type
s that do end in Connection
be dependent on an interface rather than a linter. Could you enable the lint the a Connection
interface
such that it follows the relay spec?
Thanks for your work on this project.
interface Edge {
cursor: String!
node: Node!
}
interface Connection {
totalCount: Int!
pageInfo: PageInfo!
edges: [Edge!]!
}
Hey @landau! Thanks for opening the issue. 😄
Just for clarity, are you saying the relay-connection-types-spec
rule is preventing you from defining interface Connection
or are there more issues? Will your connection types still end in Connection
?
The rules implemented in relay-connection-types-spec
follow what's written in the spec including:
Any type whose name ends in “Connection” is considered by Relay to be a Connection Type. Connection types must be an “Object” as defined in the “Type System” section of the GraphQL Specification.
As part of #18, I'm looking into providing a way for people to disable certain rules for specific parts of their schema a bit like what ESLint provides:
# lint-disable relay-connection-types-spec
interface Connection {
totalCount: Int!
pageInfo: PageInfo!
edges: [Edge!]!
}
# lint-enable relay-connection-types-spec
Let me know if this would help.
Just for clarity, are you saying the relay-connection-types-spec rule is preventing you from defining interface Connection or are there more issues? Will your connection types still end in Connection?
Just the former. I can't define the interface Connection
or relay-connection-types-spec
complains.
As part of #18, I'm looking into providing a way for people to disable certain rules for specific parts of their schema a bit like what ESLint provides:
Disabling the rule would work, but it seems to me that an interface
, which is an abstract object would, should be able to define what a type of Connection
must implement. I imagine that Relay
itself wouldn't have a problem with types implementing a Connection
.
Thanks for your time. :)
I had never thought of having an interface called Connection
. That's a really interesting idea.
When implementing relay-connection-types-spec
I followed the Relay spec to the letter. That said, I wouldn't mind making an exception for interface Connection { ... }
if it doesn't cause issues with Relay.
If you'd like to open a PR for this I'd be happy to review it.
You'll want to modify: https://github.com/cjoudrey/graphql-schema-linter/blob/master/src/rules/relay_connection_types_spec.js and https://github.com/cjoudrey/graphql-schema-linter/blob/master/test/rules/relay_connection_types_spec.js.
I appreciate the openness. I'll take a stab at the implementation, probably, tomorrow.