[v5] GraphQL schema granularity for sections/entry types #13259
Replies: 6 comments 5 replies
-
I would suggest top-level entry type options BUT would add a union per section, if querying stuff by section is still relevant/possible. This way you don't have essentially duplicate types for stuff if one Entry Type is used in several sections. Eg.
Within the UI, I'm not sure which selection makes the most sense. I guess with the type setup above you would only select with Entry types are available, which then affects which types are included in the section unions. |
Beta Was this translation helpful? Give feedback.
-
I'm not a heavy GQL user, so correct me if I'm wrong here... Let's say you went with (2) and "removed entry type options" from the schema. You would still be able to filter a Section by an Entry Type during the query, right? So if you only wanted entries of a certain type, it would still be possible to retrieve only those entries? If so, I would definitely advocate for (2) as the best (and cleanest) option. |
Beta Was this translation helpful? Give feedback.
-
I would try to make the GraphQL schema match the underlying schema as closely as possible. If I understand the changes you're planning to make, decoupling entry types from sections effectively makes them global peers. So what makes the most sense to me is #3, because you can choose:
To me when I'm thinking of setting access permissions, this is the clearest and most explicit. I also wouldn't mind #2 but I feel like someone will eventually have a case where they want to limit access by entry type as well. |
Beta Was this translation helpful? Give feedback.
-
How big of a performance boost is 2 over 3? |
Beta Was this translation helpful? Give feedback.
-
If you are going to have permissions by type, it would need to be three. Number one has a high error surface area for either incorrect set up, or otherwise unexpected behavior. Two is probably sufficient in most cases. However, needing both by section and type in complex sites could be critical. Depending on the performance implications, being able to pick the sections you need to limit permissions by type seems like an okay “both ways” option. |
Beta Was this translation helpful? Give feedback.
-
We discussed this internally today, and are thinking we’ll go with #2, for three reasons:
Existing schemas that partially include nested section components for some entry types but not others will lose those components as part of the migration, and will need to be re-added afterward. |
Beta Was this translation helpful? Give feedback.
-
Entry types are becoming decoupled from sections in Craft 5. They will be defined globally, and sections will get to choose which entry type(s) are available to it. Which effects GraphQL schemas.
Currently, you can configure a GraphQL schema to allow editing sections on a per-entry type basis.
There are three ways GraphQL schemas could evolve with globalized entry types in Craft 5:
1. Top-level entry type options
List entry types as top-level options, with no relation to the sections they’re included in. Selecting an entry type would make its entries available to GraphQL queries across, for each selected section.
2. Remove entry type options
Maybe they’re not necessary in the first place? We could remove them entirely, leaving only the section options. Selecting a section would make its entries available to GraphQL queries, regardless of entry type.
(This would be the best option for performance.)
3. Section-specific entry type options
Visually identical to what we have now. If an entry type is included in two sections, each section will need to opt into including entries of that type.
19 votes ·
Beta Was this translation helpful? Give feedback.
All reactions