apollographql / apollographql/federation

Enum value is not resolved correctly on buildFederatedSchema

Open
#363 0 comments 16 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
725
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

Getting the following error when trying to build the federation schema using `buildFederatedSchema` - It seems that when defining default values for an input enum type property and the enum resolver has different values than keys, it doesn't recognize the default enum value: `Enum "TestEnum" cannot represent value: "A"`.

**Example:**

```
import { gql } from "apollo-server";

import { buildFederatedSchema } from "@apollo/federation";

const typeDefs = gql`
enum TestEnum {
A
}

input TestInput {
prop: TestEnum = A
}
`;

buildFederatedSchema({
typeDefs,
resolvers: {
TestEnum: {
A: "another_value_than_A",
},
},
});
```

**Packages:**

0.16.0 - @apollo/federation
2.13.1 - apollo-server
15.0.0 - graphql

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported failure through buildFederatedSchema with the provided TestEnum, TestInput, and resolver values. Trace how the federation schema handles the default enum value, then verify that the example builds successfully and that the existing enum behavior remains covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.