api-platform / api-platform/core

Error: "Type with id \"createAuthorNestedInput\" is not present in the types container",

Abierto
#8,068 1 comentario 0 reacciones 0 asignados Ver en GitHub
GraphQL
Lenguaje dominante
PHP
Estrellas
2.6k
Forks
980
Merge medio
2 d 4 h
PR fusionados (30 d)
49

Descripción

**API Platform version(s) affected**: 3.0.9

**Description**
Graphql nested mutation throws error. I am following the docs about nested mutations https://api-platform.com/docs/main/core/graphql/#embedded-relation-input-creation-of-relation-in-mutation

The example **works** on my entities, but when I want to create a function for the mutation and pass the required types for my nested input as arguments, I get the graphql response:

`"Type with id \"createAuthorNestedInput\" is not present in the types container",`

The Book->Author Relation is a OneToMany relation:
#[ORM\OneToMany(mappedBy: 'book', targetEntity: Author::class, cascade: ['persist'])]
#[Groups(['book:create'])]
private Collection $authors;

My mutation looks like this:
`mutation createBook($title: String!, $authors: [createAuthorNestedInput!]!) {
createBook(input: {title: $title, authors: $authors}) {
book {
title
authors {
edges {
node {
name
}
}
}
}
}
}`

and my variables:
`{
"title": "test",
"authors": [
{
"name": "test"
}
]
}`

**How to reproduce**
You can clone this github:
https://github.com/Basti271/api-platform-bug-mutation

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.