[Flow] Too restrictive type on optional fields in mutation responses
See original GitHub issueDescribe the bug Consider following schema:
schema {
mutation: Mutation
}
type MutationResponse {
success: Boolean
errors: [String!]
}
type Mutation {
update(id: ID!): MutationResponse
}
and obviously config
generates:
demo.js:
- flow
generated type will be
export type MutationResponse = {
success: ?boolean
errors: ?Array<string>
}
which means I always need to return success
and errors
field even if they are null/undefined. All known graphql server implementations tolerate that, so I believe it should be:
export type MutationResponse = {
success?: ?boolean
errors?: ?Array<string>
}
which allows not to have field in response.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Designing GraphQL Mutations
This is useful for schemas where you want to order the mutations alphabetically (the Ruby GraphQL gem always orders fields alphabetically) and ...
Read more >GraphQL API style guide - GitLab Docs
Non-nullable fields should only be used when a field is required, very unlikely to become optional in the future, and very easy to...
Read more >Code Smells: Mutation | The IntelliJ IDEA Blog
This is part of a series investigating code that looks suspicious (“code smells”), and exploring possible alternatives.
Read more >A mutation-based gene set predicts survival benefit after ...
In this study, we established a comprehensive mutation-based gene set across different tumor types to predict the efficacy of ICI therapy.
Read more >Api graphql styleguide · Development · Help · GitLab
Non-nullable fields should only be used when a field is required, very unlikely to become optional in the future, and very easy to...
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 FreeTop 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
Top GitHub Comments
@adelsz sorry, you’re perfectly right. Let’s say:
foo?: ?string
sounds better and matches specFixed in 0.16.0. Thanks @xanf