@apollo/client
Version:
A fully-featured caching GraphQL client.
37 lines (36 loc) • 973 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Scalar = void 0;
class Scalar {
options;
static fromGraphQLScalarType(scalarType, options) {
return new Scalar({
...options,
parse: scalarType.parseValue,
serialize: scalarType.serialize,
});
}
constructor(options) {
this.options = options;
}
parse(value) {
return this.options.parse(value);
}
serialize(value) {
return this.options.serialize(value);
}
coerceToParsed(value) {
return this.is(value) ? value : this.parse(value);
}
coerceToSerialized(value) {
return this.is(value) ? this.serialize(value) : value;
}
is(value) {
if (this.options.is) {
return this.options.is(value);
}
return typeof value === "object" && value !== null;
}
}
exports.Scalar = Scalar;
//# sourceMappingURL=Scalar.cjs.map