#Querying linked records: MedusaError: Requested fields XY are not valid

1 messages · Page 1 of 1 (latest)

mild jetty
#

We created a new module and linked it to our customer module. Then we synced the links and got this success message:

info:    Syncing links...
┌────────────────────────────────────────────────────────┐
│                                                        │
│   Created following links tables                       │
│   - customer.customer <>                               │
│   customerExtModuleService.customer_ext                │
│   (customer_customer_customerextmodule_customer_ext)   │
│                                                        │
└────────────────────────────────────────────────────────┘
info:    Links sync completed

Now when I try to query the customer module and include all fields from customer_ext it does not recognize my fields:

await sdk.store.customer
      .retrieve(
        {
          fields: "+customer_ext.*",
        },
        { next: { tags: ["customer"] }, ...getAuthHeaders() }
      )
      .then(({ customer }) => customer)
      .catch(() => null)
  }

The server always complains:

error:   Requested fields [customer_ext.email_verified_at] are not valid

We tried all variations etc.

What is wrong here? The docs are (again) extremely sparse...

#

Querying linked records: MedusaError: Requested fields XY are not valid

mild jetty
#

Managed to solve this. Wow the new link / module approach is extremely useful and solid

glad sinew
#

Hi @mild jetty,
would you mind to briefly describe what the issue was? That can help others with the same error to solve it.

mild jetty
#

My issue was that I did not properly extend it in the middleware like so:

export default defineMiddlewares({
routes: [
...adminMiddlewares,
...storeMiddlewares,
{
matcher: "/store/customers/me",
middlewares: [
(req: MedusaRequest, res: MedusaResponse, next: MedusaNextFunction) => {
req.allowed = [
"customer_ext",
];

      next();
    },
  ],
},

],
});