Route Resolver with group field

Hi, is it possible for a route resolver to fetch content relationships within a group field?

I have this person type

{
  "id": "person",
  "label": "Person",
  "repeatable": true,
  "status": true,
  "json": {
    "Main": {
      "uid": {
        "type": "UID",
        "config": {
          "label": "Uid",
          "placeholder": ""
        }
      },
      "services": {
        "type": "Group",
        "config": {
          "label": "Services",
          "fields": {
            "service": {
              "type": "Link",
              "config": {
                "label": "service",
                "select": "document",
                "customtypes": ["service"]
              }
            }
          }
        }
      }
    }
  }
}

And this is the route I'm trying to add:

{
  type: 'person',
  path: '/:service?/:uid',
  resolvers: {
    service: 'services.service',
  },
}

This completely breaks the route resolver. Ideally I'd like it to fetch all the services listed under a person, but even the first service could work

Thanks,

Raj

Hi Raj,

Welcome to the community!

This is not possible as you have found. It's also not something we're likely to implement as a feature, but I will mark it as a feature request. So, I would recommend rethinking your content modelling.

Can you tell me more about what you're trying to achieve? I'm not sure I understand the use case.

Thanks.

Hi Phil,

Ah ok, thanks for your reply.

We're trying to achieve a url structure where people can be nested under services. So we have a list of services, e.g. Branding, Web design as a service type, and a list of people as a person type. An example of a url would be /service/branding/phil.

The problem is that people can be tied to multiple services, and so we need both /service/branding/phil and /service/web-design/phil to resolve. This is why you can select multiple services on a person

Thanks,

Raj

OK, I understand better.

I'm going to reach out to my team to understand how they implemented something similar to this recently then I'll get back to you.

Thanks.

So, think the only way to create a document with multiple routes would be through a convoluted content model. In Prismic, there's one route per document. So, if you want /education/phil and /videos/phil , you need two phil documents. Presumably, you'd create a document for the route with a content relationship to the person and a content relationship to the department.

You might be able to model this in your Next.js pages directory somehow, but any links to Prismic documents won't work.

Having two documents would be too much content duplication for us, so we're gonna scrap the multiple routes idea. Instead we're going to have a main_service, which is a single content relationship field used for routing, and then an other_services field for the other relationships that is used for presentational purposes only

Thanks for your help Phil!

1 Like