wp-graphql

GraphQL API for WordPress

GPL-3.0 License

Downloads
304.7K
Stars
3.6K
Committers
154

Bot releases are hidden (Show)

wp-graphql - v1.6.7

Published by jasonbahl almost 3 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/wp-graphql/wp-graphql/compare/v1.6.6...v1.6.7

wp-graphql - v1.6.6

Published by jasonbahl about 3 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/wp-graphql/wp-graphql/compare/v1.6.5...v1.6.6

wp-graphql - v1.6.5

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2081): Set is_graphql_request earlier in Request.php. Thanks @jordanmaslyn!
  • (#2085): Bump codeception from 4.1.21 to 4.1.22

New Features

  • (#2076): Add $graphiql global variable to allow extensions the ability to more easily remove hooks/filters from the class.
wp-graphql - v1.6.4

Published by jasonbahl about 3 years ago

1.6.4

Chores / Bugfixes

  • (#2076): Updates WPGraphiQL IDE to use latest react, GraphiQL and other dependencies.

New Features

  • (#2076): WPGraphiQL IDE now resizes when the browser window is resized.
wp-graphql - v1.6.3

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2064): Fixes bug where using asQuery argument could return an error instead of a null when the ID passed could not be previewed.
  • (#2072): Fixes bug (regression with 1.6) where Object Types for page templates were not properly loading in the Schema after Lazy Loading was introduced in 1.6.
  • (#2059): Update typos and links in docs. Thanks @nicolnt!
  • (#2058): Fixes bug in the filter_post_meta_for_previews was causing PHP warnings. Thanks @zolon4!
wp-graphql - v1.6.2

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2051): Fixes a bug where Types that share the same name as a PHP function (ex: Header / header()) would try and call the function when loading the Type. See (Issue #2047)
  • (#2055): Fixes a bug where Connections registered from Types were adding connections to the registry too late causing some queries to fail. See Issue (Issue #2054)
wp-graphql - v1.6.1

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2043): Fixes a regression with GraphQL Request Execution that was causing Gatsby and some other CI tools to fail builds.
wp-graphql - v1.5.9

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2043): Fixes a regression with GraphQL Request Execution that was causing Gatsby and some other CI tools to fail builds.
wp-graphql - v1.6.0

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2000): This fixes an issue where all Types of the Schema were loaded for each GraphQL request. Now only the types required to fulfill the request are loaded on each request. Thanks @chriszarate!
  • (#2031): This fixes a performance issue in the WPGraphQL model layer where determining whether a User is a published author was generating expensive MySQL queries on sites with a lot of users and a lot of content. Thanks @chriszarate!

Upgrading

If you have a codebase that extends WPGraphQL the tips below will help you upgrade.

Unit Tests / Clearing the Schema

Because v1.6.0 now fully supports Lazy Loading of the Schema, you might need to update your tests to Clear the Schema during the setUp() and tearDown() of your tests.

Lazy loading will load only the Types of the schema that are asked for, and if you have multiple queries in your tests, the 2nd test will attempt to run with the already generated Schema which might not include all the Types you need for the 2nd test.

By using \WPGraphQL::clear_schema() in your setUp() and tearDown() it resets the Schema so that each test can lazily load the Schema that it needs to fulfill the individual request.

You can see this update in the WPEngine Atlas Content Modeler plugin: https://github.com/wpengine/atlas-content-modeler/pull/212/files

Eager Type Loading

Any Type that is in the Schema but only referenced within a Union or Interface should be updated to include eagerlyLoadType => true in the Type registration.

In the WPGraphQL core codebase, there are 2 Types that are never directly referenced, just referenced as part of Interfaces:

  • DefaultTemplate
  • CommentAuthor

You can see these 2 types were set to be eagerly loaded like so:

This ensures that the GraphQL Schema can load these Types even though they aren't asked for directly.


Performance Improvements

This Release has a focus on performance improvements.

Lazy Loading Schema

GraphQL-PHP, the GraphQL library used under the hood, supports "Lazy Loading" of GraphQL Types, which allow Types to be registered as callbacks, and the full Type definitions are loaded only when needed.

For example, the following query:

{
  posts {
    nodes {
      id
      title
    }
  }
}

Should only load the following Type Definitions:

  • RootQuery
  • RootQueryToPostConnection
  • RootQueryToPostConnectionEdge
  • Post
  • (any Interfaces, such as Node and NodeWithTitle, that are implemented by these Types)

However, WPGraphQL wasn't using this feature of GraphQL-PHP quite right and was instead loading ALL GraphQL Type definitions on every GraphQL request.

This caused a lot of unnecessary overhead.

The improvements in this release show significant reduction in response time.

Below are some details on how things have improved. Results may vary based on your specific server setup, your schema, the queries you run, etc, but in general every user of WPGraphQL should see performance improvements after this release.

Query Statistics:

Request Type WP Homepage REST Endpoint GraphQL Endpoint REST Singe Post GraphQL Single Post GraphiQL Introspection
WPGraphQL 1.3.5 70 ms 77 ms 150 ms 73 ms 160 ms 2585 ms
v1.6.0 77 ms 72 ms 93 ms 73 ms 105 ms 658 ms
WPGraphQL 1.3.5 + 15 CPTs and Taxonomies 87 ms 78 ms 292 ms 79 ms 284 ms 6295 ms
v1.6.0 + 15 CPTs and Taxonomies 89 ms 77 ms 150 ms 79 ms 157 ms 1322 ms

To help visualize this data even more, I created some before/after charts:

WPGraphQL v1.3.5

Screen Shot 2021-07-23 at 1 18 16 PM

v1.6.0

Screen Shot 2021-07-23 at 1 18 48 PM

Prior to the PR we can see that GraphQL requests were near and above 150ms and after we can see it closer to 100ms!


WPGraphQL v1.3.5 (+ 15 Custom Post Types / Taxonomies)

Screen Shot 2021-07-23 at 1 20 03 PM

v1.6.0 (+ 15 Custom Post Types / Taxonomies)

Screen Shot 2021-07-23 at 1 20 14 PM

Prior to the PR, the GraphQL requests were near the 300ms and now they're cut down closer to 150ms!

And, all together we can see the different types of requests for v1.3.5 and v1.6.0:

Screen Shot 2021-07-23 at 2 42 37 PM

Faster Introspection

Introspection Queries (used for tools such as GraphiQL and Gatsby Source WordPress) is also MUCH faster now.

This is how long GraphiQL in the WP Admin takes to load the schema

Screen Shot 2021-07-23 at 2 33 29 PM

With 15 Custom Post Types and Taxonomies registered it was taking WPGraphQL 6+ seconds to return the Schema.

Now, it's taking about 1 second!

v1.3.5

~6 seconds before GraphiQL has the Schema and is ready to use

graphiql-loading-1 3 5

v1.6.0

~1 second and GraphiQL is ready for interaction

graphiql-loading-pr#2000


Improved User Model Check

The WPGraphQL Model Layer does a series of checks on each node to make sure that the requesting user has permission to see the nodes requested.

When a list of posts is queried in GraphQL, the Author(s) of the posts must also be loaded behind the scenes to properly determine whether each post in the list can be returned to the requesting user.

Let's say a list of draft posts were queried. If the request were public, no results would be returned. But, if the request were authenticated, then we'd need to know who the requesting user is, what capabilities they have, and whether they're the owner of the post(s) being returned.

If the requesting user is the Author of the post, they can see it. If they're not the author, then we need to check their capabilities. If they don't have proper capabilities to read others posts, they shouldn't see the post.

Long story short, querying a list of posts requires more than just returning raw data from the database, it requires added context of the requesting user, of the application layer (roles and capabilities of each post_type, etc) and ownership of each node being returned.

In the past, one check WPGraphQL performed to ensure User nodes were public, was to run the count_user_posts() function for each author loaded for the request.

This was expensive and required many SQL queries to fulfill.

In fact, for a "simple" query such as:

{
  posts( first: 100 ) {
    nodes {
      id
      title
      content
    }
  }
}

This would generate 113 MySQL queries to fulfil:

Screen Shot 2021-07-26 at 10 32 02 PM

But with the changes here, we're down to 13 queries, reducing the total queries by 99 for this request, and cutting the total SQL query time nearly in half!

Screen Shot 2021-07-26 at 10 41 11 PM

Results will vary from site-to-site based on data sets, etc, but this is a significant improvement and should improve performance for most users of WPGraphQL.

wp-graphql - v1.5.8

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2038): Exclude documentation directory from code archived by composer and deployed to WordPress.org
wp-graphql - v1.5.7

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • Update to trigger a missed deploy to WordPress.org. no functional changes from v1.5.6
wp-graphql - v1.5.6

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2035): Fixes a bug where variables passed to after_execute_actions weren't properly set for Batch Queries.

New Features

  • (#2035): (Yes, same PR as the bugfix above). Adds 2 new actions graphql_before_execute and graphql_after_execute to allow actions to run before/after the execution of entire Batch requests vs. the hooks that currently run within each the execution of each operation within a request.
wp-graphql - v1.5.5

Published by jasonbahl about 3 years ago

Release Notes

Chores / Bugfixes

  • (#2023): Fixes issue with deploying Docker Testing Images. Thanks @markkelnar!
  • (#2025): Update test workflow to test against WordPress 5.8 (released today) and updates the readme.txt to reflect the plugin has been tested up to 5.8
  • (#2028): Update Codeception test environment to prevent WordPress from entering maintenance mode during tests.
wp-graphql - v1.5.4

Published by jasonbahl over 3 years ago

Release Notes

Chores / Bugfixes

  • (#2012): Adds functional tests back to the Github testing workflow!
  • (#2016): Ignore Schema Linter workflow on releases, run on PRs only.
  • (#2019): Deploy Docker Testing Image on releases. Thanks @markkelnar!

New Features

  • (#2011): Introduces a new API to allow Types to register connections at the Type registration level and refactors several internal Types to use this new API.
wp-graphql - v1.5.3

Published by jasonbahl over 3 years ago

Release Notes

Chores / Bugfixes

  • (#2001): Updates Docker environment to use MariaDB instead of MySQL to play nice with those fancy M1 Macs. Thanks @chriszarate!
  • (#2002): Add PHP8 Docker image to deploy upon releases. Thanks @markkelnar!
  • (#2006): Update Docker to use $PROJECT_DIR variable instead of hardcoded value to allow composed docker images to run their own tests from their own project. Thanks @markkelnar!
  • (#2007): Update broken links to Relay spec. Thanks @ramyareye!

New Features

  • (#2009): Adds new WPConnectionType class and refactors register_graphql_connection() to use the class. Functionality should be the same, but this sets the codebase up for some new connection APIs.
wp-graphql - v1.5.2

Published by jasonbahl over 3 years ago

Release Notes

Chores / Bugfixes

  • (#1992): Fixes bug that caused conflict with the AmpWP plugin.
  • (#1994): Fixes bug where querying a node by uri could return a node of a different post type.
  • (#1997): Fixes bug where Enums could be generated with no values when a taxonomy was set to show in GraphQL but it's associated post_type(s) are not shown in graphql.
wp-graphql - v1.5.1

Published by jasonbahl over 3 years ago

Release Notes

Chores / Bugfixes

  • (#1987): Fixes Relay Spec link in documentation Thanks @ramyareye!
  • (#1988): Fixes docblock and paramater Type in preview filter callback. Thanks @zolon4!
  • (#1986): Update WP environment variables for tesing with PHP8. Thanks @markkelnar!

New Features

  • (#1984): Support for PHP8! No functional changes to the code, just changes to dependency declarations and test environment.
  • (#1990): Adds isTermNode and isContentNode to the UniformResourceIdentifiable Interface
wp-graphql - v1.5.0

Published by jasonbahl over 3 years ago

Release Notes

Chores / Bugfixes

  • (#1865): Change MenuItem.path field from nonNull to nullable as the value can be null in WordPress. Thanks @furedal!
  • (#1978): Use "docker compose" instead of docker-compose in the run-docker.sh script. Thanks @markkelnar!
  • (#1974): Separates app setup and app-post-setup scripts for use in the Docker/test environment setup. Thanks @markkelnar!
  • (#1972): Pushes Docker images when new releases are tagged. Thanks @markkelnar!
  • (#1970): Change Docker Image names specific to the WP and PHP versions. Thanks @markkelnar!
  • (#1967): Update xdebug max nesting level to allow coverage to pass with resolver instrumentation active. Thanks @markkelnar!

New Features

  • (#1977): Allow same string to be passed for "graphql_single_name" and "graphql_plural_name" (ex: "deer" and "deer") when registering Post Types and Taxonomies. Same strings will be prefixed with "all" for plurals. Thanks @apmatthews!
  • (#1787): Adds a new "ContentTypesOf. Thanks @plong0!
wp-graphql - v1.4.3

Published by jasonbahl over 3 years ago

No functional changes. See release notes for v1.4.2.

This release simply fixes a mistake with v1.4.2 release/deploy process where changes were not properly deployed.

wp-graphql - v1.4.2

Published by jasonbahl over 3 years ago

Release Notes

Chores / Bugfixes

  • (#1963): Fixes a regression in v1.4.0 where the uri field on Terms was returning null. The issue was actually wider than that as resolvers on Object Types that implement interfaces weren't being fully respected.
  • (#1956): Adds SpaceAfterFunction Code Sniffer rule and adjusts the codebase to respect the rule. Thanks @markkelnar!
Package Rankings
Top 0.97% on Packagist.org
Top 6.68% on Proxy.golang.org
Badges
Extracted from project README
Total Downloads Monthly Downloads Daily Downloads Latest Stable Version License Actions Status Actions Status Coverage Status Backers on Open Collective Sponsors on Open Collective
Related Projects