Skip to content

Instantly share code, notes, and snippets.

View nikolasburk's full-sized avatar
😑

Nikolas nikolasburk

😑
View GitHub Profile
// apollo-server
const server = new ApolloServer({ schema })
server.listen({ port: 4000 }, () =>
console.log(`Server ready at http://localhost:4000`),
)
// graphql-yoga
const server = new GraphQLServer({ schema })
server.start(() => {
console.log(`Server ready at http://localhost:4000`)
})

Data model vs Prisma database schema

When starting out with GraphQL and Prisma, the amount of .graphql-files you're working with can be confusing. Yet, it's crucial to understand what the role of each of them is.

Looking only at Prisma, there are two .graphql-files that are relevant:

  • The data model containing the model definitions for your service's APIs, typically called datamodel.graphql.
  • The Prisma database schema defining the actual CRUD/realtime operations of the service's API, typically called prisma.graphql.

Personal response to this Twitter thread

I've just been taking a hard look at prisma. and to me it seems like crutch, rather than a solution. my guess is that it works for very simple stuff, but it's not usable for anything more or less "serious".

There are many serious developers and larger companies using Prisma in production today, such as adidas, HyreCar (recently IPOed) or Labelbox (just raised 10mio series A). We have no doubt that Prisma can be used for "serious" applications!

The docs are basically marketing material. "under the hood" doc provides no information I was hoping to find at least there. starting from "how queries are optimized"? some tutorial says there's a dataloader, but that's about it.

You're definitely right that our docs are lacking behind at the moment! We are working on the nex

type Post {
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
title: String!
published: Boolean! @default(value: "false")
author: User
comments: [Comment!]!
}
### This file was autogenerated by Nexus 0.9.9
### Do not make changes to this file directly
type AggregatePost {
count: Int!
}
type AggregateUser {
count: Int!

Get Your Own Prisma Client Explorer

This project uses a hosted database that has writes disabled. Follow these steps to set up your own demo database that lets you perform database writes:

1. Fork the CodeSandbox

To get your own version of this sandbox, click the Fork button in the top-left corner (then wait until the embedded browser in the new Sandbox ):

Get Your Own Prisma Client Explorer

To get your own Prisma client explorer on CodeSandbox that allows for database writes, you need to perform the following steps:

1. Fork the CodeSandbox

2. Open new Terminal tab

@nikolasburk
nikolasburk / stitching.graphql
Last active June 29, 2018 12:07
stitching.graphql
query myMenu {
menu {
burger {
bun
cheese
patty
}
salad {
romaine
tomato
import { GraphQLServer } from 'graphql-yoga'
const typeDefs = `
type Query {
hello: String!
}
`
const resolvers = {
Query: {