Closed terion-name closed 3 years ago
I will look at your code carefully, but you can not use the same props same time. The second one will rewrite the first one.
@AhmedElywa as I've said I've tried all combos, none work
@terion-name after looking at my code. I exported the generateInputsString
function in the last version 4.0.7 you can use to return a string direct you can use it to build your file without using the print
function.
https://github.com/paljs/prisma-tools/blob/main/packages/plugins/src/sdlInputs.ts#L104-L99
filterInputs
first then apply the excludeFields
filter to the returned array.input
types, not including the enum
or output type
@AhmedElywa thank you) I'll test soon
@AhmedElywa thank you, now it works. Added such filter to remove immutable fields:
filterInputs: input => {
const omit = ['updatedAt', 'createdAt'];
if (input.name.match(/.+(Create|Update)[A-Z].*/)) {
omit.push('id')
}
return input.fields.filter((field) => !omit.includes(field.name));
}
But this is far from perfect due to autogenerated primary key can be named not id
:(
it's strange that prisma's built-in inputs (that you use internally to render, if I understand correctly) include fields that should not be user-provided.
v 3.8.3 I generate input file like this:
With any combination of
excludeFields
andfilterInputs
(anyone or both) — file output contains these fields.Also, can callback get some more data for filtering? e.g. fields with
@id
,@updatedAt
and@createdAt
directives should be omitted in general (not by names, but by directives) and even by default I suppose, but there is no data on this in callback input. can it be passed to callback?