@ryanchenkie
GraphQL Dev Rel at Prisma
@ryanchenkie
@prisma
Most often, developers start with an SDL-first approach
Easy to get going
Most examples show SDL-first but it's not the only way
@ryanchenkie
@prisma
type Post {
id: ID!
title: String!
body: String!
}
type Query {
posts: [Post]
}
@ryanchenkie
@prisma
const resolvers = {
Query: {
posts: (_, args, context, info) => {
return context.db.posts.findMany()
}
}
}
@ryanchenkie
@prisma
Schema and Resolvers in different places on the filesystem, modularization challenges
Need to context switch between Schema and Resolvers
Need for tooling
@ryanchenkie
@prisma
const Post = objectType({
name: 'Post',
definition(t) {
t.id('id');
t.string('title');
t.string('body');
}
});
@ryanchenkie
@prisma
const Query = queryType({
definition(t) {
t.list.field('posts', {
type: 'Post',
resolve(_, args, context, info) {
return context.db.post.findMany();
}
});
}
});
@ryanchenkie
@prisma
Everything is in one place, no need for extra modularization and context switching
No need for extra tooling
Codegen produces artifacts like SDL and types
Easy to move quickly and collaborate
@ryanchenkie
@prisma
@ryanchenkie
bit.ly/graphql-galaxy