GraphQL
A query language for your API
(and how we could use it in SilverStripe)
Motivation
Schema smarts are built in
Self-documenting API
Flexible backend integration
Multiple "resources" in a single call
Enables co-location of API query with view
Context: Server
A specification created by Facebook
Alternative to REST and SOAP
GraphQL servers in many languages (Node, PHP, etc)
Used by the new Github API, Pinterest, Shopify, ...
Interest by Drupal Core
Context: Client
Query Basics
Query Params
Query
Get exactly the data you need
Operates on types and a declarative schema
A type can be a scalar (Int) or complex (Film)
Nested Data
Types in PHP
Queries in PHP
Apollo Client
How about SilverStripe 4?
- Early stage investigation!
- Create a supported core API (easier than REST)
- View performance: Load config, current user, menu items, page tree, form schemas, ... - in one request
- Shift in dev thinking: Types and model constraints vs. getCMSFields()
Read more
GraphQL & SilverStripe
By chillu
GraphQL & SilverStripe
- 1,631