[flow] enums with underscore produce an invalid object key
See original GitHub issueDescribe the bug
When you use _
as a value on a graphql enum, the flow plugin fails to generate a valid object definition for such enum. It creates an object with a missing key (take a look below for examples).
To Reproduce Use the following enum on a Graphql schema:
enum Gender {
M
F
_
}
- My GraphQL schema:
schema {
query: Query
mutation: Mutation
}
type Mutation {
# Pay schedules
addUser(input: addUserInput!): User
}
type Query {
node(id: ID!): Node
viewer: Viewer
}
interface Node {
id: ID!
}
type Viewer implements Node {
id: ID!
user(id: ID!): User!
}
input addUserInput {
name: String!
email: String!
}
type User {
id: ID!
username: String!
email: String!
}
enum Gender {
M
F
_
}```
2. My GraphQL operations:
I don't know what this is
```graphql
# Put your operations here
- My
codegen.yml
config file:
overwrite: true
schema: "schema.graphql"
documents:
- "./document.graphql"
- "./*.js"
generates:
generated/graphql.js:
plugins:
- "flow"
- "flow-operations"
./graphql.schema.json:
plugins:
- "introspection"
Expected behavior I expect it to use ‘_’ or at least ‘’ as property name, instead it is producing the following invalid JS object definition:
export const GenderValues = Object.freeze({
M: 'M',
F: 'F',
: '_'
});
Additional context
Reproduction: https://codesandbox.io/s/enumfailure-l7j7b?file=/document.js
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Using enums | Flow
Learn how to use Flow Enums, including their methods and exhaustive checking. ... like a string , to the enum type (if it...
Read more >How can I guarantee that my enums definition doesn't change ...
For each entry, create a new local variable whose name starts with ENUM_ or INDEX_ , then the name of the group, then...
Read more >Generator produces an invalid enum with an underscore "_ ...
Using the 3.14.1 code generator with Java on a MySQL database with an enum field defined as: `t_offset_o` enum('-','+') NOT NULL DEFAULT '+' ......
Read more >Introducing Flow Enums - Medium
const couldBeStatus: Status | void = Status.cast(someString);. Previously, you would have to create a switch statement with every enum member as ...
Read more >graphql-code-generator - Bountysource
[flow] enums with underscore produce an invalid object key $ 0. Created 1 year ago in dotansimha/graphql-code-generator with 6 comments. Describe the bug....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t think there is a real reason cc @dotansimha
No real reason, just because the configuration is generated from the plugins code, so it sits next to that.
I merged your PR and the new documentation page should be live in a few minutes. Thank you!