GraphQL query for Modular Content field type

I think you have to add all the possible blocks into your query. Only used blocks will be returned, and the frontend will have to know how to render each type based on its _modelApiKey or __typename.

You can use a switch statement to deal with the different kinds of possible blocks, like in this example for Structured Text (not the same thing as Modular Content, but the frontend switch logic should be similar):

switch (record.__typename) {
            case 'ImageRecord':
              return <Image data={record.image.responsiveImage} />;
            default:
              return null;
          }
2 Likes