Bot releases are visible (Hide)
Published by jasonbahl over 6 years ago
Published by jasonbahl over 6 years ago
Making Connections Contextual: #387 made changes to how Connection Types are registered and implemented throughout. Previously, connections were pretty generic, such as PostsConnection
and that connection was a field of the RootQuery and appeared elsewhere like as children of a Post, or connection from TermObjects. . .The flaw in that is that connections should be contextual based on the node it's connecting from and connecting to. So, now, we have connections such as: PostCategoriesConnection
and RootCategoriesConnection
. This allows for each type to execute differently, and provide other conditional attributes like edge data that exists when categories are being queried as a field of a Post vs. when they're being queried for as a Root Query. Same with args on the connections, they can now be added to specific connections, instead of available generally across the board. You can read more about it in #387
shouldOutputInFlatList
and shouldOnlyIncludeConnectedItems
. You can read more about use in #387We've added batch request support in #385! This allows for multiple queries/mutations to be sent in an HTTP request as an array of requests, and they will be processed in one request!
:/endif;
Types::non_null
and Types::list_of
to play nicer with IDEsPublished by jasonbahl almost 7 years ago
Published by jasonbahl almost 7 years ago
define( 'GRAPHQL_DEBUG', true );
in your wp-config.php to enable more friendly debug errors to be returned in GraphiQL. Many errors that are returned as Internal Server Error
by default show more helpful errors with GRAPHQL_DEBUG
enabled.register_setting
APIbin/install-wp-tests.sh
to setup a working environment for CodeceptionPublished by jasonbahl almost 7 years ago
'show_in_rest' => 'true'
.Published by jasonbahl almost 7 years ago
This is probably the biggest release yet!
Lots of good stuff here.
wp graphql generate-static-schema
will output a schema.graphql
file to the root of the plugin.register_setting()
do_action( 'graphql_before_resolve_field' )
do_action( 'graphql_after_resolve_field' )
apply_filters( 'graphql_resolve_field' )
to allow granular control over how fields resolve.'isPrivate' => true
in the Schema to ensure it only resolves to Authenticated users. Additional 'auth' => []
options for more powerful authorization control over the resolvers.UserError
instead, as Exceptions will now be returned publicly as "Internal Server Error" as to not expose sensitive server data.rootQuery
and post
as a type, now it's RootQuery
and Post
__typename
field, or any fragments or union queries that make use of the ...on Post { }
. . ....on post
will now be ...on Post
, etc.author
field is now a union, instead of returning a User
, as it can be a User
or a CommentAuthor
{
comment( id:"..." ) {
id
title
author {
...on CommentAuthor {
name
}
...on User {
name
}
}
}
}
sprintf()
with $wpdb->prepare
in a few spotsPublished by jasonbahl about 7 years ago
nodes
to connectionsSometimes it makes sense to query for nodes without their edges. Now you can!
All connections that are part of the plugin now have the ability to query the connections edges
OR nodes
.
For example, you can now get a list of posts like so:
{
posts {
pageInfo {
startCursor
endCursor
}
nodes {
id
title
date
link
}
}
}
There is now a format
Enum arg on the content, title and excerpt fields for postObjects. This enum has 2 values by default, RENDERED
and RAW
where the default is RENDERED
.
This field is intended to be used in conjunction with the App Context that gets passed down the GraphQL Resolve Tree to be able to provide output that matches the context.
RAW is intended to be the raw, unaltered value as stored in the data store. Rendered is intended to be how the data should render in the context it's being requested.
Since there are different render contexts (web, print, mobile, AMP, Facebook Instant Articles, etc), the value that is returned can be changed based on the context. Currently, nothing is changed by the plugin itself based on different contexts, but this opens up the door for folks to be able to provide different content for different contexts, OR provide raw data values as well.
Note: pagination will still work as there is still access to the startCursor and endCursor.
global $post
when resolving a post and resets it at the end of the GraphQL executionPublished by jasonbahl about 7 years ago
Get single postObjects by Global ID, DB ID and URI
{
postById: postBy(id:"cG9zdDoxMDAw") {
...postData
}
postByPostId: postBy(postId:1000) {
...postData
}
postByURI: postBy(uri:"hello-world") {
...postData
}
}
fragment postData on post {
id
postId
uri
}
User Mutations
mutation createUser {
createUser( input: {
clientMutationId: "someId"
username: "username"
email: "[email protected]"
}) {
user {
firstName
lastName
}
}
}
403 Default Header Status
The default header status for responses will be 403. For authenticated requests, the status will be 200. The execution will remain the same, where authorization will occur at the resolve level, but the status change will allow clients to invalidate current users, etc when a request comes back as unauthenticated without getting a full error for the entire request.
Misc Updates
last_name
field on user type to lastName
(breaking change)Unit Test Changes
Documentation
Published by jasonbahl about 7 years ago
This is a pretty big update!
Breaking Changes
postTypeType
and taxonomyType
taxonomy
arg from the TermObjectConnectionArgsOther Changes
Published by jasonbahl over 7 years ago
Ancestors of hierarchical taxonomy terms can only be of the same taxonomy, so they can be queried like so:
cateogory( id:"..." ) {
id
title
ancestors {
id
name
}
}
Since postObjects can have ancestors of any postType and that cannot be known until query time, the ancestors are unions and can be queried like so:
page( id:"..." ) {
ancestors{
...on page {
id
title
link
}
...on otherPostType {
id
title
link
}
}
}
Published by jasonbahl over 7 years ago
Adds initial mutations for terms.
For example:
Create a Category:
mutation createCategory( $clientMutationId:String!, $name:String!, $description:String ) {
createCategory(
input: {
clientMutationId: $clientMutationId
name: $name
description: $description
}
) {
clientMutationId
category {
id
name
description
}
}
}
Update a Category:
mutation updateCategory( $clientMutationId:String!, $id:ID! $description:String ) {
updateCategory(
input: {
clientMutationId: $clientMutationId
description: $description
id: $id
}
) {
clientMutationId
category {
id
name
description
}
}
}
Delete a Category:
mutation deleteCategory( $clientMutationId:String!, $id:ID! ) {
deleteCategory(
input: {
id: $id
clientMutationId: $clientMutationId
}
) {
clientMutationId
category {
id
name
}
}
}
Published by jasonbahl over 7 years ago
Updates translation strings and enforces late escaping on the schema
Published by jasonbahl over 7 years ago
This includes a breaking change. Instead of using postTag
and postTags
for the Schema for the "post_tags" taxonomy, we now use tag
and tags
If you're already invested in consuming the GraphQL API using the postTag names, you can add them back like so:
add_action( 'graphql_generate_schema', function() {
global $wp_taxonomies;
if ( isset( $wp_taxonomies['post_tag'] ) ) {
$wp_taxonomies['post_tag']->graphql_single_name = 'postTag';
$wp_taxonomies['post_tag']->graphql_plural_name = 'postTags';
}
} );
Published by jasonbahl over 7 years ago
Published by jasonbahl over 7 years ago
Version number bump
Published by jasonbahl over 7 years ago
Fixes issue with Relay files being ignored, and not versioned, in the vendor file.
This will likely change in the future, where we won't version the vendor files directly in this repo, but instead have a build that installs them and creates a downloadable .zip file with the vendor files included. . .but for now, for folks that want to use the plugin and want to download a .zip from github, this is the quickest resolution for that.
Published by jasonbahl over 7 years ago
Published by jasonbahl over 7 years ago
Published by jasonbahl over 7 years ago
Published by jasonbahl over 7 years ago