pothos
pothos copied to clipboard
add withScalar method
Based on this issue https://github.com/hayes/pothos/issues/910
Add method withScalars
to SchemaBuilder
to enable loading scalars and inferring their types for convenience. This especially helps with using existing libraries like graphql-scalars
Loading scalars is done via a method instead of as an option to enable the inference to merge the Scalars from the manually typed scalars and the inferred scalars. This is because typescript doesn't have a way to do partial inference.
Previously
const builder = new SchemaBuilder<{
Scalars: {
Date: {
Input: Date;
Output: Date;
};
};
}>({});
builder.addScalarType('Date', CustomDateScalar, {});
Using withScalars
const builder = new SchemaBuilder({}).withScalars({ Date: CustomDateScalar });