Skip to content

Conversation

avelosa
Copy link

@avelosa avelosa commented Mar 21, 2025

Tried to implement supporting the include functionality that is traditionally specified as a query parameter. The include feature is defined here.
Since there are multiple operations this implementation lets the api user specify a meta object at the top level of each individual operation data. In the meta object the api user can set the include field that expects a list of relationship names.

Example Request Data:

{
  "atomic:operations": [
    {
      "op": "add",
      "data": {
        "type": "Book",
        "attributes": {
          "title": "Meditations"
        },
        "relationships": {
          "author": {
             "data": {
               "id": "1",
               "type": "Author"
             }
          }
        }
      },
      "meta": {
        "include": ["author"]
      }
    }
  ]
}

Example Response Data:

{
  "atomic:results": [
    {
      "data": {
        "type": "Book",
        "id": "1",
        "attributes": {
          "title": "Meditations"
        },
        "relationships": {
          "author": {
             "data": {
               "id": "1",
               "type": "Author"
             }
          }
        }
      }
    },
    "included": [
      {
        "data": {
          "id": "1",
          "type": "Author",
          "attributes": {
            "first_name": "Marcus",
            "last_name": "Aurelius"
          }
        }
      }     
    ]
  ]
}

Each operation can use the include parameter if desired. The meta field is of course optional.

Also adds unit tests for the view and parser.

@avelosa avelosa force-pushed the add-include-support branch from 16c2929 to 310b1d2 Compare March 21, 2025 23:37
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

Successfully merging this pull request may close these issues.

1 participant