Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to deprecate a union member? #256

Closed
vecerek opened this issue Oct 8, 2019 · 2 comments
Closed

Is it possible to deprecate a union member? #256

vecerek opened this issue Oct 8, 2019 · 2 comments
Labels
question Further information is requested

Comments

@vecerek
Copy link

vecerek commented Oct 8, 2019

Hello 👋
I would like to ask if it's currently possible to deprecate a member of a union similarly to deprecating a member of an enum? Suppose we have the following union:

const Event = unionType({
  name: "Event",
  definition(t) {
    t.members(
      EventA,
      EventB,
    );
    t.resolveType((item) => item["__typename"]);
  },
});

const EventA = objectType({
  name: "EventA",
  deprecation: "Replaced by EventB", // this doesn't work
  definition(t) {
    t.field("someField", { type: SomeType });
  },
});

const EventB = objectType({
  name: "EventB",
  definition(t) {
    t.boolean("someOtherField");
  },
});

With enums we could just do the following but not with unions as far as I know:

const MyEnum = enumType({
  name: "MyEnum",
  members: [
    { name: "EnumA", deprecation: "Replaced by EnumB" },
    "EnumB",
  ],
});
@tgriesser
Copy link
Member

It is not, but only because this is not supported by GraphQL / graphql-js. If this changes in the spec we will add this behavior to nexus, but at present it is out of scope for the library.

Related: graphql/graphql-spec#197 (comment)

@tgriesser tgriesser added the question Further information is requested label Nov 8, 2019
@tiago-loureiro
Copy link

Hi @tgriesser - going through the issues, it seems like it is now graphql/graphql-spec#525 - would it make sense to revisit it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants