Skip to content

GraphqQl does not allow input embedded relation #3694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BernardA opened this issue Aug 29, 2020 · 1 comment
Closed

GraphqQl does not allow input embedded relation #3694

BernardA opened this issue Aug 29, 2020 · 1 comment

Comments

@BernardA
Copy link

API Platform version(s) affected: "api-platform/api-pack": "^1.2",

Description
Fetching contacts from GooglePeopleApi and attempting to adding them to existing user.

Google provides an array of contacts.

I am following this comment from @dunglas #1645 (comment), and setting up a relation that share the same groups on the denormalization context for the operation updateUser.

I was expecting to be able to have the full Contact entity as an input to updateUser, but graphiql will only expect an array of strings, ie, contacts: [String] ( see screenshot below)

How to reproduce
( only relevant code )
The USER entity :

    *          "update"={
    *              "security"="(is_granted('IS_AUTHENTICATED_FULLY') and object == user) or is_granted('ROLE_ADMIN')",
    *              "denormalization_context"={
    *                  "groups"={"put-profile-change", "put-contacts", "put"}
    *              },
    *              "validation_groups"={"put-profile-change"}
    *          },

   .....

 /**
  * @ORM\OneToMany(targetEntity="App\Entity\Contact", mappedBy="user")
  * @Groups({"put", "put-contacts", "get-admin", "get-owner"})
  */
 private $contacts;

The CONTACT entity:

 *          "create"={
 *              "security"="is_granted('IS_AUTHENTICATED_FULLY')",
 *              "denormalization_context"={"groups"={"post", "put", "put-contacts"}},
 *              "normalization_context"={"groups"={"get-owner", "get-admin"}},
 *          },
 *          "update"={
 *              "security"="(is_granted('IS_AUTHENTICATED_FULLY') and object == user) or is_granted('ROLE_ADMIN')",
 *              "denormalization_context"={
 *                  "groups"={"put-contacts", "put"}
 *              },
 *          },

 ....


/**
 * @ORM\Id()
 * @ORM\GeneratedValue()
 * @ORM\Column(type="integer")
 * @Groups({"put", "put-contacts", "get-admin", "get-owner"})
 */
private $id;

/**
 * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="contacts")
 * @Groups({"post", "put", "put-contacts", "get-admin", "get-owner"})
 */
private $user;

/**
 * @ORM\Column(type="string", length=180)
 * @Groups({"post", "put", "put-contacts", "get-admin", "get-owner"})
 */
private $email;

Possible Solution

Additional Context
Update user input:
Screenshot 2020-08-29 at 12 33 12

@alanpoulain
Copy link
Member

Please see this comment: #3258 (comment).

Closing this issue in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants