WordCamp 2019 - GraphQL in WordPress
July 20, 2019•181 words
https://ebeldev.github.io/graphql-in-wordpress/
(use down arrow too)
travel analogy
talking about REST API
- URL/wp-json/wp/v2/posts etc
- his point here is how many calls per endpoint REST takes
- risks:
- over-fetching - one endpoint gives you a lot of data you do not need
- under-fetching - one endpoint may not give you all you need
GraphQL - invented by Facebook basically
types of operation
- query
- mutation
- subscription
concepts:
nodes and edges
looks like data category ("posts") is the edge, and specific items (the actual posts) are the nodes
can define fragments
Software
WordExpress
WP-GraphQL -- https://www.wpgraphql.com/ the best one
- can be extended through hooks to add data to query or do other mutations
- not on version one yet, but still production ready
Frontend - Relay or Apollo (React though)
GraphiQL is the Postman for GraphQL
like/with https://playground.wpgraphql.com
GraphQL is always POST method
Gutenburg doesn't work with GraphQL or REST because it sucks. Adds a lot of code that the front end strips out, but the APIs won't
Server side resolvers being a core issue