-
For example, given a backing type CreateUser and its inputRef implementation, i'd like to disallow any inputRef fields that don't exist in CreateUser:
Currently I'll get a warning if I neglect any fields from backing type, but adding additional fields is allowed. My use case is that I have automatically generated input objects that I don't want to manually keep in sync with the GraphQL input type implementation. Basically I just want to some type safety to ensure that input objects are always identical to their backing types! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You could use type CreateUser = {
firstName: string;
lastName: string;
};
const CreateActivityInputRef = builder.inputRef<CreateUser>('CreateUserInput').implement({
fields: (t) =>
({
firstName: t.string({ required: true }),
lastName: t.string({ required: true }),
someOtherField: t.string({ required: true }), // <--------- any way to disallow fields like this that don't exist in CreateUser?
} satisfies Record<keyof CreateUser, InputFieldRef<unknown>>),
}); |
Beta Was this translation helpful? Give feedback.
-
This works, thanks! |
Beta Was this translation helpful? Give feedback.
You could use
satisfies
to limit what fields can be defined: