Skip to content

Instantly share code, notes, and snippets.

Avatar

gc-codesnippets

View GitHub Profile
View Untitled-1
import type { Context } from '../../';
type EditReleaseInput = {
data: {
releaseId: string,
title?: string,
},
};
export default async (
View Query.ts
import { idArg } from 'gqliteral'
import { prismaObjectType } from '../../../plugin'
import { prisma } from '../../generated/prisma-client'
export const Query = prismaObjectType('Query', t => {
t.prismaFields(['products', 'options', 'brands'])
t.field('otherProduct', 'Product', {
args: { id: idArg({ required: true }) },
resolve: (parent, { id }) => prisma.product({ id }),
View Post.ts
import { PostResolvers } from '../generated/graphqlgen'
import { prisma } from '../generated/prisma-client';
export const Post: PostResolvers.Type = {
...PostResolvers.defaultResolvers,
published: parent => parent.isPublished,
author: (parent, args, ctx) => ctx.db.post({ id: parent.id }).author(),
}
async function main() {
View Untitled-3
type MyCustomDef struct {
}
myRes := MyCustomDef{}
err := prisma.GraphQL(`{
users {
*
}
View Untitled-2
const query1 = `{
user(id: "$id") {
*
}
}`
type query1 = `{
user(id: "$id") {
*
}
}`
View datamodel.prisma
type User {
id: ID! @id
createdAt: DateTime!
updatedAt: DateTime!
firstName: String!
lastName: String!
email: String! @unique
password: String!
phone: String!
responseRate: Float
View graphqlgen.ts
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import { GraphQLResolveInfo } from 'graphql'
import { Context } from '../types'
import { PostNode } from './prisma-client'
import { UserNode } from './prisma-client'
export namespace QueryResolvers {
export const defaultResolvers = {}
View Mutation.js
async signup(parent, args, ctx, info) {
args.email = args.email.toLowerCase();
const password = await bcrypt.hash(args.password, 10);
const user = await ctx.db.mutation.createUser(
{
data: {
...args,
password,
permissions: { set: ['USER'] },
},
View prisma.graphql
# source: https://eu1.prisma.sh/nikolas/fduivg/dev
# timestamp: Sat May 12 2018 15:13:56 GMT+0200 (CEST)
type AggregateUser {
count: Int!
}
type BatchPayload {
"""The number of nodes that have been affected by the Batch operation."""
count: Long!
View prisma.graphql
# source: https://eu1.prisma.sh/nikolas/fduivg/dev
# timestamp: Sat May 12 2018 15:07:31 GMT+0200 (CEST)
type AggregateUser {
count: Int!
}
type BatchPayload {
"""The number of nodes that have been affected by the Batch operation."""
count: Long!
You can’t perform that action at this time.