Structured Text Inline Block: GQL error

Describe the issue:

Trying to use inline blocks in structured text as per Inline blocks are landing in structured texts! — DatoCMS but there is a GQL error when trying query the structured text:

Selections can’t be made on scalars (field ‘inlineBlocks’ returns String but has selections [id])

This error appears both in the GQL API and the GQL playground, however the playground returns the expected result but shows this error

Field inline must not have a selection since type “[String!]!” has no subfields

(Recommended) What’s the URL of the record or model in question?

https://sandbox-9778.admin.datocms.com/editor/item_types/aqPKVh8fSFi1LvDXDh1J6Q/items/ALUD2YpURu6FaaVLmo5gag

(Optional) Do you have any sample code you can provide?

No code, check a sandbox with Structure Text inline block/records.

Hoping this one is a skill issue on my end, cheers!

Hi @matty,

What is the actual query you’re trying to make? (As in what is the actual GraphQL query you have right now that’s not working, and what is your intent with that query?)

You can post it here on the forum by formatting with triple backticks followed by “gql”, like this:

```graphl
query MyQuery {
  blahBlahModel: {
    id
  }
}
```

will be rendered as:

query MyQuery {
  blahBlahModel: {
    id
  }
}

(Sorry, your project playground is only saved on your computer and I can’t see what you put in there!)

A query like this seems to work OK for me, but not sure if this is what you’re trying to do:


query MyQuery {
  allAPages {
    title
    slug
    sections
    rte { # rte is the structured text field
      blocks # will be empty because this field has no separate blocks
      inlineBlocks { # no inline blocks either
        id
      }
      value # the actual structured text, where the inline items and links live
      links { # use this to look up the record links from the value field by ID
        id
        title
        slug
        sections
      }
    }
  }
}

If that’s not what you were trying to do, could you please provide the query you attempted to use?

Ok this is working as expected now, below query in the playground is here and completely fine

{
  aPage(filter: {slug: {eq: "page-with-inline-link"}}) {
    title
    rte {
      inlineBlocks {
        page {
          slug
        }
      }
    }
  }
}

Even if the model was updated to have many types of inlineBlocks its working

{
  aPage(filter: {slug: {eq: "page-with-inline-link"}}) {
    title
    rte {
      inlineBlocks {
      # as an example, model isn't set up this way
       ... on RecordInterface {
         id
        __typename
       }

       ... on CtaRecord {
        label
        page {
          slug
        }
      }
    }
  }
}

I will keep looking to see what is wrong on my end. Cheers

Update: it was a skill issue.

Sandbox error: inline block only had a single record in the validation but I was using the below which it doesn’t seem to like, completely fine adjusted the query.

inlineBlocks {
   ... on RecordInterface {
    id
    __typename
}

Code GQL error: I was not pointing to the correct Dato environment which had the model with inline blocks (main had no inlineBlocks, so empty array).

Closing, thanks for your time as always support team

1 Like

Great, glad you got it working and thank you for the update!