Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { scalarType } from "nexus";
import { Kind } from "graphql";
// `value` is in seconds from Stripe - We convert it to milliseconds
export const DateTime = scalarType({
name: "DateTime",
asNexusMethod: "dateTime",
description: "DateTime custom scalar type.",
parseValue: value => value, // value from the client
serialize: value => new Date(value * 1000).toISOString(), // value sent to the client
parseLiteral: ast =>
ast.kind === Kind.INT
? new Date(parseInt(ast.value) * 1000).toISOString()
: null
});
protected publishScalar(typeName: string) {
if (scalarsNameValues.includes(typeName as any)) {
return typeName
}
this.markTypeAsPublished(typeName)
return Nexus.scalarType({
name: typeName,
serialize(value) {
return value
},
})
}
import * as Nexus from 'nexus'
export const dateTimeScalar = Nexus.scalarType({
name: 'DateTime',
serialize: value => value,
})
export const uuidScalar = Nexus.scalarType({
name: 'UUID',
serialize: value => value,
})
import * as Nexus from 'nexus'
export const dateTimeScalar = Nexus.scalarType({
name: 'DateTime',
serialize: value => value,
})
export const uuidScalar = Nexus.scalarType({
name: 'UUID',
serialize: value => value,
})