By Kiersten Mounce, on Jun 20, 2019

Everything you need to know about GraphQL

Over the past few years, we’ve talked a lot about GraphQL’s impact on the way digital products are built. We released our own GraphQL Content API at the end of 2018, and our users agree: GraphQL makes everyone’s life easier — from content creators to backend engineers.

GraphQL’s strength is its flexibility and specificity. In a single query, you can ask for exactly what you want — regardless of content type — with the help of strongly-typed schema. Applications run faster because compact queries return small responses without unnecessary response data. Developers are happy because this reduces the need for response parsing. Editors, writers, and other users are happy because it allows the whole organization to work in a more agile way and everyone can quickly access content from multiple sources.

Want to learn more? Here’s a roundup of articles from our blog that cover the benefits, creative uses, and future of GraphQL at Contentful and in the digital field.

GraphQL and optimizing for developer experience We’ve found that the developers who use Contentful learn quickly, stick with their existing workflow and set up, appreciate tools that let them code as fast as possible, and dislike redundancies. These preferences align with GraphQL. It can be written in any language as long as it delivers the payload as expected. It delivers compact, customized responses for fields in the same order requested, which makes them easier to parse with fewer redundancies. You can build schemas any way you want, and introspection allows the user to see the entire GraphQL schema. Graph QL API gives developers using Contentful everything they need to work happily and efficiently.

Writing GraphQL queries in native Ruby = Love GraphQL improves the lives of both frontend and backend developers. For those working on the backend, we created GQLi, a GraphQL consumer domain-specific language that allows you to write GraphQL queries in native Ruby. GQLi provides a better way to interface with GraphQL APIs in your Ruby applications by enabling you to work with the entirety of the Ruby language.

GraphQL and Serverless: where cloud computing is heading Contentful combines the powers of GraphQL and serverless, two developments changing the digital world. Because serverless technologies run code without provisioning servers, they are effective means of distributing serverless code (such as object types defined through GraphQL, which can be queried and modified). This means that schema stitchings and transformation will become more common (see Combining APIs using GraphQL schema stitching: Part 1 and Part 2) and influence how we both build and distribute software.

How ASTs power the GraphQL schema handling The foundation of any GraphQL is an abstract syntax tree (AST). ASTs are used on the server side to deal with schema definitions and parsing of the actual GraphQL query. Learn how ASTs make GraphQL APIs so powerful and the best practices for working with them.

Implementing GraphQL with a REST API The team over at Apollo is working on a small library called apollo-link-rest for developers who want to test GraphQL on a project without having to integrate the backend with a GraphQL server. If you aren’t ready to take the GraphQL leap, this article shows you how to use apollo-link-rest and implement a GraphQL client that talks to REST endpoints.

3 Methods to Resolve GraphQL Endpoints GraphQL offers many possibilities when it comes to designing the most appropriate architecture. But deciding which architecture to choose is often the most critical decision. Implement a REST layer? Direct data access? What about stitching together several APIs? The best answers to these questions depend on understanding organizational boundaries and planning for future growth.

Launching Eviction Free NYC using GatsbyJS, GraphQL and Contentful In less than one month, Eviction Free NYC developed a static, mobile-first site with localization capabilities to serve tenants in New York City, thanks to the straightforward pipeline established by GraphQL API. Eviction Free NYC’s story is one of many that demonstrate why GraphQL might be your new best friend.

Thanks to its flexibility, GraphQL is paving the road to more agile organizations to work more efficiently with a broader scope of development projects. GraphQL improves the lives of content creators. It’s now possible to assemble content from multiple sources and deliver it to exact frontend requirements — all with a single API call.

Conclusion

We have even more to say about GraphQL and our Content API. Our tutorials and documentation provide a comprehensive look at the API, its strengths and ways of using it. Even better: explore it yourself with a Contenful demo.

Kiersten Mounce
Berlin, Germany

Technical writer at Contentful and API obsessed. Kiersten collaborates with Contentful's makers and users to write informative and accessible articles that support the Contentful community. She’s happiest when helping others talk about their Contentful-powered dream projects.