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

Resolver Generated for Non-Scalar Fields Does Not Reflect name From Prisma Schema for Primary Keys #213

Open
jpulec opened this issue May 6, 2022 · 0 comments
Labels
type/bug Something is not working the way it should

Comments

@jpulec
Copy link

jpulec commented May 6, 2022

Description

One of the features of prisma is that it allows changing the internally generated name for a composite primary key. It looks like nexus-prisma is hard-coded to use the default name, which means that generated resolvers try to perform lookups that don't exist.

Repro Steps/Link

Create the following Prisma models, and schema definitions.

model Order {
  orderNo Int
  orderCustomerId Int

  orderItems OrderItem[]

  @id([orderNo, orderCustomerId], name: "customerOrder")
}

model OrderItem {
  orderNo Int  orderCustomerId Int

  order Order @relation(fields: [orderNo, orderCustomerId], references: [orderNo, orderCustomerId])
}
import { Order } from "nexus-prisma";

const SchemaOrder = objectType({
  name: "SchemaOrder",
  definition(t) {
    t.field(order.orderItems);
  }
});

Trying to query for orderItems above, will generate the following prisma query, first trying to fetch the order, and then using the fluent api:

prisma.order.findUnique({
  where: {
    orderNo_orderCustomerId: {
      orderNo,
      orderCustomerId,
    }
  }
});

This query bombs since the correct name for the lookup has been mapped to customerOrder but nexus-prisma does not reflect that.

@jpulec jpulec added the type/bug Something is not working the way it should label May 6, 2022
@jpulec jpulec changed the title Resolver Generated for Non-Scalar Fields Does Not Reflect name From Prisma Schema Resolver Generated for Non-Scalar Fields Does Not Reflect name From Prisma Schema for Primary Keys May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is not working the way it should
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant