Example for recursive object creation / reference fields
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- graphql, php
- Domain
- api, backend, documentation
Research direction
Start by reviewing the linked graphql README and example repositories, then compare their mutation and nested-reference documentation with the requested A/B schema. Document a concrete recursive creation example showing the input, mutation, and returned distinct Drupal objects; verify that the example covers both nested fields and created IDs.
Written by the indexing model from the issue text.
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:
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 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
- Dominant language
- PHP
- Stars
- 12
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from drupal-graphql/graphql-examples
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
All issues in drupal-graphql/graphql-examples
Similar issues
-
FrameworkBundle SecurityBundle
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
symfony/symfony-docs#23277 ·
Maintainers usually reply within 3 days
-
[Sync EN] hard link does not need special permissionsPossibly taken @lacatoire claimed this today. Opensync-en
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 76/100
Maintainers usually reply within 4 days
-
bug mod:appointments
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
3pontos-tech/gil-benefits#303 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day