Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projection on addRelation not working for Discriminators #441

Open
danimayfield opened this issue Mar 27, 2024 · 0 comments
Open

Projection on addRelation not working for Discriminators #441

danimayfield opened this issue Mar 27, 2024 · 0 comments

Comments

@danimayfield
Copy link

danimayfield commented Mar 27, 2024

I have a discriminator called BProduct which is a discriminator off the base of AProduct. And this discriminator has a property I'm trying to add a relation to:

BProductTC.getFieldOTC("metadata").addRelation(
  "amenities",
  {
    resolver: () => AmenityTC.mongooseResolvers.findByIds(),
    prepareArgs: {
      _ids: (source: any) => source.amenities ?? [],
      sort: null,
      limit: null,
    },
    extensions: { projection: { amenities: true } }, <-- This doesn't work
  }
);

However the projection on this discriminator (BProduct) doesn't work at all regardless of if I use extensions or not.

The below relation on the base model of AProduct works perfectly with the use of extension though:

AProductTC.addRelation("tags", {
  resolver: () => TagTC.mongooseResolvers.findByIds()
  prepareArgs: {
    _ids: (source) => source.tags,
    sort: null,
    limit: null,
  },
  extensions: { projection: { tags: true } }, <-- works as projection should
});

Does anyone have a solution for adding relations on discriminator properties?

These are my dependancies:

  "graphql": "^16.8.1",
    "graphql-compose": "^9.0.10",
    "graphql-compose-mongoose": "^10.0.0",
    "mongodb": "^6.2.0",
    "mongoose": "^8.2.0",

Originally posted by @danimayfield in #377 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant