How to use the nexus.mutationType 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 prisma-labs / nexus-prisma / tests / __app / main.ts View on Github external
import { objectType, queryType, mutationType } from 'nexus'

export const Query = queryType({
  definition(t) {
    // ASSERT findOne & findMany
    t.crud.user()
    t.crud.users()
  },
})

export const Mutation = mutationType({
  definition: t => {
    t.crud.createOnePost()
    t.crud.updateManyPost()
  },
})

export const User = objectType({
  name: 'User',
  definition(t) {
    // ASSERT CUID maps to GQL ID
    t.model.id()
    t.model.firstName()
    // ASSERT pagination automatically enabled
    // ASSERT exposes filtering if true
    // ASSERT exposes ordering if true
    t.model.posts({ filtering: true, ordering: true })
github keepforever / a-prisma2 / src / resolvers / Mutation.ts View on Github external
import { compare, hash } from 'bcrypt';
import { sign } from 'jsonwebtoken';
import { idArg, mutationType, stringArg, booleanArg } from 'nexus';
import { APP_SECRET, getUserId, createToken } from '../utils';
import { string } from 'yup';

export const Mutation = mutationType({
    definition(t) {
        t.field('signup', {
            type: 'AuthPayload',
            args: {
                name: stringArg({ nullable: true }),
                email: stringArg(),
                password: stringArg(),
                isAdmin: booleanArg(),
                arenaHandle: stringArg()
            },
            resolve: async (
                _parent,
                { name, email, password, arenaHandle },
                ctx
            ) => {
                const hashedPassword = await hash(password, 10);
github prisma-labs / nexus-prisma / examples / blog / src / schema / Mutation.ts View on Github external
import { mutationType } from 'nexus'

export const Mutation = mutationType({
  definition(t) {
    t.crud.createOneBlog()
    t.crud.updateManyBlog()
  },
})
github prisma / prisma-examples / javascript / graphql-auth / src / types / Mutation.js View on Github external
const { compare, hash } = require('bcryptjs')
const { sign } = require('jsonwebtoken')
const { idArg, mutationType, stringArg } = require('nexus')
const { APP_SECRET, getUserId } = require('../utils')

const Mutation = mutationType({
  definition(t) {
    t.field('signup', {
      type: 'AuthPayload',
      args: {
        name: stringArg({ nullable: true }),
        email: stringArg(),
        password: stringArg(),
      },
      resolve: async (parent, { name, email, password }, ctx) => {
        const hashedPassword = await hash(password, 10)
        const user = await ctx.photon.users.create({
          data: {
            name,
            email,
            password: hashedPassword,
          },
github arkhn / pyrog / server-v2 / src / types / Mutation.ts View on Github external
import { arg, idArg, mutationType, stringArg, booleanArg } from 'nexus'

import { createResource, updateResource, deleteResource } from './Resource'
import { deleteSource, createSource } from './Source'
import { createAttribute, updateAttribute, deleteAttribute } from './Attribute'
import { signup, login } from './User'
import { createInput, deleteInput } from './Input'
import { deleteCredential, upsertCredential } from './Credential'
import { createTemplate, deleteTemplate } from './Template'
import { addJoinToColumn } from './Column'
import { updateJoin, deleteJoin } from './Join'

export const Mutation = mutationType({
  /*
   * AUTH
   */

  definition(t) {
    t.field('signup', {
      type: 'AuthPayload',
      args: {
        name: stringArg({ required: true }),
        email: stringArg({ required: true }),
        password: stringArg({ required: true }),
      },
      resolve: signup,
    })

    t.field('login', {
github tonyfromundefined / serverless-graphql-workshop / cheatsheet / server / src / resolvers / Mutation.ts View on Github external
import { mutationType } from 'nexus'

export const Mutation = mutationType({
  definition(t) {
    t.string('ping', {
      resolve: (_parent, _args, _context) => {
        return 'pong'
      },
    })
  },
})
github prisma / photonjs / examples / typescript / graphql-auth / src / resolvers / Mutation.ts View on Github external
import { compare, hash } from 'bcrypt'
import { sign } from 'jsonwebtoken'
import { idArg, mutationType, stringArg } from 'nexus'
import { APP_SECRET, getUserId } from '../utils'

export const Mutation = mutationType({
  definition(t) {
    t.field('signup', {
      type: 'AuthPayload',
      args: {
        name: stringArg({ nullable: true }),
        email: stringArg(),
        password: stringArg(),
      },
      resolve: async (parent, { name, email, password }, ctx) => {
        const hashedPassword = await hash(password, 10)
        const user = await ctx.photon.users.create({
          data: {
            name,
            email,
            password: hashedPassword,
          },
github tonyfromundefined / serverless-graphql-workshop / starters / server / src / resolvers / Mutation.ts View on Github external
import { mutationType } from 'nexus'

export const Mutation = mutationType({
  definition(t) {
    t.string('ping', {
      resolve: (_parent, _args, _context) => {
        return 'pong'
      },
    })
  },
})
github prisma / prisma-examples / typescript / graphql-auth / src / types / Mutation.ts View on Github external
import { compare, hash } from 'bcryptjs'
import { sign } from 'jsonwebtoken'
import { idArg, mutationType, stringArg } from 'nexus'
import { APP_SECRET, getUserId } from '../utils'

export const Mutation = mutationType({
  definition(t) {
    t.field('signup', {
      type: 'AuthPayload',
      args: {
        name: stringArg(),
        email: stringArg({ nullable: false }),
        password: stringArg({ nullable: false }),
      },
      resolve: async (_parent, { name, email, password }, ctx) => {
        const hashedPassword = await hash(password, 10)
        const user = await ctx.photon.users.create({
          data: {
            name,
            email,
            password: hashedPassword,
          },