Skip to content

Question: how to detect relationships #846

Discussion options

You must be logged in to vote

Relationships will always be an object containing a data attribute (which itself will always contain id, type and any attributes from the relationship. 1-1 relationships will have data as an object and 1-many relationships will have data as an array of objects

I.e author and comments are 1-1 and 1-many relationships here:

{
  id: '89',
  type: 'post',
  content: 'My post content',
  author: {
    data: {
      id: '42',
      type: 'people',
      name: 'John'
    }
  },
  comments: {
    data: [
      {
        id: '43',
        type: 'comment',
        text: 'A comment',
        author: {
          data: {
            id: '3',
            type: 'people',
            name: 'Bob'
          }

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by wopian
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants
Converted from issue

This discussion was converted from issue #845 on April 18, 2023 10:04.