2020-02-26
2864
#graphql
Leonardo Losoviz
14569
Feb 26, 2020 ⋅ 10 min read

Code-first vs. schema-first development in GraphQL

Leonardo Losoviz Freelance developer and writer, with an ongoing quest to integrate innovative paradigms into existing PHP frameworks, and unify all of them into a single mental model.

Recent posts:

Understanding The Css Revert Layer Keyword, Part Of Css Cascade Layers

Understanding the CSS revert-layer keyword

In this article, we’ll explore CSS cascade layers — and, specifically, the revert-layer keyword — to help you refine your styling strategy.

Chimezie Innocent
Apr 24, 2024 ⋅ 6 min read
Exploring Nushell, A Rust Powered, Cross Platform Shell

Exploring Nushell, a Rust-powered, cross-platform shell

Nushell is a modern, performant, extensible shell built with Rust. Explore its pros, cons, and how to install and get started with it.

Oduah Chigozie
Apr 23, 2024 ⋅ 6 min read
Exploring Zed, A Newly Open Source Code Editor Written In Rust

Exploring Zed, an open source code editor written in Rust

The Zed code editor sets itself apart with its lightning-fast performance and cutting-edge collaborative features.

Nefe Emadamerho-Atori
Apr 22, 2024 ⋅ 7 min read
Implementing Infinite Scroll In Next Js With Server Actions

Implementing infinite scroll in Next.js with Server Actions

Infinite scrolling in Next.js no longer requires external libraries — Server Actions let us fetch initial data directly on the server.

Rahul Chhodde
Apr 19, 2024 ⋅ 10 min read
View all posts

4 Replies to "Code-first vs. schema-first development in GraphQL"

  1. Great read. I’ve worked on a Typescript/Rails schema first approach application. Now working on a restful Typescript/Laravel service and I’m missing the graphql schema. Im interested in trying a schema first approach. I hope it’ll be a tool allowing backend & frontend dev to collaborate more. The risk I see in a code first approach for speedy changes is the impact on all the integrated systems. Working in a code first approach is enabling the backend dev team to make all design decisions. Depending on your team this may be great. I think this ties into your first point about schemas being a communication tool. Theres one way I’ll find out 🙂

  2. “Im interested in trying a schema first approach. I hope it’ll be a tool allowing backend & frontend dev to collaborate more.”

    Have your tried playing with https://graphqleditor.com/ ? Looks like we might have what you are looking – live collabroation, schema libraries, visual representation as well as mock backend an some more features 🙂

  3. I did both, schema and code first approach (using NestJS). While it is easier to write the contract using the schema, it is much more convenient to then implement the resolvers using the code first approach. So to summarize, I first wrote the gql schema and then wrote the corresponding classes with decorators (code first), once done I dropped the schema.

  4. SDL First or Code First, you can still API First and Schema First. Using “Schema First” to name the act of using SDL to define your API/Schema First is poor naming. The real issue is, you can use SDL or Code to define your API/Schema First, choose the one that makes the most sense for you. The value of API/Schema First design principle is still valid and great practice regardless of it you choose SDL or Code First to is define the API.

Leave a Reply