Design a GraphQL Schema So Good, It'll Make REST APIs Cry
Designing a robust GraphQL schema is essential for adaptable APIs. The article outlines steps using a TechTalent platform example, emphasizing core types, relationships, operations, and best practices for structured development.
Read original articleDesigning a robust GraphQL schema is crucial for creating adaptable APIs. The schema acts as a contract between backend and frontend teams, ensuring structured development. Using a hypothetical TechTalent platform as an example, the article outlines steps to design a GraphQL schema. It starts with defining core types like Company and Candidate, then models relationships and plans query and mutation operations. Authentication, pagination, real-time updates, custom scalars, interfaces, and documentation are also discussed. Best practices include starting with UI considerations, clear naming conventions, leveraging GraphQL features, planning for changes, optimizing performance, ensuring security, validating input, providing meaningful errors, monitoring usage, and reducing duplication. The iterative process of schema design is emphasized, highlighting the need for thoughtful planning to accommodate evolving application needs. By following these principles, developers can create maintainable GraphQL schemas that meet specific use cases effectively.
Related
Serving a billion web requests with boring code
The author shares insights from redesigning the Medicare Plan Compare website for the US government, focusing on stability and simplicity using technologies like Postgres, Golang, and React. Collaboration and dedication were key to success.
Declaratively build your APIs in TypeScript and Python
Metatype is a declarative API development platform focusing on creating reliable, modular components. It offers Typegraphs for composing APIs, Typegate for GraphQL/REST, and Meta CLI for live reloading. Users can access documentation and a quick start guide on the Metatype GitHub repository.
Remix is better than GraphQL
Remix and GraphQL are compared for data loading in applications. Remix offers type-safe data fetching with loaders, while GraphQL allows selective data queries but may face challenges with authorization and performance. Remix is favored for simpler authorization and is recommended for full-stack teams, while GraphQL suits separating backend and frontend teams with expertise.
Devs need system design tools, not diagramming tools
The New Stack website provides resources on software engineering, emphasizing system design tools for developers. It covers various topics like AI, security, and trends in software development, offering insights and resources for the community.
Eight Years of GraphQL
A critique of GraphQL's viability after 8 years raised concerns about security, performance, and maintainability. Emphasized the importance of persisted queries and understanding trade-offs before adoption.
In terms of destructive power to the software industry it's almost on the level of OOP. The one positive seems to be that engineers are catching on to this fact at a much faster rate(5-10 years instead of 10-20). However, unfortunately, GraphQL sits in a position of the software stack that's very difficult to swap out, so even when engineers do realize the damage, they are stuck with it unless they change jobs. Extremely frustrating. Yes I'm one of those stuck engineers.
And then you have articles like this still touting it as some kind of rainbow miracle.
I'm not even going to list the countless issues you will be encountering by committing to this tech, or the fact that the mitigation of those issues will result in essentially gravitating back to REST with several unnecessary and convoluted translation layers. Instead, I invite you to research how Meta, the company behind the technology, is using the technology in practice. Just open Facebook and look at the /graphql queries, or read some articles by Meta engineers.
I love the section on documentation: https://tailcall.run/blog/graphql-schema/#step-10-document-y...
The most useless documentation is followed by:
> Good documentation helps both your team and API consumers understand the purpose and usage of each type and field.
May be me though
We mainly use python and we're probably stuck with MSSQL. I've built simple stuff with FastAPI and even Flask before but nothing serious.
As a strong DDD advocate, the core idea of GraphQL makes me scream on the inside. It turns explicit FE/BE contracts into implicit ones and you lose out on valuable domain insight.
However, if you have a purely read-only use-case with no way back to the BE, then maybe it's a nice tool actually? Especially since Data Guys often lament not having access to the full DB and making specific endpoints for them get tedious really quickly.
It requires a deep understanding of many ideas and people aren't able to grasp what it means and what it solves (hint: it is not meant to solve schema design). It ends up being a problem instead of a solution.
GraphQL (which is built upon REST, but has a simpler conceptual load) is way better for common everyday webdevelopment.
Everything you described from posting jobs to searching candidates are dead simple POST and GET requests. No need to overcomplicate things…
Related
Serving a billion web requests with boring code
The author shares insights from redesigning the Medicare Plan Compare website for the US government, focusing on stability and simplicity using technologies like Postgres, Golang, and React. Collaboration and dedication were key to success.
Declaratively build your APIs in TypeScript and Python
Metatype is a declarative API development platform focusing on creating reliable, modular components. It offers Typegraphs for composing APIs, Typegate for GraphQL/REST, and Meta CLI for live reloading. Users can access documentation and a quick start guide on the Metatype GitHub repository.
Remix is better than GraphQL
Remix and GraphQL are compared for data loading in applications. Remix offers type-safe data fetching with loaders, while GraphQL allows selective data queries but may face challenges with authorization and performance. Remix is favored for simpler authorization and is recommended for full-stack teams, while GraphQL suits separating backend and frontend teams with expertise.
Devs need system design tools, not diagramming tools
The New Stack website provides resources on software engineering, emphasizing system design tools for developers. It covers various topics like AI, security, and trends in software development, offering insights and resources for the community.
Eight Years of GraphQL
A critique of GraphQL's viability after 8 years raised concerns about security, performance, and maintainability. Emphasized the importance of persisted queries and understanding trade-offs before adoption.