drupal-graphql / drupal-graphql/graphql-examples
Example for recursive object creation / reference fields
- Dominant language
- PHP
- Stars
- 12
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Could you please provide an example for a mutation that recursively creates an object? On the Drupal side we expect the "A" bundle to contain a field referencing the "B" bundle.
Expected usage from the GraphQL side:
```graphql
type B {
z: String
}
type A {
b: B
}
input BInput {
z: String
}
input AInput {
b: BInput
}
mutation CreateA($a: AInput) {
createA(a: $a) {
id
b {
id
z
}
}
}
```
Note that `XXXInput` has the exact same structure and types as `XXX`.
With `$a = { b: { z: "example" } }` it should return `{ id: 1234, b: { id: 3456, z: "example" } }` (e.g.). In particular, A and B should be created as distinct Drupal nodes.
We already had a look at the following resources, but without finding examples for anything but the most simple cases:
* https://github.com/drupal-graphql/graphql/blob/8.x-3.x/README.md
* https://github.com/drupal-graphql/drupal-decoupled-app
* https://github.com/acquia-pso/decoupledkit-drupal
- [their documentation](https://decoupledkit-react.readthedocs.io/en/develop/drupal-contenttypes/#the-decoupled-kits-content-types) describes a case that appears similar to our use-case, but it also appears to be lacking any concrete examples or code
* https://github.com/pmelab/graphql-drupal-example
- More complex in nature, but lacks mutations
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.