paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
680 stars 55 forks source link

Question: transform outputs from pal g for SDL first #289

Open simmons-kyle opened 1 year ago

simmons-kyle commented 1 year ago

Is it possible to transform the outputs which pal g creates in both the typeDefs and resolvers outputs? For example, our existing setup has resolvers defined in this format in our schema.graphql (using a type named User as an example):

type Query {
   users(first: Int, skip: Int, where: UserWhereInput): [User]!
}
type Mutation {
  createUser(data: UserCreateInput!): User!
  updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User
  deleteUser(where: UserWhereUniqueInput!): User
}

However I noticed that pal g will create these in the format (I know there are other queries that are also generated such as findUniqueUser, findFirstUser, etc. , but just scoping on the specifics for now):

type Query {
  findManyUser(where: UserWhereInput, orderBy: [UserOrderByWithRelationInput], cursor: UserWhereUniqueInput, take: Int, skip: Int, distinct: [UserScalarFieldEnum]): [User!]
}
type Mutation {
  createOneUser(data: UserCreateInput!): User!
  updateOneUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User!
  deleteOneUser(where: UserWhereUniqueInput!): User
}

Is there any config that I can provide to "transform" the names of the created resolvers - and more importantly the typeDefs - into the formats that fit our current system?

We already have something in place which will handle the execution of the resolvers, the main goal is for us to dynamically generate our schema.graphql on our current schema.prisma files, hence the importance on the typeDefs.