apollo-server: Apollo Federation - Duplicate scalar in multiple services
-
I run into an error when using a scalar like
DateTime
in two different microservices, and merging them together with Apollo Federation. Here is a snippet of the error being thrownUnhandledPromiseRejectionWarning: GraphQLSchemaValidationError: There can be only one type named "DateTime".
-
Apollo Federation
-
UnhandledPromiseRejectionWarning: GraphQLSchemaValidationError: There can be only one type named "DateTime"..
Microservice Foo
export const typeDefsFoo: DocumentNode = gql`
scalar DateTime
extend type Query {
foo(id: ID!): Sensor!
}
type Foo {
time: DateTime!
}
Microservice Bar
export const typeDefsBar: DocumentNode = gql`
scalar DateTime
extend type Query {
bar(id: ID!): Bar!
}
type Bar {
time: DateTime!
}
`;
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 17 (5 by maintainers)
@byrnedo This should be available now in
@apollo/federation@0.6.4
.@apollo/gateway@0.6.7
should be published in the next couple hours with this@Pruxis I’m not aware of a workaround, but I hope to be wrapping up work on this today, so this should work soon. Sorry for the trouble. If anyone else here has a workaround, feel free to share!
I’m also having the same problem. We’ve structure our stuff a little differently, so wanted to add it for extra investigative input
Microservice Alpha
Schema/types.graphql
Schema/index.js
Microservice Beta
UuidV4 is a valid scalar on both microservices, they run as expected on their own. When we join them with federation, we get the same duplicate error. If we change them both to
String!
, it runs fine. We also had the same problem with other custom scalars.