All Articles

Day 45

We can create our own json end points, we can return any type of content we’d like.

Currently we need to install a new plugin, so off we go to the Wordpress admin plugin page. Search for “menus api v2” and then install that sucker.

Wordpress API plugin for menus

Lets pretend that we’ve installed said plugin, and have activated it. We will then need to tell Gatsby to look for the new routs. This is part of the Gatsby Gatsby-source-wordpress plugin.

Gatsby source wordpress menu

This screen shot is from our ‘gatsby-config.js’ file.

Once we add the menus into the included routes, we then need to restart our ‘gatsby develop’ cli. After that head over to GraphiQL and we should have some new top level items inside the explorer tab.

Graphiql menus query

TADA! We’ve got WP menus in GraphiQL! Okay okay, not ground breaking, this was done with all the hard work of whoever made the gatsby-wordpress plugin, and also the wordpress menus api plugin. But come one its super cool!