3
votes

I am trying to implement Smart Slider 3 Wordpress plugin into my Gatsby site. Up until now I've been using "gatsby-source-wordpress" plugin to query wordpress API endpoints using GraphQL. It works fine for posts/pages etc.

However, I am using Smart Slider REST API plugin to query this end point: /wp-json/smartslider3/v1/sliders/<slider-id>

I can see the response in the browser but I am not sure how to get the results using GraphiQL. Normally I was able to see new endpoints such as "allWordpressPost" etc.

In gatsby-source-wordpress plugin config there are included routes array that needs to be updated to be able to query new endpoints. Example:

"**/categories",
"**/posts",
"**/pages",
"**/media",

Therefore I've added this one "**/sliders", but seems like I can't get results to show in GraphiQL.

1

1 Answers

-1
votes

There are two ways I think you could do what you want:

  1. Query it directly client-side, ex. using window.fetch or wpapi
  2. Fork gatsby-source-wordpress and add in support for it yourself

By default, gatsby-source-wordpress supports the following plugins:

  • Custom Post Types, including those made with Custom Post Type UI WordPress plugin
  • Advanced Custom Fields + ACF to REST API
  • WP API MENUS
  • WPML REST API
  • WP REST Polylang
  • Yoast + WP API Yoast Meta

See: https://www.gatsbyjs.org/packages/gatsby-source-wordpress/#wordpress-plugins

So while you can include or exclude routes like comments or media, adding a route for other plugin APIs isn’t enough to make it work.

Similar to you, I ended up needing support for Gravity Forms, and forked gatsby-source-wordpress and added support for it myself. It’s doable and doesn’t necessarily require a huge amount of changes to the original plugin, but it is one more thing to maintain.

To try and deal with this in the future, I wrote up a proposal for adding a generic way to do this, so it would be possible to do exactly what you are after without needing to modify gatsby-source-wordpress. If you wouldn’t mind explaining what you are looking to do there too, it might help make it something that can be pursued in the future.

In the short-term, the above options are what’s available.