Closed jw closed 1 year ago
Not exactly sure what you are looking for in terms of format but here is an example: You get the QueryObject and use the properties on the field prop to complete the query It should be noted that you import the Object from the base file
import { findFirstProfileQueryObject } from "@graphql/__generated__/Profile/queries/findFirst.base";
builder.queryFields((t) => {
const field = findFirstProfileQueryObject(t);
return {
**ChangeTheName**: t.prismaField({
...field,
type: Profile,
args: {
...field.args,
},
shield: allow,
resolve: async (query, root, args, context, info) => {
const profile = await prismaClient.profile.findFirstOrThrow({
...query,
where: {
id: {
equals: args.where.id.equals,
},
},
});
return {
...profile,
};
},
}),
};
});
@jw
We dont generate queries/mutations by default
By optionally running autocrud
, it generates everything automatically...
But if you want, you can exclude some models from generation and define them with custom names like elritz example
Optionally, you can use replace
function to change everything in generated code.
Thanks!
This is a great tool! Thanks a lot!
Is it possible to rename the generated queries/mutations (like
findFirstFoo
), into something else (like foo)? Or is there a way to change the queries/mutations after generation? Could anybody give an example?