5

If using DD4T2 and publishing JSON, is it possible to request individual component field elements from the published JSON (e.g. for a page or a DCP) using the GraphQL Content Service (in Tridion Sites 9), or would I need to request the whole JSON for the page/DCP using the GraphQL Content Service and then parse it in my code?

I saw from Oleksii and Ben’s TDS presentation (https://vimeo.com/293897994#t=31m10s) that we can get the ‘raw data’ for the published JSON, but I wonder whether we can drop into that in the query and just have the GraphQL Content Service return, for example, an individual content field from a component?

One of the big advantages of GraphQL is being able to retrieve only small data packets. Obviously that it not so valuable if we can't return just individual component fields and instead have to send the JSON for the whole Page/DCP over the wire (and process it).

3

Unfortunately, the DD4T JSON (or DXA R2 JSON for that matter) is basically just a blob of text for the Content Service.

Indeed, the GraphQL Content Service provides a feature to return JSON content as JSON within the GraohQL result (rather than an escaped JSON string), but that is as far as it goes; it is not really structured data which can be filtered or queried.

There are ideas to improve this in Sites 9.5, though.

| improve this answer | |
2

Rick already answered to clarified.

Indeed!, there is no OOTB way to retrieve individual components fields values of published DCP and page JSON outputs, but It's possible to do a Graph-QL extension using the ‘CDGraphQLSchemaExtension’ extension point. This is available in Sites 9.0 but with limited support as it is currently not documented. It will fully be supported in 9.1 when R&D introduce the new Add-On service UnifiedExtension mechanism.

For now, the content part is returned as “untyped JSON” and can’t be selected via GraphQL. This is something R&D looking into for 9.5. So writing your own extension you can either add new custom fields or transform the content body to something else.

I hope it helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.