Category: Announcements

  • WPGraphQL v2.0 is Here: What You Need to Know

    🚀 WPGraphQL v2.0.0 has officially been released! This is a major update that includes breaking changes, so if you’re using WPGraphQL in production, please review the details below to ensure a smooth upgrade.

    👉 View the Release on GitHub

    👉 Technical Update: Breaking Changes

    Why WPGraphQL v2.0?

    The primary motivation behind this release was upgrading WPGraphQL’s underlying GraphQL-PHP library. This upgrade unblocks us from shipping long-awaited features, such as the @oneOf directive, which will enable polymorphic input types. I’ve been talking about this since 2017 (GitHub comment here), and we’re finally in a position to make it happen!

    Additionally, this release encourages users to keep their server stack updated (PHP, WordPress, and related dependencies), leading to better performance, security, and long-term supportability.

    What’s Changed in WPGraphQL v2.0?

    🚨 Breaking Changes

    • Dropped support for PHP below 7.4
    • Dropped support for WordPress below 6.0
    • Error handling changes due to updates in graphql-php (see full details in the technical update post)

    🔥 New Features Over the Last Few Months

    While v2.0 itself doesn’t introduce major new features, recent releases included several improvements, all of which are now part of v2.0:

    • 🛠 New Extensions Page
    • 🖥 New CLI arguments in wp graphql generate
    • 📂 New fields on MediaItem for file and filePath
    • 🚨 New SemVer update checker (warns about breaking changes before updating)
    • New fields on EnqueuedAsset and EnqueuedScript

    🔗 See full release notes

    How to Upgrade to WPGraphQL v2.0

    For many users, no immediate action is required. However, if you’re running an outdated version of PHP or WordPress, you’ll need to upgrade your stack before updating WPGraphQL.

    • Step 1: Check your PHP version (must be 7.4+) and WordPress version (must be 6.0+)
    • Step 2: Test your site and any WPGraphQL custom extensions in a staging environment
    • Step 3: Follow the upgrade guide:

    👉 Technical Update: Breaking Changes

    👉 General WPGraphQL Upgrading Guide

    Where to Get Help?

    If you run into issues or have questions, we encourage you to reach out:

    💬 GitHub Issues – Report bugs or discuss issues

    💬 Join the WPGraphQL Discord – Connect with the community

    Special Thanks to Our Contributors

    This release would not have been possible without the incredible contributions of our community, especially Dovid Levine (@justlevine), who put in countless late nights and weekends helping maintain WPGraphQL and grow the headless WordPress ecosystem. 🎉

    What’s Next for WPGraphQL?

    With v2.0 released, we’re excited to move forward on several highly requested features, including:

    • 🛠 Custom Scalars
    • 🏗 @oneOf Directive (enabling polymorphic input types)
    • 📷 MediaItem Enhancements

    Upcoming Event: Ask Questions Live!

    I’ll be at the Headless WordPress Community Event on Monday, Feb 24, where you can ask questions about WPGraphQL v2.0 and beyond. This is hosted by the Headless WP Discord communityjoin here!


    🚀 We’re excited for the future of WPGraphQL, and we appreciate all of you who have helped make this possible.

    Happy querying!

  • WPGraphQL v2.0 Is Coming – Here’s What You Need to Know


    We’re excited to announce that WPGraphQL v2.0 is coming soon! This release brings key improvements such as better performance, stricter validation, and more flexibility for developers.

    This change introduces breaking changes that may affect your site or project.

    For technical details on breaking changes and developer recommendations, read the WPGraphQL v2.0 Technical Update Guide.

    Release Timeline


    We plan to release WPGraphQL v2.0 in the first week of February. This timing allows developers to prepare after the holiday and start-of-year rush.

    We’ve already opened a Beta Pull Request for testing. If you’d like to get an early look, test your projects against the beta and let us know your feedback!

    Breaking Changes


    WPGraphQL v2.0 will require PHP 7.4 or newer. Please ensure your server is running PHP 7.4 or newer before installing the new version.

    We’re upgrading WPGraphQL’s underlying GraphQL engine, graphql-php, from v14.11.10 to v15.8.1. This brings modern improvements but also introduces changes developers need to be aware of.

    We’ve written up a more technical guide that gets into more detail about the changes.

    What you should do

    • Check your PHP version: Ensure your site runs PHP 7.4+
    • Test in a staging environment: Test the update in a staging environment before applying it to your live site.
    • Check for compatibility: Ensure custom plugins or WPGraphQL extensions are compatible with v2.0.

    Looking Ahead

    While we work toward the final v2.0 release, we’ll continue adding new features and improvements. Some features currently in development include:

    • Extensions Page: An enhanced admin experience for managing WPGraphQL extensions.
    • Semantic Version Check: A system to reduce the risk of auto-updates causing breaking changes.

    Learn More & Stay Informed

    For developer-focused technical details, visit our WPGraphQL v2.0 Technical Update Guide. We’ll share more updates as the release approaches.

  • WPGraphQL v2.0 Technical Update & Breaking Changes

    WPGraphQL v2.0 is coming soon, featuring an upgrade to its underlying GraphQL engine, graphql-php, from v14.11.10 to v15.8.1.

    This upgrade brings better performance, stricter validation, and enhanced extensibility. However, it also introduces breaking changes that may impact developers extending WPGraphQL or maintaining custom plugins.

    This guide highlights technical changes, developer recommendations, and actions needed to prepare your projects.

    PHP Version Requirement:

    WPGraphQL v2.0 will require PHP 7.4 or newer, raising the minimum requirement from PHP 7.1.
    This change follows the adoption of graphql-php v15+, which also requires PHP 7.4+. Ensure your hosting environment is updated before testing the beta or upgrading to v2.0.

    By adopting the latest graphql-php, WPGraphQL inherits several breaking changes that may impact developers extending WPGraphQL. Below, we’ve highlighted the most important changes, though we also recommend reviewing the graphql-php release notes for more detail.

    Key Breaking Changes:

    Error Response Changes:

    • “category” field removal on errors: The “category” field has been removed from GraphQL error responses. If your application depends on this field, adjust your error-handling logic accordingly.
    • debug entries moved: graphql-php now places debug information under the extensions key of the error response. Ensure your application properly handles this structure.
    • serialization errors: Errors during leaf value serialization will now throw SerializationError, replacing previously thrown generic errors.
    • HTTP Status Code Change: For graphql requests made over HTTP using the POST method, if the request does not contain the Content-Type header specifying application/json, the response will have HTTP Status of 415 instead of 500. (see: https://github.com/wp-graphql/wp-graphql/pull/3291)

    Schema and Type Management Updates:

    • Topological Schema Ordering: graphql-php now orders schema definitions based on type dependencies and user-defined types. Be aware that this could change the output of introspection queries, especially when dynamically generating types.
    • Standard Type Enforcement: Overriding built-in GraphQL Types in the schema is no longer supported. Consider using custom types instead of overriding built-in types directly.

    Input and Enum Parsing Enhancements:

    • Lazy Loading for Input Objects and Enums: graphql-php now supports lazy-loading for input objects and enums. This can improve performance for schemas with complex, deeply nested types. Developers defining custom types should adjust type definitions if needed.

    Server and HTTP Behavior Adjustments:

    • Request Validation: Requests with invalid JSON will now trigger a RequestError instead of a generic error. This makes debugging request payload issues easier by returning clear error messages early in the request lifecycle.

    Recommended Actions:

    • Upgrade PHP: Ensure your environment runs PHP 7.4+ before updating WPGraphQL.
    • Review Error Handling: Update how your application handles GraphQL errors, including changes to the category field, the new location of debug entries and the HTTP Status Code change for invalid Content Type headers.
    • Test Plugin Compatibility: Test any custom plugins, WPGraphQL extensions, and GraphQL queries in a staging environment. Ensure compatibility before deploying to production.

    Resources and Links:

  • What’s next for WPGraphQL?

    On February 1, I announced that I was no longer employed at Gatsby, and stated a blog post would be coming soon.

    This is that blog post.

    TL;DR

    I’m joining WP Engine as a Principal Software Engineer where I will continue maintaining WPGraphQL and will contribute to other projects and initiatives centered around the goal of making WordPress the best headless CMS.

    Below I will expand a bit more on “Why WP Engine?”, but first, I’d like to take a moment to reflect on my time at Gatsby and acknowledge how important Gatsby is to the future of headless WordPress.

    WPGraphQL and Gatsby

    I am incredibly thankful for the opportunity I had to work at Gatsby to push forward WPGraphQL. Gatsby’s investment in WPGraphQL led to a lot of growth and maturation of the project

    Project Growth and Maturation

    I joined Gatsby in June 2019, and since then, WPGraphQL went from:

    Community Growth

    In addition to the growth and maturation of the core WPGraphQL plugin, the community around it has also grown.

    While I believe WPGraphQL would have seen growth in the community regardless, I believe we can attribute at least some of this growth to Gatsby’s investment in WPGraphQL. Gatsby’s investment in WPGraphQL signaled that it wasn’t just a hobby project, but was solving real problems for real users, and users should have confidence using it in their projects.

    When I joined Gatsby to work on WPGraphQL and collaborate with Tyler Barnes on WPGatsby and Gatsby’s new WordPress Source Plugin, the JavaScript ecosystem paid much more attention to using WordPress as a headless CMS, and the WordPress community got more comfortable using WordPress in ways they hadn’t before.

    Many agencies, developers and site owners now consider WPGraphQL an essential part of their stack.

    WordPress plugin developers have now created more than 30 WPGraphQL extensions, and there are now more than 1,500 people in the WPGraphQL Slack!

    Agencies such as Zeek Interactive, WebDev Studios, 10up and Postlight use and recommend WPGraphQL for headless WordPress projects.

    Websites such as gatsbyjs.com, qz.com, denverpost.com, diem.com, apollographql.com, bluehost.com, rudis.com and many more are using WPGraphQL in production.

    So, why leave Gatsby?

    Gatsby has been incredibly generous in funding open source developers to work on projects related to, but not part of Gatsby. For example, John Otander was working on MDX, Rikki Schulte was working on GraphiQL, and I was working on WPGraphQL.

    I was the last remaining of these engineers working primarily on other projects that tangentially, but not directly benefit Gatsby.

    WordPress is only one part of Gatsby’s story. Gatsby can work well with just about any data source. Some popular non-WordPress choices are Contentful, Sanity, DatoCMS, Shopify, among many others.

    The team I was part of was asking me to start transitioning to work more on other Gatsby integrations, such as Contentful and Shopify, and work less on WordPress and WPGraphQL. This doesn’t mean Gatsby was abandoning WordPress or WPGraphQL, just that I would need to spend less time on it and prioritize other things. There’s nothing wrong with this. There’s a lot of sound decision making to this when it comes to making Gatsby a sustainable business.

    I feel right now is a unique time in history where more investment in WordPress as a headless CMS can change the future of WordPress. I believe WordPress is now more respected as a viable option for a headless CMS and that with the momentum of WPGraphQL, technologies like Gatsby, NextJS, and others, I need to spend more time focusing on WPGraphQL and headless WordPress, and not less time.

    Fortunately for me, WP Engine is investing in the future of headless WordPress, and they see WPGraphQL as an important part of that future.

    As ironic as it may sound, I believe that my departure from Gatsby will actually strengthen the WordPress + Gatsby integration.

    Instead of partially focusing on the Gatsby side of the integration and partially focusing on the WordPress API side of the integration, this move will allow Gatsby to hire a backfill for my position to work specifically on the Gatsby side of integrations, and not have to worry about the WordPress server API side of things. This allows the team to narrow their focus and deliver higher quality code on the Gatsby side of the Gatsby + WP integration.

    I intend to continue working with Tyler Barnes and the Gatsby Integrations and Collaborations team to ensure that users of Gatsby + WPGraphQL feel supported and productive. Gatsby + WPGraphQL will continue to play a big role in the future of Headless WordPress, and I’m here for it.

    Why WP Engine?

    Serendipity, at least to some degree.

    Within a few weeks of having conversations about needing to start focusing less on WPGraphQL at Gatsby, I discovered that WP Engine was building a headless WordPress framework and was hiring engineers to focus on headless WordPress. The job description felt like it was describing me, almost perfectly. Serendipity.

    A few years ago, prior to my time at Gatsby I was interested in a position at WP Engine. But at the time there was a hard requirement for employees to be in Austin, TX. I have so many friends and family members in Denver that I have no plans to move if I don’t absolutely have to. WP Engine no longer requires employees to be in Austin, so I could now work for WP Engine without needing to move. Serendipity.

    Along with the serendipitous aligning of stars, WP Engine is a generally attractive employer.

    WP Engine is a leader in the WordPress space. I’ve trusted WP Engine to host many sites I’ve worked on over the last decade, including WPGraphQL.com and jasonbahl.com.

    While WP Engine’s primary business is managed WordPress hosting, it also invests in a lot of products and projects that make it easier for businesses to run their sites on WordPress.

    Projects such as LocalWP (that I gave a shout out to on Syntax.fm in Jul 2019) and Genesis Blocks are thriving under WP Engine, and I believe that WPGraphQL can continue to mature and thrive with WP Engine’s support.

    WP Engine’s investment in headless WordPress isn’t limited to me joining to continue working on WPGraphQL and other headless WordPress projects. There will be more hires and projects aimed at reducing the friction of using WordPress as a headless CMS, and allowing businesses to get started and move faster within that context.

    I believe that WP Engine’s investment in this space will allow WPGraphQL to grow and mature faster than ever before, as I will be part of a larger team working to make WordPress the best it can be.

    So, does WP Engine own WPGraphQL?

    Before my time at Gatsby, during my time at Gatsby and now as I transition to working at WP Engine, WPGraphQL has and will continue to be operated and maintained as a free, open-source community plugin benefitting anyone using WordPress.

    WP Engine pays my salary, and in exchange I will be maintaining WPGraphQL and helping grow the headless WordPress ecosystem, reducing friction in many different ways.

    What’s next for WPGraphQL?

    I can’t officially commit to any of these things quite yet, but some things I have on my radar to tackle in the near future include, but are not limited to:

    • Significant updates to WPGraphQL for Advanced Custom Fields
    • Updates to the GraphiQL IDE that ships with WPGraphQL (testing as public and authenticated user, for example)
    • Introduce new Custom Scalars (datetime, HTML, among others)
    • Add Support for Image Uploads
    • Update Schema surrounding Media
      • Introduce a MediaItem interface and different GraphQL Types for Image, Video, etc
    • New tooling to help developers move faster
      • Query / error logging
      • Breaking change notifications
      • Persisted Queries
      • Query Complexity configuration and analysis
    • WPGraphQL Subscriptions (real time updates when data changes)
    • Component library(s) using WPGraphQL Fragments
    • More tutorials, videos, blog posts about using WPGraphQL in various contexts

    I’m excited to get started at WP Engine and work on the next chapter of WPGraphQL and headless WordPress! I hope to have a more formal roadmap to discuss with the community in the near future, once I get settled as a WP Engine employee.

    I’m so thankful to the community that has embraced WPGraphQL. I feel so much love and appreciation from thousands of developers that are using, contributing to, and providing feedback for WPGraphQL.

    I’ve made many genuine friends from the WPGraphQL community and I am so thankful that this next chapter of my career allows me to continue working in this community.

  • Announcing WPGraphQL v1.0

    I’m so excited to announce WPGraphQL 1.0!

    If you’ve been using WPGraphQL for your side projects, but are waiting for the “stable” version, then this is it! You can use WPGraphQL in production with the confidence that it is secure, well documented, and supported full time and long term.

    If you’re new to the WPGraphQL community, you may ask yourself, “But WordPress already has the REST API. What’s different about using WPGraphQL?”

    Well, when you use WPGraphQL to turn your WordPress site into a GraphQL server, multiple resources can be fetched at the same time. And by design you get back the exact data you asked for, nothing more, nothing less. In addition to being easier to work with compared to the REST API, data loading with GraphQL is faster and more efficient. (Read more: “WPGraphQL vs. WP REST API“)

    If you are upgrading to 1.0 or another version, see the release notes for information on breaking changes and preparing your site. If you are new, start at the homepage and follow our step-by-step docs.

    In this post I want to talk about the journey to 1.0, why it took so long to get to 1.0, and a look at what’s next for WPGraphQL. But before diving into that, I want to also announce some other fun stuff that has also come to life along with this release.

    • WPGraphQL is now available on the WordPress.org repository
    • New WPGraphQL.com website
    • WPGraphQL Swag available on the Gatsby Swag Store

    WPGraphQL on WordPress.org

    The WordPress.org plugin repository has long been the default distribution mechanism for WordPress plugins. Prior to today, developers had to install WPGraphQL using Composer and installing from packagist, or by downloading from Github.

    Now, users can install WPGraphQL directly from WordPress.org’s plugin directory.

    We believe that distributing WPGraphQL on the WordPress.org plugin repository should make it easier for users to find and install and keep updated.

    New WPGraphQL.com website

    WPGraphQL.com has been re-built from the ground up.

    Before today, WPGraphQL had 2 primary domains:

    • WPGraphQL.com, a “traditional” WordPress site using WordPress as the CMS and the theme layer
    • docs.wpgraphql.com, a Gatsby site using Markdown files in a Github repository for the content.

    Now, instead of splitting some content in Markdown files on Github and some content in WordPress, WPGraphQL.com now uses WordPress as the CMS for all content, and and has a Gatsby front-end powered by the new Gatsby Source WordPress plugin, WPGatsby and of course WPGraphQL.

    We’ll be releasing tutorials and videos in the coming weeks and months walking through how various parts of the site were created to provide inspiration for you to build great things with this stack as well, but for now you can draw inspiration from the repository this site is built from: https://github.com/wp-graphql/wpgraphql.com

    WPGraphQL Swag

    Now, possibly the most exciting thing about this whole announcement, is the fact that you can now get WPGraphQL Swag from the Gatsby swag store.

    The Journey to 1.0

    WPGraphQL was started in November 2016 (with no commit message ???? ) and has come a long way in that time.

    Screenshot of the “Initial Commit” in Github

    By the end of 2017 the codebase was pretty robust and provided a Schema to interact with many parts of WordPress. Posts, Pages, Custom Post Types, Tags, Categories, Custom Taxonomies, Comments and Nav Menus.

    Qz.com was the first site to go to production with WPGraphQL, even before I was using it in production! A few years later and they are still running on WPGraphQL! You can learn more about the early days of their stack from this presentation from December 2017.

    In early 2018, my team took WPGraphQL into production on a network of 54 large WordPress sites. WPGraphQL was used as a syndication engine for our network of newspapers. Unlike most GraphQL users, we didn’t initially have a JavaScript or native mobile UI that was using GraphQL, we had PHP WordPress servers syndicating content and GraphQL solved a lot of pain points we had been facing when using REST.

    By the end of 2018, more than 100 sites were using WPGraphQL in some way.

    Now, WPGraphQL seems to be running all over the place!

    This is a non-comprehensive list of sites using WPGraphQL in production in some way:

    According to Packagist.org as of June 30, 2020 there were nearly 50,000 installs of WPGraphQL in the wild, and as of November 2020 Packagist reports 71,573 installs.

    In 2019 Credit Karma paid for a security audit on the plugin and all reported issues were resolved.

    It’s safe to say, WPGraphQL is production ready!

    So, why the wait for 1.0?

    So, if WPGraphQL has been production ready for such a long time, why is is still not 1.0?

    Breaking Changes & WordPress

    The WordPress ecosystem has a strong commitment to backward compatibility. This means that once functionality is introduced to a WordPress plugin, it often sticks around forever.

    With that in mind, before tagging WPGraphQL 1.0, I wanted so badly to be at a place with the codebase & Schema that I could no longer predict anymore breaking changes.

    I wanted the GraphQL Schema to be “perfect” before tagging it 1.0, because I knew that whatever would be in the WPGraphQL Schema at 1.0 would need to remain in the Schema forever. The WordPress community is used to things working the same way “forever” and I wanted to play along.

    Breaking Changes & WPGraphQL

    The reality is that for software to get better, sometimes it needs to make breaking changes.

    WPGraphQL will never be perfect, and it will need to occasionally break to make things better.

    For example, when the GraphQL Specification updates to include Input Unions or Interfaces that can implement other Interfaces, WPGraphQL will need to break to keep up with the GraphQL Specification.

    There would be no way to keep GraphQL as we know it today and take advantage of tomorrow’s GraphQL Spec without breaking.

    WPGraphQL turning 1.0 isn’t a statement that there will never be breaking changes, instead it’s a statement of stability and long term support.

    So, how will breaking changes be handled in a post-1.0 world?

    Semantic Versioning

    WPGraphQL has been following Semver practices for a few years. We will continue to follow Semver and let version numbers communicate meaning. The summary of Semver versioning is as follows:

    • MAJOR version when you make incompatible API changes,
    • MINOR version when you add functionality in a backwards compatible manner, and
    • PATCH version when you make backwards compatible bug fixes.

    You can read more about the details of Semver at semver.org

    Seamless Upgrade Paths

    When WPGraphQL needs to make breaking changes to the Schema, there are sometimes ways to make the changes and allow for seamless upgrade paths.

    What that means, is that WPGraphQL can introduce a new feature while keeping the old feature. For example, let’s say the following (hypothetical) query were in the Schema and the author field returned the name of the Author:

    {
      book {
        author
      }
    }
    

    Let’s say we realized that the Author should actually be a one-to-one connection to an object with edge space for relational context. We would want to change the schema to allow for the following query instead.

    {
      book {
         author {
             node {
                 name
              }
         }
      }
    }
    

    If WPGraphQL made this change, any consumer application would break.

    So, what we can do is introduce the new feature like so:

    {
       book {
         author
         authoredBy {
            node {
                name
            }
         }
       }
    }
    

    We could introduce the new feature as a new field name authoredBy which returns the data in the shape we want.

    The end goal, however, is to have the author field return the author.node.name shape.

    So, with both fields (author and authoredBy) co-existing on the server, consumer applications could make use of GraphQL Aliases and update their code from:

    {
      book {
         author
      }
    }
    

    to:

    {
       book {
          author: authoredBy { # Consumer uses an alias to prepare for the upcoming change to the author field
              node {
                 name
              }
          }
       }
    }
    

    Once consumers have updated their code, the server could then update once more to flip the old field name to the new shape. So, the next release would have the following possible:

    {
       book {
          author {
             node {
                 name
              }
          }
          authoredBy {
            node {
                name
            }
         }
       }
    }
    

    So now, the old field author no longer returns the name directly, it now returns the new nested node/name shape. The client is using an alias to query the authoredBy field, so now the consumer should update their code from:

    {
       book {
          author: authoredBy { # Consumer uses an alias to prepare for the upcoming change to the author field
              node {
                 name
              }
          }
       }
    }
    

    to:

    {
       book {
          author
              node {
                 name
              }
          }
       }
    }
    

    Now, the consumer application is using the new shape of data and the old author field, and one more release would be able to remove the temporary authoredBy field that was used for seamless upgrades.

  • WPGraphiQL IDE v1.0.0 with GraphQL Explorer

    The GraphiQL IDE is an incredibly helpful tool when using GraphQL. WPGraphiQL has been the go-to GraphiQL IDE for use with WPGraphQL, and today we’ve released v1.0.0 of the WPGraphiQL IDE, now with the AMAZING GraphQL Explorer feature, courtesy of the fine folks at OneGraph.com.

  • Re-introducing WPGraphQL for ACF

    TL;DR

    Starting today, WPGraphQL for Advanced Custom Fields is FREE!

    Some Context

    In April 2019, I released the WPGraphQL for Advanced Custom Fields plugin as a paid plugin in an attempt to generate enough revenue to one day be able to work on WPGraphQL full-time.

    I want to thank everyone that purchased a license and helped me grow the community. The purchases proved that this is an important plugin with an audience, and the revenue from the purchases have allowed me to spend time working on additional features, bug fixes, and interact with users in Slack, Twitter and other communication channels over the past few months. It’s clear that a big part of the future of WordPress headless, and WPGraphQL is a big part of that future.

    New Opportunity

    As you may have heard on Syntax.fm or WPTavern, I have been blessed with the opportunity to join the Gatsby team, where I get to spend my time working on WPGraphQL and its immediate ecosystem, including plugins like WPGraphQL for Advanced Custom Fields.

    Now that I have the opportunity to work on the WPGraphQL ecosystem full-time, the Gatsby team and I believe it’s best for the community to make the WPGraphQL for Advanced Custom Fields FREE, starting today.

    The plugin is now freely available on Github: https://github.com/wp-graphql/wp-graphql-acf. The plugin will also be submitted to packagist.org which will allow the plugin to be more easily included in projects using Composer.

    Support and Updates

    WPGraphQL for Advanced Custom Fields will continue to get the same care and support I’ve provided since launch, but even better as I now have more time to focus on the WPGraphQL ecosystem. 

    • Github: If you run into issues or have ideas for feature requests, I kindly ask that you open issues on the Github repository.
    • Slack: If you have general questions, the WPGraphQL Slack workspace is a great place to seek support. If you’re not in the Slack workspace already, you can join here
    • Spectrum: WPGraphqL has an online community on Spectrum, which allows publicly visible and indexable async communication. You can visit the WPGraphQL Spectrum community here.

    WPGraphQL and Gatsby

    The Gatsby team and I are excited to invest more time into adding more features to WPGraphQL to benefit the entire headless WordPress & modern Javascript communities. 

    Whether you’re using React or Vue, Next or Nuxt, Create React App or Gatsby, or anything else, we want WPGraphQL to be a great experience for all.

    Of course, we believe in many cases there will be benefits of using WPGraphQL with Gatsby, and we’d love it if you gave Gatsby a try, but ultimately we want you to build great experience for your users using the tools you enjoy.

    Thank you for your support and I’m looking forward to a bright future for GraphQL and WordPress.

    Thanks!

    Jason Bahl
    Creator / Maintainer, WPGraphQL

  • WPGraphQL for FacetWP

    I am pleased to announce the beta release of my FacetWP integration plugin for WPGraphQL. 

    The main functionality was written quickly in late 2018 to fill a need to provide client-side access to FacetWP’s index and filtering functionality via WPGraphQL. As a proof-of-concept it worked exactly as needed. It was a lot less effort to create this plugin than it would have been to roll my own facet indexing module. 

    Recently, I have had some down time between changing jobs and have been able to refactor and clean up the original code into something more usable by the larger WordPress and WPGraphQL community. If you have the need to expose the functionality of FacetWP via the GraphQL schema, I hope you find this plugin helpful!

    Usage

    To register WP Post Type(s) to be added to the schema, simply use the facet query registration function register_graphql_facet_type() as follows: 

    // Register facet for Posts 
    register_graphql_facet_type( 'post' ); // replace post with your CPT name as necessary 

    Prerequisites: To use the plugin users must have already configured at least one facet in FacetWP and configured WPGraphQL.

    Input

    The plugin uses reflection to expose all configured facets are available for querying. Each facet is added as an input argument to the query. 

    Different facet types have unique inputs (eg a Slider has a min and max while Checkboxes is a simple array of strings). 

    Given the post registration above the query variables might look something like this: 

    const variables = { 
        after: '', // Use endCursor for paging 
        query: { 
            // example facet filtered on post ID 
            facet_name: [1, 2, 3], 
            // sample facet filtered on taxonomy term 
            term_facet_name: ['category-1', 'category-3'], 
        }, 
        orderBy: { 
            field: 'DATE', 
            order: 'DESC', 
        }, 
    } 

    Payload

    Registering a facet type will result in a new field on the Root Query. The field name is determined by the type to be queried. 

    The payload of the new facet field includes: 

    • facets: The returned facet information
    • type connection: A WPGraphQL connection to the post type query 

    Given the post registration earlier, the query and response payload might look like this: 

    postFacet(where: {status: PUBLISH, query: $query}) { 
      facets { 
        selected 
        name 
        label 
        choices { 
          value 
          label 
          count 
        } 
      } 
      posts(first: 10, after: $after, where: {search: $search, orderby: $orderBy}) { 
        pageInfo { 
          hasNextPage 
          endCursor 
        } 
        nodes { 
          title 
          excerpt 
        } 
      } 
    } 

    Facets

    This payload includes all information relating to the queried facets and input variables. Available choices (including available count), settings and other relevant information are exposed in this field. 

    Connection

    This payload is a connection to the configured post type. It accepts all the pertinent GraphQL arguments (paging, sorting etc). 

    This connection only returns posts that match the facet filter. 

    Conclusion 

    This plugin provides users of WPGraphQL with access to an established and popular WordPress plugin for server-side filtering; FacetWP. I hope the WordPress community finds it helpful. It certainly was a great time saver for our project. 

    Disclaimer and limitations: I have thoroughly tested Checkbox, fSelect and Radio facet types, as these are used in my app. There is provisional support for all other facet types, however these are not fully tested. As with any open source project, a detailed issue (or better yet a pull request) would be appreciated. 

    Please see GitHub for further documentation and commentary.

  • WPGraphQL featured on Syntax.fm

    Today, I had the pleasure of being featured on the Syntax.fm podcast with hosts Wes Bos and Scott Tolinsky.

    In this episode we discussed how to use GraphQL with WordPress using the WPGraphQL plugin. I also announced that I’ve joined the Gatsby team to work on WPGraphQL an its immediate ecosystem full-tiime.

    Below is the recording of the podcast.

  • WPGraphQL for ACF is here!

    Many folks using WPGraphQL have asked about how to use GraphQL with their ACF data. The answer has typically been to manually map their ACF fields to the GraphQL schema using functions like register_graphql_field and register_graphql_object_type. For a few fields, this isn’t much of an issue, but when you have dozens of fields, this gets very tedious.

    Today, we’ve released WPGraphQL for Advanced Custom Fields, which automatically adds your Advanced Custom Fields to your WPGraphQL Schema.

    You can learn more about the plugin here: https://www.wpgraphql.com/acf

    Very excited to see what the community builds with this. If you have any questions, please contact us.