Skip to content

Instantly share code, notes, and snippets.

query {
users {
id
name
}
}
mutation {
createUser(name: "Alice") {
id
}
}
const userBinding = require('graphql-binding-users')
// Retrieve all `User`s
userBinding.query.users({}, `{ id name }`)
.then(users => console.log(`Retrieved all users: ${users}`))
const userBinding = require('graphql-binding-users')
// Create a new `User`
userBinding.mutation
.createUser(
{
name: 'Alice',
},
`{ id }`,
)
type User {
id: ID!
name: String
}
type Query {
users: [User!]!
}
type Mutation {
type User @pgTable(name: "users") {
id: ID! @unique
isAdmin: Boolean! @default(value: false)
posts: [Post!]!
comments: [Comment!]!
}
type Post @pgTable(name: "posts") {
id: ID! @unique
title: String!
version: '3'
services:
prisma:
image: prismagraphql/prisma
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
const typeDefs = `
type Query {
hello(name: String): String
}
`
const resolvers = {
Query: {
hello: (_, args) => `Hello ${args.name || 'World'}!`,
},
import { makeBindingClass } from 'graphql-binding'
import helloSchema from './helloSchema'
export default const HelloBinding = makeBindingClass(helloSchema)
const binding = new HelloBinding()
binding.query.hello({ name: 'Alice' })