Add option for generate original type too
See original GitHub issueI know this plugin produces mutation validators in the first place, but can we have an option for original type as well? Nowadays we are not only uses zod for mutations, but also validates the data received from the server after fetching. I know I can just add the ID to the schema using zod’s extend, but it would be even more convenient if this plugin could do that.
type Member {
id: ID!
firstName: String
lastName: String
}
type MemberInput {
firstName: String
lastName: String
}
// ->
// add this
export function MemberSchema(): z.ZodObject<Properties<Member>> {
return z.object({
id: z.string(),
firstName: z.string().nullish(),
lastName: z.string().nullish(),
})
}
export function MemberInputSchema(): z.ZodObject<Properties<MemberInput>> {
return z.object({
firstName: z.string().nullish(),
lastName: z.string().nullish(),
})
}
so I can
import { graphQLClient, Member, MemberSchema } from "@/infra/graphql";
const getMembers = async (query = defaultQuery): Promise<Member[]> => {
const { members } = await graphQLClient.request(query);
const validatedData = MemberSchema().array().parse(members);
// instead of
// const validatedData = MemberInputSchema().extend({ id: z.string() }).array().parse(members);
return validatedData;
};
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How can i change options in dropdowns if it is generated ...
My question is : If user selects an option from first dropdown then the options in the other two dropdowns should change according...
Read more >How to Add / Remove Options of a Selection Box Dynamically
1) Using the Option constructor and add() method. First, use the Option constructor to create a new option with the specified option text...
Read more >crunch - generate wordlists from a character set
If your original command used the -s option you MUST remove it before you resume the session. Just add -r to the end...
Read more >Adding variants - Shopify Help Center
You add variants to a product that has more than one option, ... If you've already created a product, you can add options...
Read more >typing — Support for type hints — Python 3.11.1 documentation
Source code: Lib/typing.py This module provides runtime support for type hints. The most fundamental support consists of the types Any, Union, Callable, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I needed the same thing. I opened a PR #109
@anhdd-kuro @Brian-McBride Hi 👋
I just published the latest version v0.6.0 which is included this feature.
Thank you!