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

Relationship attributes are not displayed in the response #34

Closed
midsonlajeanty opened this issue Jul 5, 2023 · 2 comments
Closed

Relationship attributes are not displayed in the response #34

midsonlajeanty opened this issue Jul 5, 2023 · 2 comments

Comments

@midsonlajeanty
Copy link

I'm using Laravel 10 an spatie/laravel-query-builder

 {
    "id": "2",
    "type": "tickets",
    "attributes": {
      "code": "64a2ec21d75e4",
      "total_amount": "75.00",
      "created_at": "2023-07-03T15:41:21.000000Z",
      "updated_at": "2023-07-03T15:41:59.000000Z"
    },
    "relationships": {
      "user": {
       // The key attributes is not present 
        "data": {
          "type": "users",
          "id": "1",
          "meta": {}
        },
        "meta": {},
        "links": {}
      }
    },
    "meta": {},
    "links": {}
  }
@bolivir
Copy link

bolivir commented Jul 8, 2023

Thats correct, they shouldnt be present in the relationships. You need to include them with the query builder. See https://github.com/timacdonald/json-api/#example-request-and-response then they will be in the included section.

@timacdonald
Copy link
Owner

as @bolivir mentioned, you need to "include" the relationships to see their attributes.

This is part of the JSON:API specification.

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

3 participants