-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New rule: force Relay schema structure #27
Comments
This is very tricky to implement, since there isn't a good way to figure out if returned type is supposed to be paginated. This will ether have to be done through naming conventions (inconvenient for the end user), or check return type for arrays and assume that any array should be paginated (probably an overkill). |
Reopening, just because I think we can implement some aspects of this. @B2o5T what do you think about the following:
|
My top reasonsSharing some thoughts for why I think an ESLint can drive value. Top reasons include
I would love to chat more about this. As some of my later thoughts show, this rests at the forefront of my schema design right now. Other comments
The GraphQL Cursor Connections Specification requires these naming conventions. So, if we promote the rule as explicitly for this spec, I think the naming convention concern disappears.
Yeah, I do not know how we find the exact pagination fields. Maybe we look for fields that have conforming Arguments. I do not have context about how the ESLint plugin works w.r.t. analyzing the GQL AST.
First, I think this stems from the Global Object Identification spec, but +1 to having this. More contextI set out to implement cursor based pagination with schema-driven interfaces. Roughly, interface Connection {
edges: [Edge]
pageInfo: PageInfo!
}
interface Edge {
node: Node
cursor: Cursor
}
scalar Cursor
type PageInfo { ... } Then I would implement the interface with a specific connection. extend Query {
foos(first: NonNegativeInt, after: Cursor): FooConnection
}
type FooConnection implements Connection {
edges: [FooEdge] # Works fine
pageInfo: PageInfo!
}
type FooEdge implements Edge {
node: FooResult # Works with `Foo`, but not `FooResult`
cursor: Cursor
}
type Foo { ... }
union FooResult = Foo | ... However, the So, I had two options: (1) Remove |
@connorjs @domkm I have implemented 3 new rules according to Relay spec for validating Connection types, Edge types and Also for validation Edge types, I added 3 configurable options that don’t strict in Relay spec:
Before these rules will be merged I need feedback, can you test it on your schemas? You can try an alpha version Docs: Also, you can extend |
TL;DR - Can we (a) add @B2o5T - Do we need to add the plugin ( I have added the rules directly in the mean-time. 👍🏻 My feedback follows.
|
@connorjs Thank you for your feedback 😍💪
Exactly, this was my mistake, now this should be fine as I added also a test to test that the
I think we can support by default a non-null String/Scalar for
For your particular case if you still want to use
UPDATE:Added 4th rule and last for relay spec |
Available in @graphql-eslint/eslint-plugin@3.10.0 |
Related: https://relay.dev/docs/en/graphql-server-specification.html#schema
The text was updated successfully, but these errors were encountered: