Take the community feedback survey now.

Query Optimizely Graph with Strawberry Shake

Vote:
 

When querying Optimizely Graph for content in contentareas using Strawberry Shake it seems that we only can get the expanded result from the first area in the query.

If I have this in the query I only get values in the result från ContentArea1. The result from ContentArea2 only contain null values. If I remove the ContentArea1 part from the query I get correct values from ContentArea2. Is there a setting or something else preventing me from getting results from multiple areas in the same query?

ContentArea1 {
      ContentLink {
        Expanded {
          ... on BlockType1 {
            Property1
            Property2
          }
        }
      }
    }
  ContentArea2 {
      ContentLink {
        Expanded {
          ... on BlockType2 {
            Property1
            Property2
          }
        }
      }
    }

 

 

#338539
May 22, 2025 11:56
Johan Kronberg - May 23, 2025 11:05
Do the results look as expected when running the query in GraphiQL?
Vote:
 

Yes, running the same query in GraphiQL gives me correct result

#338593
May 23, 2025 11:12
Vote:
 

Try using GuidValue or Id for the ContentLink like.

        ContentLink {
          GuidValue
          Expanded {
            ... on MyContentType {
 
This should fetch you appropriate data in the strawberry shake client
#338604
Edited, May 23, 2025 15:29
Vote:
 

Hi,

Any updates here? I'm having a similar issue with the Strawberryshake client, but still not getting any results when including GuidValue (or Id).

And yes, this works as expected in the GraphiQL editor.

  • Locations: ContentArea
    • LocationPage: PageData
      • Addresses: ContentArea
DepartmentPage {
    items {
      Name
      Locations {
        ContentLink {
          GuidValue
          Expanded {
            ... on LocationPage {
              Title
              Url
              Addresses {
                ContentLink {
                  GuidValue
                  Expanded {
                    ... on AddressBlock {
                      AddressLine1
                      AddressLine2
                      PostalCode
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
#339949
Aug 13, 2025 8:53
Vote:
 

So I did a test against Allloy project for this and I am able to get the correct data. Here are my inputs and responses.

Article page has Main Content aread and a secondary content area. Query below

query ArticlesContentAreaQuery {
  ArticlePage {
    items {
      Name
      MainContentArea {
        ContentLink {
          Expanded {
            ... on ContactPage {
              ContentLink{
                Id
                GuidValue
              }
              Name
              Email
            }
          }
        }
      }
      SecondaryContentArea {
        ContentLink {
          Expanded {
            ... on ContactPage {
              Name
              Email
              ContentLink {
                Id
                GuidValue
              }
            }
          }
        }
      }
    }
  }
}

 

In the Controller, I have following 

        var queryResponse = await _contentGraphClient.ArticlesContentAreaQuery.ExecuteAsync();

        var mainContentData = queryResponse.Data.ArticlePage.Items.First().MainContentArea.First().ContentLink.Expanded as IArticlesContentAreaQuery_ArticlePage_Items_MainContentArea_ContentLink_Expanded_ContactPage;
        var secondaryContentData = queryResponse.Data.ArticlePage.Items.First().SecondaryContentArea.First().ContentLink.Expanded as IArticlesContentAreaQuery_ArticlePage_Items_SecondaryContentArea_ContentLink_Expanded_ContactPage;

Here am looking only for the first item only to compare results. After casting, when i inspect mainContentData and secondaryContentData I see appropriate values. You can compare against the data I provided and ensure to have the query updated (if anything missing) and also make sure to cast it from correct interface as each item in ContentArea expanded object will have interfaces and need to be used correctly.

 

let me know if any questions. Unfortunately I cannot attach screenshots.

#340019
Edited, Aug 21, 2025 18:07
Vote:
 

Still no luck. I have double checked that I've used the correct generated interfaces.

I have the same issue as the original poster, where only the first expanded content is returned. The second has only null values.

It is always like this, and if I swap them around, its still the first that has values.

So for this sample query, ContentArea1_ContentLink_Expanded_NewsPage will have values, but ContentArea2_ContentLink_Expanded_NewsPage will have null-values.

query ContentWithNewsPagesQuery {
    ContentPage {
        items {
            ContentLink {
                Id
            }
            Url
            ContentArea1 {
                ContentLink {
                    Expanded {
                        __typename
                        ... on NewsPage {
                            __typename
                            Name
                            Content
                        }
                    }
                }
            }
            ContentArea2 {
                ContentLink {
                    Expanded {
                        __typename
                        ... on NewsPage {
                            __typename
                            Name
                            Content
                        }
                    }
                }
        }
    }
}

 

And if I just swap the ContentAreas around in the query, it will be the oppsite. ContentArea2_ContentLink_Expanded_NewsPage will have values, but ContentArea1_ContentLink_Expanded_NewsPage will have null-values.

query ContentWithNewsPagesQuery {
    ContentPage {
        items {
            ContentLink {
                Id
            }
            Url
            ContentArea2 {
                ContentLink {
                    Expanded {
                        __typename
                        ... on NewsPage {
                            __typename
                            Name
                            Content
                        }
                    }
                }
            }
            ContentArea1 {
                ContentLink {
                    Expanded {
                        __typename
                        ... on NewsPage {
                            __typename
                            Name
                            Content
                        }
                    }
                }
            }
        }
    }
}

 

#340087
Edited, Aug 25, 2025 9:41
Dileep D - Aug 25, 2025 14:59
Its hard to tell why the difference in behavior would be, may be you want to delete the graph client, recreate the client using dotnet-init command and re run the index job. Also am using StrawberryShake.Server(13.9.12) and StrawberryShake.Transport.Http(14.0.0) if it makes any difference compare the versions you are using. Check how this works on a different project like Alloy (might get some hint on differences)
Vote:
 

Hi,

I think the issue here is the generated C# models by StrawberryShakes share one underlying fragment/type mapping.

Have you tried to use alias like this:

Area1: ContentArea1 {
      ContentLink {
        Expanded {
          ... on BlockType1 {
            Property1
            Property2
          }
        }
      }
    }
Area2: ContentArea2 {
      ContentLink {
        Expanded {
          ... on BlockType2 {
            Property1
            Property2
          }
        }
      }
    }
#340135
Aug 29, 2025 4:45
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.