Closed Vishwaas closed 18 hours ago
One more observation.
With the below interfaces:
interface INode {
id: ID!
}
interface UserIFields implements INode {
id: ID!
name: string
age: number
}
The below does not work
type User implements UserIFields {
location: Location
}
but the below works:
type User implements UserIFields & INode {
location: Location
}
Hi @Vishwaas , Interfaces cannot implement other interfaces in a nested way you describe (Related SO answer)
However, you can implement multiple interfaces with a type (Related SO answer)
interface INode {
id: ID!
}
interface UserIFields {
name: String
age: Int
}
type User implements INode & UserIFields {
id: ID!
name: String
age: Int
}
If you look at the accepted answer, it appears the latest graphql spec allows interfaces implementing other interfaces right? https://stackoverflow.com/questions/57888591/interface-extends-multiple-interfaces-in-graphql-schema
Hi @Vishwaas 👋 You are right, it is allowed as of the latest GraphQL version.
I'm unable to see the issue you are reporting after running it through a CodeSandbox though. Here's the schema I had to update:
type Query {
node(id: ID!): INode
}
interface INode {
id: ID!
}
interface UserIFields implements INode {
id: ID!
name: String # Note: Updated from `string` to `String` from the issue
age: Int # Note: Updated from `number` to `Int` from the issue
}
type User implements INode & UserIFields { # Note: Added INode here because both interfaces need to be here, otherwise it schema validation fails
# Note: All the fields in the INode and UserIFields are needed to be here, otherwise schema validation fails.
id: ID!
name: String
age: Int
}
And here's the generated types:
Note that the generated interface type UserIFields
does not add its implementing type (INode
) since all the fields are already generated.
You can check out this CodeSandbox to have a play.
Closing this since it seems to work fine in tests. Please let me know if it's still an issue and I'll re-open
Describe the bug Lets say the schema had something like below:
now I wanted to split it up as below:
This results in an unexpected types.generated.ts being generated. UserIFields ends up as
and not
Eg:
To Reproduce Steps to reproduce the behavior: _1.Setup a schema as above
Expected behavior
Versions