GraphQL is a query language for APIs and a runtime for fulfilling those queries with existing data, providing an alternative to the traditional RESTful style of web services. Here are some common questions about GraphQL—and how Brightspot helps solve them.
GraphQL is a query language—hence the "QL"—used for APIs, plus a runtime environment for fulfilling the respective queries with data. In short, a GraphQL query is designed to provide data from a server—or many servers—to a client-side application, whether that’s a website, app or some other connected device. Some of the main benefits to GraphQL queries include enabling the client to specify exactly the data it needs; aggregation of different data across multiple sources; and a self-describing type system that helps clients discover which data types and fields are accessible from the API (likewise, if a new field is added to a content type, for example, the GraphQL schema will automatically reflect it).
Everything you need to know about GraphQL
What is GraphQL?
What are the advantages of GraphQL?
- Bring your own data and code: Because GraphQL is simply a specification of how an API should work, there is no limitation on the client or server languages used to implement it. There are already several libraries written in a variety of languages to help you get started.
- Ask for what you need, and get exactly that: GraphQL is useful for content types, like Article, that contain numerous input fields. If one App needs two fields while another needs 10, you don’t need multiple API endpoints—the app that only needs two fields only gets two fields, and the same for the App that needs 10.
- Get many resources in a single request: When dealing with complex data relationships, REST APIs usually require loading data from multiple URLs to gather all data; GraphQL, on the other hand, get all the data your app requires in a single request.
- Describe what’s possible with a type system: GraphQL has a self-describing type system, enabling clients to easily discover what data types and fields are accessible from the API.
- Move faster with powerful developer tools: There are a myriad of development tools for writing and sending GraphQL queries. Because of GraphQL’s self-describing type system, you also benefit from features like auto-complete. Brightspot has actually embedded a developer tool called GraphiQL directly within our platform.
- Evolve your API without versions: GraphQL enables you to add new fields and deprecate old ones without impacting existing queries.
Does GraphQL make multiple requests to get data?
Does GraphQL force me to version my APIs?
Can you use your own data and code with GraphQL?
How do I write a GraphQL query?
Is GraphQL faster than REST?
How does Brightspot use GraphQL?
Like GraphQL, Brightspot has a self-describing type system, enabling clients to easily discover what data types and fields are accessible from the API. In Brightspot, for example, if a new field is added to a content type, the editorial user interface for that type also updates so that an editor can publish that new field. Our GraphQL implementation takes this functionality a step further by ensuring the GraphQL schema and user interface remain in sync. In other words, if a new field is added to a content type, it will automatically be reflected in the GraphQL schema that we generate.
GraphQL enables you to add new fields and deprecate old ones without impacting existing queries, and Brightspot translates deprecated data model types and fields directly into deprecated versions of their GraphQL counterparts, giving apps continuous access to new features from the platform.
Because GraphQL doesn’t limit the client or server languages that are used to implement it, it enables Brightspot to express our existing Brightspot type and view systems as GraphQL schemas.