question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apollo Federation - Duplicate scalar in multiple services

See original GitHub issue
  • 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 thrown UnhandledPromiseRejectionWarning: 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!
  }
`;

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:17
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
JakeDawkinscommented, Jun 18, 2019

@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

3reactions
JakeDawkinscommented, Jun 12, 2019

@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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Value types in Apollo Federation - Apollo GraphQL Docs
This article describes how to share value types and their fields in federated graph, enabling multiple subgraphs to define and resolve them. Sharing...
Read more >
Federated schema design best practices - Apollo GraphQL Docs
The majority of best practices that apply to non-federated GraphQL schema design also apply when designing service schemas within a federated graph.
Read more >
Apollo Federation subgraph specification
This scalar is serialized as a generic JSON object, which enables the graph router to include representations of different entities in the same...
Read more >
Custom scalars - Apollo GraphQL Docs
The GraphQL specification includes default scalar types Int , Float , String ... Copy. You can now use MyCustomScalar in your schema anywhere...
Read more >
Value types - Apollo GraphQL Docs
Define the exact same type in multiple services · Scalars · Objects · Interfaces · Inputs · Enums · Unions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found