2

For an application I want to remove some levels of data from what jss's layout service returns. My end goal is to have an api endpoint that returns fields on the content items and fields on personalized datasource items. I want the json to look like the following:

{
   id: '{myId}',
   path: '/my/path',
   fields: [
      {
         name: 'field name',
         value: 'value'
      }
   ],
   content : //placeholder name
   [
      {
         id: '{myId}',
         fields: [
           {
              name: 'field name',
              value: 'value'
           }
         ]
      },
      {
         id: '{myId}',
         fields: [
           {
              name: 'field name',
              value: 'value'
           }
         ]
      }
   ]
}

Is it possible to do this with GraphQL? So far it looks like using the GraphQL fields on renderings (integrated mode) cannot affect the json returned by the layout service that is outside of a rendering. I think using that method to get the desired effect I would need to customize jss's item serializer.

If I used the connected approach is there an easier way to do this than adding a custom query that looks up personalized datasources based on a context item? It seems like the existing datasources query has a different purpose (passing in the context item's path/id gives the context item itself back).

1 Answer 1

3

You would need to customize the item serializer to accomplish what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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