Hi Sebastian,
we are now using schemas with nested references with the following structure
- Home page
- team schema 1
- team-member schema
- person schema
- team-member schema
- team schema 1
Basically, we tried to create a list of persons. Most of these persons are part of the team / team-member. Let’s assume we want to have a page where we want to show some content and all persons assigned to content team schema 1 (we could have a different page where we assign team-members to team 2)
Right now, we tried to use the ClientLibrary to query from the top content. By doing so, we do not get our references resolved. We’ve seen a couple of questions in this forum (e.g., Using the Reference Type) which basically tell us to either
- load the recursively.
Taking your comment from [IMPLEMENTED] One-to-many relationship display on Content section a little bit out of context, you agree that having single calls for referenced content is not the best way to go. I think it’s possible to query multiple IDs at once instead of using N queries for N referenced content items. Given we have a deeper hierarchy, we would need to make at least 1 query for each level of hierarchy which is consuming time and API calls. - using GraphQL. This seems to your most recommended solution.
We’ve invested 3-4 hours to trying to get the referenced content resolved and we are at a point where we are a bit frustrated. We’ve managed to write a Graph QL query in the GraphiQL interface (https://cloud.squidex.io/app/XXX/api/graphql) but it’s cumbersome to write such a query per hand and keep it in sync with schema changes.
Open questions that we currently have:
- The easiest way for us would be to have all references resolved automatically (so that it would feel like a big SQL join) by Squidex. Since that request came up multiple times in the past and it’s not implemented suggests, that not resolving references from IDs to content is by design. Instead of breaking existing functionality, an optional query parameter with ‘ResolveNestedSchemas’ would be a possible way to do this. Is this something you would consider on the roadmap?
- How do we move from having a query from GraphiQL to using it with the SquidexClientLibrary? I think we came to the point where we found the right method but didn’t know how to wrap the example query back to C# classes. I’m not sure if we’ve understood Squidex’s GraphQL approach correctly: Do we really need to manually keep these three places in sync? 1) Schema in Squidex, 2) GraphQL query as C# Code, 3) C# wrapper class with attributes that read the JSON response and map to properties in the C# classes.
Is there an easier way? - Would you please provide a complete example in the docs for using GraphQL with multiple levels of nested schemas, starting by creating the schemas in Squidex, writing a GraphQL query for them, querying the API from the GraphQL syntax as C# code through the NuGet package and providing a C# response class where the result from GraphQL is being somewhat flat? This would help us a lot Thank you!