graphql / graphql/graphql-spec
GraphQL Mutation how to make fields optional to update fields only by selection and generate schema
- Dominant language
- JavaScript
- Stars
- 14.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
I have a graphql mutation defined as follows
```
updateParts(
partId: String!
parts: PartRequest!
): UpdatePartsResponse!
input PartRequest {
name: String!
image: Strings!
boltTypes: [Bolts]!
}
input Bolts {
code: String!
metadata: String!
}
```
and the requirement was to update fields upon selection like
* update all
```
mutation {
updateParts(
partId: "0x1223"
parts: {
name: "some"
image: "dark.png"
boltTypes: [
{ code: "A", metadata: "B" }
]
}
)
}
}
```
* Update by selection name only
```
mutation {
updateParts(
partId: "0x1223"
parts: {
name: "some"
}
)
}
}
```
Update by selection , parts only
```
mutation {
updateParts(
partId: "0x1223"
parts: {
boltTypes: [
{ code: "A", metadata: "B" }
]
}
)
}
}
```
How to construct a schema to achieve this ?
Contributor guide
Assessment
This issue has not been assessed yet.