How to use the nexus.scalarType function in nexus

To help you get started, we’ve selected a few nexus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jferrettiboke / stripe-graphql / src / graphql / _scalars / DateTime.ts View on Github external
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
});
github prisma-labs / nexus-prisma / src / publisher.ts View on Github external
protected publishScalar(typeName: string) {
    if (scalarsNameValues.includes(typeName as any)) {
      return typeName
    }

    this.markTypeAsPublished(typeName)

    return Nexus.scalarType({
      name: typeName,
      serialize(value) {
        return value
      },
    })
  }
github prisma-labs / nexus-prisma / src / scalars.ts View on Github external
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,
})
github prisma-labs / nexus-prisma / src / scalars.ts View on Github external
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,
})