apollographql / apollographql/federation

Interfaces implementing interfaces

Open
#227 2 comments 6 reactions 0 assignees View on GitHub
:beetle: bug
Dominant language
TypeScript
Stars
725
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

# Interface implements Interface of Graphql 15 syntax is not working

We found this issue when trying to implement our type system into graphql. We've got a big set types inheriting properties from common ancestors and all of the ancestors need a common interface so they can be queried.

## Expected Behavior
Creating multi inheritance interfaces are working as described in the Graphql spec.

## Actual Behavior
When trying to create an interface that implements an interface `buildFederatedSchema` fails with the error
"Error: Schema must contain uniquely named types but contains multiple types named XXX".

## Affected version
- npm: "@apollo/federation": "^0.20.4"

## Minimal runnable reproduction
The following type definition fails when creating the federated schema. "Error: Schema must contain uniquely named types but contains multiple types named A"
```
const { buildFederatedSchema } = require('@apollo/federation')
const { gql } = require('apollo-server-express')

const typeDefs = gql`
interface A { text: String }
interface B implements A { text: String number: Int}
`

const resolvers = {}

buildFederatedSchema([{ typeDefs, resolvers }])
```

A repository show casing the issue can be found here:
https://github.com/MerzDaniel/apollo-federation-if-impl-if
Just run `npm i && npm start`

## PR introducing the feature
https://github.com/apollographql/federation/pull/30

Contributor guide

Open the contributing guide

Research direction

Run the minimal reproduction with `buildFederatedSchema` and inspect the federation code path that builds the schema from the shown interface definitions. Compare the behavior with the linked PR introducing the feature and the GraphQL interface implementation expectation; done means the example builds without duplicate type errors and preserves the stated interface relationships.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.