Open edjiang opened 3 years ago
Me too.
My workaround is to add a custom formatTypegen
fn.
export const schema = makeSchema({
types: [User, Mutation, Query, GraphQLDate],
outputs: {
typegen: path.resolve(__dirname, './__generated__/nexus-typegen.ts'),
schema: path.resolve(__dirname, './__generated__/schema.graphql'),
},
formatTypegen: (code, type) => {
if (type === 'types') {
return code.replace(/null/g, 'null | undefined');
}
return code;
},
});
If I define:
Is there a reason to differentiate undefined with null? This means that I can't pass a typescript optional directly, and will have to
return optional || null