-
Notifications
You must be signed in to change notification settings - Fork 960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make dynamic zone fragment documentation more clear #1386
Comments
Hi @harshSinghCondenast I think I understand the issue here as it relates to a new population option we have on dynamic zones (though our documentation does not make this clear/easy to find) For populating the dynamic zones with specific needs per component you will want to use this new In your case the way I would build that middleware would be as such: "use strict";
/**
* `defaultPopulate` middleware
*/
module.exports = (config, { strapi }) => {
// Add your own logic here.
return async (ctx, next) => {
if (!ctx.query.populate) {
ctx.query.populate = {
// Handle all the media fields
logo: {
fields: ["name", "caption", "alternativeText", "url"],
},
twitterImage: {
fields: ["name", "caption", "alternativeText", "url"],
},
GridImage: {
fields: ["name", "caption", "alternativeText", "url"],
},
SliderImage: {
fields: ["name", "caption", "alternativeText", "url"],
},
// Handle the relations
ad_audiences: {
populate: ["type"],
},
// Handle the dynamic zone
pageBuilder: {
on: {
"ad-block-menu.accordian": {
fields: ["yourField"],
},
"ad-block-menu.audience-stats": {
fields: ["someOtherField"],
},
"ad-block-menu.brands-slider": {
fields: ["anotherField"],
populate: {
someNestedRelation: true,
},
},
//etc...
},
},
};
}
await next();
};
}; |
I'm going to transfer this issue over to our docs team to have them adjust the docs to be a bit more clear on how this works compared to just regular populate (we also need to mirror this into the REST population doc too. |
Edited by @derrickmehaffy for the docs team, we need to clean up the docs for fragmets in the entityService + REST population docs to make it a bit more clear on the differences between regular populate vs the on fragmet syntax and explain the differences.
Whenever you start working on this, reach out to me on Slack as I have some suggestions and also just so you know this user is one of our EE customers
Bug report
unable to fetch relation queries for collections with many relations, images, and dynamic zones
Required System information
Describe the bug
whenever I'm trying to make the query for collections that have many sections like dynamic zones, relations, and images, The relation field is not getting populated.
I have used custom middleware generated by strapi generate.
here is the code.
I have also tried these queries
but this also doesn't worked.
I tried with another example but it worked with the same queries. So really was not able to find the issue.
Steps to reproduce the behavior
Expected behavior
the final JSON should load with all the images, relations, and dynamic zones.
Code snippets
custom middleware code
routes.js for implementation of bug
schema for the brands
Additional context
https://drive.google.com/drive/folders/1EnUwkGcoXRWKqLiMoxX6cmOPizMKP36U?usp=share_link
The text was updated successfully, but these errors were encountered: