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

prisma-extended-models #57

Open
kamalkech opened this issue Dec 18, 2024 · 1 comment
Open

prisma-extended-models #57

kamalkech opened this issue Dec 18, 2024 · 1 comment
Assignees
Labels
❓ talk: question Can be resolved with an answer

Comments

@kamalkech
Copy link

bunx prisma-extended-models generate     
error: GET https://registry.npmjs.org/prisma-extended-models - 404

this package deleted ?

@schettn
Copy link
Contributor

schettn commented Dec 18, 2024

Seems like the command in the docs is wrong. The correct one is bunx prisma-repository.

But I will remove the prisma-extended-models soon because they are quite outdated and might not work with the latest version of pylon.

Instead you should use prismas client extensions, there you can define extra fields on your data result which is then used by pylon.

For example:

const prisma = new PrismaClient().$extends({
  name: 'code',
  result: {
    project: {
      user: {
        needs: {
          userId: true,
        },
        compute(args) {
          return async () => {
            return await prisma.user.findFirstOrThrow({
              where: {
                id: args.userId,
              },
            });
          };
        },
      }
    },
  },
});


export const graphql = {
  Query: {
    project: async (projectSlug: string) => {
      // This will also include the user relation that is only queried if needed
      return await prisma.project.findFirst({
        where: {
          slug: projectSlug,
        },
      });
    },
  },
};

@schettn schettn added the ❓ talk: question Can be resolved with an answer label Dec 18, 2024
@schettn schettn self-assigned this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ talk: question Can be resolved with an answer
Projects
None yet
Development

No branches or pull requests

2 participants