0

I have a page in contentful which I retrieve content to my react app with graphql. In this page, a link a content model called Person which is like that:

{
  "name": "Person",
  "description": "",
  "displayField": "name",
  "fields": [
    {
      "id": "name",
      "name": "Name",
      "type": "Symbol",
      "localized": false,
      "required": true,
      "validations": [],
      "disabled": false,
      "omitted": false
    },
    {
      "id": "profilePic",
      "name": "profile pic",
      "type": "Link",
      "localized": false,
      "required": true,
      "validations": [],
      "disabled": false,
      "omitted": false,
      "linkType": "Asset"
    },
    {
      "id": "socialLinks",
      "name": "social links",
      "type": "Array",
      "localized": false,
      "required": false,
      "validations": [],
      "disabled": false,
      "omitted": false,
      "items": {
        "type": "Link",
        "validations": [
          {
            "linkContentType": [
              "socialLink"
            ]
          }
        ],
        "linkType": "Entry"
      }
    }

ProfilePic is another content model which include name and picUrl. SocialLinks is an array of socialLink content model which contain name and link

I can retrieve without problem my profilePic name or picUrl but I cannot get the socialLinks. I have read the contentful documentation about one-to-many but is not clear to me how to apply to my case: https://www.contentful.com/developers/docs/references/graphql/#/reference/schema-generation/one-to-many-multi-type-relationships

My query:

...rest of the query..
      founder{
        name,
        profilePic{
          url,
          title
        },
        socialLinksCollection {
          items {
            name,
            link
          }
        }
      },
... rest of the query...

Can somoene help me understand why it doesn't work as a normal collection? Should I maybe use this concept of linkedFrom? But how exactly?

2

1 Answer 1

0

I had to add (limit: 1) to my socialLinksCollections otehrwise there were too many calls and wasn't possible to get the data back. Thanks to @stefan judis for the suggestion where to look out for the errors.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.