Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 })
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);
import { mutationType } from 'nexus'
export const Mutation = mutationType({
definition(t) {
t.crud.createOneBlog()
t.crud.updateManyBlog()
},
})
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,
},
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', {
import { mutationType } from 'nexus'
export const Mutation = mutationType({
definition(t) {
t.string('ping', {
resolve: (_parent, _args, _context) => {
return 'pong'
},
})
},
})
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,
},
import { mutationType } from 'nexus'
export const Mutation = mutationType({
definition(t) {
t.string('ping', {
resolve: (_parent, _args, _context) => {
return 'pong'
},
})
},
})
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,
},