graphql-stitching-ruby
graphql-stitching-ruby copied to clipboard
Support foreign key → relation transform
GraphQL foreign keys are commonly handled as Product.imageId is here:
# -- Products schema:
type Product {
id: ID!
imageId: ID!
}
# -- Images schema:
type Image {
id: ID!
url: String!
}
However, stitching wants this schema to be shaped as:
# -- Products schema:
type Product {
id: ID!
image: Image!
}
type Image {
id: ID!
}
# -- Images schema:
type Image {
id: ID!
url: String!
}
Rather than forcing services to be reshaped (assuming we even have ownership and are able to), it would be nice if stitching would handle the transformation of key fields into typed relations, such as:
# -- Products schema:
type Product {
id: ID!
imageId: ID! @relation(fieldName: "image", typeName: "Image", foreignKey: "id")
# --> image: Image! // type Image { id: ID! }
}
# -- Images schema:
type Image {
id: ID!
url: String!
}