I have a problem regarding GraphQL Schema stitching. I have two Graphql Schemas:
type Name {
firstname: String!
lastname: String!
}
type Address {
street: String!
number: Int!
}
type User {
name: Name!
address: Address!
}
type Query {
user(userId: String!): User
}
and
type User {
age: String!
}
type Query {
user(userId: String!): User
}
I now tried to merge the schemas using graphql-tools's mergeSchemas
Function:
const schema = mergeSchemas({
schemas: [schema1, schema2]
});
But instead of what I'm trying to achieve (an extended User Type):
type Name {
firstname: String!
lastname: String!
}
type Address {
street: String!
number: Int!
}
type User {
name: Name!
address: Address!
age: String!
}
type Query {
user(userId: String!): User
}
it resulted in this: type Name { firstname: String! lastname: String! }
type Address {
street: String!
number: Int!
}
type User {
name: Name!
address: Address!
}
type Query {
user(userId: String!): User
}
Only one of the UserTypes is displayed in the final schema.
I tried using the onTypeConflict
API in mergeSchemas
to extend the Type but I haven't made any results.
Is there a way to merge Schemas by extending Types on Conflict?
type User
toextend type User
. I fetch them usingmakeRemoteExecutableSchema
– Nicolai Schmid