Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

getEnumDefinitions with rare "%future added value" #81

Closed
artola opened this issue Jan 2, 2019 · 6 comments
Closed

getEnumDefinitions with rare "%future added value" #81

artola opened this issue Jan 2, 2019 · 6 comments

Comments

@artola
Copy link
Contributor

artola commented Jan 2, 2019

For example, using github graphql schema.graphql:

"""The possible states of an issue."""
enum IssueState {
  """An issue that is still open"""
  OPEN

  """An issue that has been closed"""
  CLOSED
}

It is generated in the following type, containing an extra and rare "%future added value".

export type IssueState = "CLOSED" | "OPEN" | "%future added value";

Source code:

values.push("%future added value");

Has this extra entry in the alias some especial meaning? It seems error prone.

@sibelius
Copy link
Contributor

sibelius commented Jan 2, 2019

This is to be type safe for future enum values

you could add more enum types for your graphql schema and it won't break old apps

@alloy
Copy link
Member

alloy commented Jan 2, 2019

For more info see eg this upstream issue facebook/relay#2351

@alloy alloy closed this as completed Jan 2, 2019
@artola
Copy link
Contributor Author

artola commented Jan 2, 2019

@sibelius @alloy thanks for your prompt reply. From my point of view, a type system makes sense when you enforce it, and this kind of entry is not needed as stated in the upstream issue.
Anyway, see the code introduced in the upstream where is possible to use the flag noFutureProofEnums to avoid them.

https://github.com/facebook/relay/blob/f54557df14f992ce175153913736eed3e2419d7c/packages/relay-compiler/language/javascript/RelayFlowGenerator.js#L535

@alloy
Copy link
Member

alloy commented Jan 2, 2019

Yup, that simply wasn’t ported over yet because we don’t use that option. A issue for this exists #80

@artola
Copy link
Contributor Author

artola commented Jan 2, 2019

@alloy Sorry I did not see #80 ... absolutely same.

@alloy
Copy link
Member

alloy commented Jan 2, 2019

No worries!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants