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

GraphQL SDL and FlowType descrepencies #41

Open
mikestaub opened this issue Mar 26, 2018 · 2 comments
Open

GraphQL SDL and FlowType descrepencies #41

mikestaub opened this issue Mar 26, 2018 · 2 comments

Comments

@mikestaub
Copy link

FlowType allows 3 cases of optional fields and nullable types as explained here:
https://stackoverflow.com/questions/37165601/flowtype-how-to-annotate-union-with-optional-fields/37174244#37174244

When a user marks a GraphQL field as NonNull, the current code assumes the 3rd case, which is incorrect. It should assume the 2nd as the GraphQL spec does not allow the 3rd case.
https://github.com/joarwilk/gql2flow/blob/master/util/interface.js#L104

@mikestaub
Copy link
Author

I see now this was previously discussed: #12

This makes sense to me but the issue still applies to input types. For example this graphql definition:

input CreateUserInput {
  name: String!
  role: String
}

Will generate this FlowType:

declare type CreateUserInput = {
  name: string;
  role?: ?string;
}

Which is too lax. It should be:

declare type CreateUserInput = {
  name: string;
  role?: string;
}

@mikestaub
Copy link
Author

mikestaub commented Mar 27, 2018

My proposed solution: mikestaub@159facd

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

No branches or pull requests

1 participant