Skip to content
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

User relations are not loaded when querying /users/{id} endpoint #7197

Closed
rokasaitenta opened this issue Jul 27, 2020 · 0 comments · Fixed by #7204
Closed

User relations are not loaded when querying /users/{id} endpoint #7197

rokasaitenta opened this issue Jul 27, 2020 · 0 comments · Fixed by #7204
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@rokasaitenta
Copy link

Describe the bug
After I upgraded my Strapi project from 3.0.5 to 3.1.1, /users/{id} endpoint no longer populates the relational fields, i.e. my User model has a "has one" relation to some other collection and previously /users/{id} populated the relational field with all the data from the related item, but now only the item's id is returned. However, if I query /users?id=8 then the related fields are properly populated. All other collections seem to populate all the related fields properly.

Steps to reproduce the behavior

  1. In Strapi's admin panel create a "Test" collection with a field "title" of type "text".
  2. In Strapi's default Users collection add a new relational field with a name "test", a relation type "has one" and a related collection "Test".
  3. Create a new item in the "Test" collection.
  4. Create a user in "Users" collection and create a relation with the item created previously.
  5. Now try to query the /users/{id} endpoint with the id of the user created previously.

Expected behavior
I expect the API to return a User object with a "test" field populated like "{ id: 1, title: "asdf", ... }", like it was in version 3.0.5.

Current behavior
The API does not populate the "test" field and returns only the id of the related item.

System

  • Node.js version: 12
  • Strapi version: 3.1.1
  • Database: MySQL 8.0.21
  • Operating system: Official Strapi Docker image "strapi/strapi:3.1.1-node12"

Additional context
My Strapi project is running in Docker container with official Strapi image "strapi/strapi:3.1.1-node12". It was version "strapi/strapi:3.0.5-node12" but I updated it because I needed OR and AND operators in REST API queries. I also followed the migration guide https://strapi.io/documentation/v3.x/migration-guide/migration-guide-3.0.x-to-3.1.x.html.

juandl added a commit to juandl/strapi that referenced this issue Jul 27, 2020
To avoid issue with population we change the service of state user to there own service call "fetchState", also to keep a separate customization
juandl added a commit to juandl/strapi that referenced this issue Jul 27, 2020
To avoid issue with population we change the service of state user to there own service call "fetchState", also to keep a separate customization

Signed-off-by: Juan David <juand.business@gmail.com>
@lauriejim lauriejim added severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members issue: bug Issue reporting a bug labels Jul 27, 2020
juandl added a commit to juandl/strapi that referenced this issue Jul 27, 2020
To avoid issue with population we change the service of state user to there own service call "fetchState", also to keep a separate customization

Signed-off-by: Juan David <juand.business@gmail.com>
juandl added a commit to juandl/strapi that referenced this issue Jul 27, 2020
To avoid issue with population we change the service of state user to there own service call "fetchState", also to keep a separate customization

Signed-off-by: Juan David <juand.business@gmail.com>
juandl added a commit to juandl/strapi that referenced this issue Jul 27, 2020
To avoid issue with population we change the service of state user to there own service call "fetchState", also to keep a separate customization

Signed-off-by: Juan David <juand.business@gmail.com>
alexandrebodin pushed a commit that referenced this issue Jul 28, 2020
* Fix/#7197/Change custom populate state to own service

To avoid issue with population we change the service of state user to there own service call "fetchState", also to keep a separate customization

Signed-off-by: Juan David <juand.business@gmail.com>

* specific service for fetch  authenticated user

Signed-off-by: Juan David <juand.business@gmail.com>

* Update comment

Signed-off-by: Juan David <juand.business@gmail.com>

* Add some comments

Signed-off-by: Juan David <juand.business@gmail.com>
gilfernandes pushed a commit to onepointconsulting/strapi that referenced this issue Aug 13, 2020
)

* Fix/strapi#7197/Change custom populate state to own service

To avoid issue with population we change the service of state user to there own service call "fetchState", also to keep a separate customization

Signed-off-by: Juan David <juand.business@gmail.com>

* specific service for fetch  authenticated user

Signed-off-by: Juan David <juand.business@gmail.com>

* Update comment

Signed-off-by: Juan David <juand.business@gmail.com>

* Add some comments

Signed-off-by: Juan David <juand.business@gmail.com>
Signed-off-by: Gil Fernandes <gil.fernandes@onepointltd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants