Lucky you! You found an early release chapter - it will be fully polished and published shortly!
Rest assured, the gnomes are hard at work
completing this video!
Coming soon...
So when two resources are related in our api, they show up and we set them as Iris. But you might say, Hey, could you instead actually include the data right here for Dragon Treasure instead of the iri? So I don't need to make a second, third, fourth, and fifth request to get that data. Yep, that's totally possible. Again, you can also do something really cool with Vulcan, but let's learn how to embed data.
In two minutes. We have meeting with Daniel.
Let's learn how to embed data. Okay, so when we're reading, when we're, when user objects being serialized, it uses the normalization context and it's using the user colon read group. So that's why the email field shows up and the username field shows up as well as the dragon treasures to make dragon treasures. To turn this dragon treasures into an into embedded data, we need to go into Dragon Treasure and add this same user colon read group to whatever fields we want to show up there. So check this out. Let's go above name and add user read here, and then let's also go down and add it to value. So as soon as we have even one property inside a dragon treasure that uses that same normalization group, watch what happens when we execute that. Awesome. It actually includes name and value here, and of course it's in the normal at ID and at type. So what this means is that when you have a relation field, it can either be a string or an embedded object. It just depends on your normalization config, which is going to use. All right, so let's do the same thing in the other direction. So we have a treasure whose ID is two. So I'm gonna go up here to the get single treasure endpoint. We'll put ID two in there.
Perfect. And we see owner as an I R I string. So let's see if we can get that to be embedded. So we know Dragon Treasure uses the treasure coin read normalization group. So if we go into user and add that to username
"Houston: no signs of life"
Start the conversation!
// composer.json
{
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^3.0", // v3.0.8
"doctrine/annotations": "^1.0", // 1.14.2
"doctrine/doctrine-bundle": "^2.8", // 2.8.0
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.2
"doctrine/orm": "^2.14", // 2.14.0
"nelmio/cors-bundle": "^2.2", // 2.2.0
"nesbot/carbon": "^2.64", // 2.64.1
"phpdocumentor/reflection-docblock": "^5.3", // 5.3.0
"phpstan/phpdoc-parser": "^1.15", // 1.15.3
"symfony/asset": "6.2.*", // v6.2.0
"symfony/console": "6.2.*", // v6.2.3
"symfony/dotenv": "6.2.*", // v6.2.0
"symfony/expression-language": "6.2.*", // v6.2.2
"symfony/flex": "^2", // v2.2.4
"symfony/framework-bundle": "6.2.*", // v6.2.3
"symfony/property-access": "6.2.*", // v6.2.3
"symfony/property-info": "6.2.*", // v6.2.3
"symfony/runtime": "6.2.*", // v6.2.0
"symfony/security-bundle": "6.2.*", // v6.2.3
"symfony/serializer": "6.2.*", // v6.2.3
"symfony/twig-bundle": "6.2.*", // v6.2.3
"symfony/ux-react": "^2.6", // v2.6.1
"symfony/validator": "6.2.*", // v6.2.3
"symfony/webpack-encore-bundle": "^1.16", // v1.16.0
"symfony/yaml": "6.2.*" // v6.2.2
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.2
"symfony/debug-bundle": "6.2.*", // v6.2.1
"symfony/maker-bundle": "^1.48", // v1.48.0
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/stopwatch": "6.2.*", // v6.2.0
"symfony/web-profiler-bundle": "6.2.*", // v6.2.4
"zenstruck/foundry": "^1.26" // v1.26.0
}
}