Skip to content

UserPermissionPlugin require id instead of documentId for mutations on relational fields #22799

@robinNavas

Description

@robinNavas

Node Version

v21.7.3

NPM/Yarn/PNPM Version

10.5.0

Strapi Version

5.6.0

Operating System

Windows 11

Database

MySQL

Javascript or Typescript

Typescript

Reproduction URL

No response

Bug Description

When I try to perform a mutation of an user using the userPermissionPlugin like :

mutation UpdateUsersPermissionsUser($updateUsersPermissionsUserId: ID!, $data: UsersPermissionsUserInput!) {
  updateUsersPermissionsUser(id: $updateUsersPermissionsUserId, data: $data) {
    data {
      confirmed
      username
    }
  }
}

with these variables it doesn't work, I get a not found error:

{  
  "updateUsersPermissionsUserId": documentID-OfAnUser, // e.g. "g1234o33xzjghhz9obw0brhy"
  "data": {
    "relation": [documentID-OfAnEntryOfTheRelationalField],  // e.g. "g1234o33xzjghqssdbw0brhy"
  }
}

but with these it does

{  
  "updateUsersPermissionsUserId": ID-OfAnUser,  // e.g. 1
  "data": {
    "relation": [ID-OfAnEntryOfTheRelationalField], // e.g. 3
  }
}

The problem is that I can't get the id of the relational field entry with graphQL as only the documentId is exposed via the api.

Steps to Reproduce

  1. Create a User role
  2. Create a Collection type - for example "allergies"
  3. Add a relational field between the two, user has many allergies
  4. Add some entries to the allergies collection type
  5. Try to add new entries to the user relational field via graphQL

Expected Behavior

I expect the graphql mutation to work with documentsIds

Logs

{
  "errors": [
    {
      "message": "Internal Server Error",
      "extensions": {
        "error": {
          "name": "NotFoundError",
          "message": "User not found",
          "details": {}
        },
        "code": "INTERNAL_SERVER_ERROR"
      }
    }
  ],
  "data": null
}

Code Snippets

No response

Media

No response

Additional information

No response

Confirmation Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions