skip to Main Content
Screen Shot 2017 08 18 At 2.37.41 PM

WPGraphQL at WordCamp for Publishers

I hosted a workshop on “Content Syndication with the WP REST API and WPGraphQL” at the first ever WordCamp for Publishers on Friday, August 18, 2017 at the Denver Post building in beautiful Denver, CO.

Unfortunately, there was no video of the workshop, but the slides for the workshop are here: http://slides.com/jasonbahl-1/content-syndication

In the workshop, we covered how Digital First Media uses the WP REST API to syndicate millions of pieces of content per year across various WordPress and non-WordPress systems. We cover what we’ve learned about using REST, both positives and negatives.

We looked at many of the frustrations we have with working with REST and how GraphQL eases some of those frustrations. We looked at what GraphQL is, how it applies to WordPress as an application data graph, and how you can use GraphQL today in WordPress with the WPGraphQL plugin.

We walked through various features of GraphQL using the GraphiQL IDE. We explored the documentation that is generated for the GraphQL Schema using the GraphiQL documentation browser, then we wrote some queries. We queried for posts, posts with nested author objects and nested posts of that author. We looked at node queries, fragments, aliasing, variables and the cursor based pagination, even for data that’s typically not paginated, such as plugins and themes.

We then looked at examples of how to extend the WPGraphQL schema to add custom entry points into the queryable WordPress Application Data Graph. The examples we looked at for extending the Schema included:

  • adding a root field
  • adding a custom field to the “post” schema
  • registering a custom post type with WPGraphQL support
  • registering a custom taxonomy with WPGraphQL support
  • adding a custom field to a custom post type where the field can be queried and mutated
  • adding a root field that resolves data from an external system (return a random “dad joke” from icanhazdadjoke.com
  • Finally, we looked at registering a new Type to the GraphQL schema.
    • We registered a “Syndicated Books” type which resolves with data from external WPGraphQL enabled servers.

The examples we looked at all exist in a plugin here: https://github.com/wp-graphql/wordcamp-for-publishers-demo-extension

WPGraphQL is also going to be one of the projects for Contributor Day at WordCamp for Publishers on Saturday, August 19, 2017 at The Denver Post building. Even if you can’t make it to Denver, feel free to contribute remotely…you can submit issues, start working on pull requests for open issues, test the plugin on your own and write a blog post about it, or just simply star the GitHub repo and tweet about it.

NOTE: this post was written using Gutenberg v0.9.0

This Post Has One Comment

Leave a Reply

Share This
Back To Top