DEPRECATION NOTICE
WPGraphQL for Custom Post Type UI
Install this plugin along with WPGraphQL and Custom Post Type UI and you will have settings to show your Custom Post Types and Custom Taxonomies in GraphQL.
Install this plugin along with WPGraphQL and Custom Post Type UI and you will have settings to show your Custom Post Types and Custom Taxonomies in GraphQL.
Hey there, In CPT UI I can't get "Show in GraphQL" to save as true. I thought it might be something in my config or settings so I spun up a fresh WordPress install and installed the latest versions of WPGraphQL (version 1.3.3), CPT UI (version 1.8.2), and this plugin (version 1.2.0). Everything's just set to their defaults. I added a new custom post type in CPT UI with the Post Type Slug being case_results, the Plural Label being Case Results, and the Singular Label being Case Result. Everything else is left untouched. When I select True in Show in GraphQL it seems to automatically pull in what's in Singular Label for GraphQL Single Name and Plural Label for GraphQL Plural Name. So I did try that first. But when I hit Save Post Type it just goes back to false. I tried changing the GraphQL Single Name to various different things including case-result, caseresult, and _caseresult and tried changing the GraphQL Plural Name to case-results, caseresults, and _caseresults but none worked. When I go to Registered Types/Taxes below is what I see in the Settings column. Any help would be much appreciated.
name: case_results label: Case Results singular_label: Case Result description: "" public: true publicly_queryable: true show_ui: true show_in_nav_menus: true delete_with_user: false show_in_rest: true rest_base: "" rest_controller_class: "" has_archive: false has_archive_string: "" exclude_from_search: false capability_type: post hierarchical: false rewrite: true rewrite_slug: "" rewrite_withfront: true query_var: true query_var_slug: "" menu_position: "" show_in_menu: true show_in_menu_string: "" menu_icon: "" custom_supports: "" graphql_single_name: "" graphql_plural_name: ""
Actually I pulled an older version of this plugin off of another site we're using it on, version 1.1, and that one seems to be working as expected.
bug close candidateIf I add a single name of team mate
, it's registered to the schema like that. Ideally these fields would be normalized to camelcase automatically. so team mate
becomes teamMate
.
It could be nice to have an option to infer the field names from the post type labels too. Team Mate
could become teamMate
automatically.
When adding a new post type in CPTUI, if I don't scroll down and add the GraphQL single and plural names, but I create the post type, the site will be broken and the admin will be unreachable and display The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.
[30-Oct-2019 04:33:50 UTC] PHP Fatal error: Uncaught GraphQL\Error\UserError: The much post_type isn't configured properly to show in GraphQL. It needs a "graphql_single_name" and a "graphql_plural_name" in /Users/tyler/Local Sites/wpgraphql/app/public/wp-content/plugins/wp-graphql/wp-graphql.php:415
Stack trace:
#0 [internal function]: WPGraphQL::{closure}('much')
#1 /Users/tyler/Local Sites/wpgraphql/app/public/wp-content/plugins/wp-graphql/wp-graphql.php(424): array_map(Object(Closure), Array)
#2 /Users/tyler/Local Sites/wpgraphql/app/public/wp-content/plugins/wp-graphql/wp-graphql.php(289): WPGraphQL::get_allowed_post_types()
#3 /Users/tyler/Local Sites/wpgraphql/app/public/wp-includes/class-wp-hook.php(286): WPGraphQL->get_allowed_types('')
#4 /Users/tyler/Local Sites/wpgraphql/app/public/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#5 /Users/tyler/Local Sites/wpgraphql/app/public/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
#6 /Users/tyler/Local Sites/wpgraphql/app/public/wp-settings.php(525): do_action('init' in /Users/tyler/Local Sites/wpgraphql/app/public/wp-content/
Show in GraphQL always defaults to true and doesn't take its saved option. The option saves correctly but if you go back in and edit the taxonomy or post it defaults to true
Seems that latest update CPT UI (to version 1.8.2) breaks schema generation at GraphiQL IDE (page /wp-admin/admin.php?page=graphiql-ide). When this plugin activated, the Explorer window in GraphiQL IDE became empty and in developer console I see following error:
Uncaught (in promise) Error: Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: { status: 500 } main.b7d08b5b.js:1:199854 https://........./wp-content/plugins/wp-graphql/src/Admin/GraphiQL/app/build/static/js/main.b7d08b5b.js?ver=5.7:1
Currently these are not required. This leads to an odd UX.
If you add a new post type with no intention of using it in WPGraphQL, it will still be set to "show_in_graphql" => true
by default. This means when you create your new post type, without changing any settings related to this plugin, you'll get an error when attempting to make a gql request.
Ideally these fields should be required. I went to start making a PR to do this, but I realized these fields should only be required if "Show in GraphQL" is set to true. If it's false these fields shouldn't be required. I'm not too sure how to make that work with the CPTUI $ui
helper without adding some custom JS π€ .
Do we need to register a little bit of JS that flips these between required and not-required?
Solves this ticket: #6
I'm sure there is a better way to abstract some functions here, to not repeat so much code. But this is an easy add-in and it fixes the issue. Would be great if someone tests it properly.
If someone has some code optimize suggestions, I'm happy to add it. I'm not the biggest php guru π
Review Ready Work In ProgressGetting a PHP warning:
Notice: Undefined variable: post_type_deleted in /app/public/wp-content/plugins/wp-graphql-custom-post-type-ui-master/wp-graphql-custom-post-type-ui.php on line 78
Looks like changing line 78 to the following should fix it:
$selected_post_type = cptui_get_current_post_type( false );
bug good first issue
This is basically a complete refactor of the plugin.
The overall goal is to handle the fields for GraphQL settings better.
Currently, users can leave graphql_single_name and graphql_plural_name blank, but set the Post Type or Taxonomy to show_in_graphql and that causes issues.
This makes the graphql_single_name and graphql_plural_name fields conditional to only show and be required if show_in_graphql is set to true.
See example:
Release Review ReadyIssue #4
Fix the Notice: Undefined variable: post_type_deleted in /app/public/wp-content/plugins/wp-graphql-custom-post-type-ui-master/wp-graphql-custom-post-type-ui.php on line 78
It would be nice for users to be able to install this plugin using composer.
This plugin should have a composer.json file and be submitted to packagist.org
This is basically a complete refactor of the plugin.
The overall goal is to handle the fields for GraphQL settings better.
Currently, users can leave graphql_single_name and graphql_plural_name blank, but set the Post Type or Taxonomy to show_in_graphql and that causes issues.
This makes the graphql_single_name and graphql_plural_name fields conditional to only show and be required if show_in_graphql is set to true.
See example:
Source code(tar.gz)N.B I've released an updated version of the project to a new repository, PostTypes. WP Custom Post Type Class v1.4 A single class to help you build mo
Quick Open Dashboard Widget Requires PHP: 7.0 WP requires at least: 5.7 WP tested up to: 5.7 WC requires at least: 5.6.0 WC tested up to: 5.8.0 Stable
WPGraphQL Meta Query This plugin adds Meta_Query support to the WP GraphQL Plugin for postObject query args. Why is this an extension and not part of
QL Search What is QL Search? An extension that integrates SearchWP into WPGraphQL. Quick Install Install & activate SearchWP v3.1.9+ Install & activat
WPGraphQL for Advanced Custom Fields WPGraphQL for Advanced Custom Fields automatically exposes your ACF fields to the WPGraphQL Schema. Install and A
WPGraphQL WPML Extension Contributors: rburgst Stable tag: 1.0.6 Tested up to: 5.6.1 Requires at least: 4.9 Requires PHP: 7.0 Requires WPGraphQL: 0.8.
WPGraphQl Yoast SEO Plugin Please note version 14 of the Yoast Plugin is a major update. If you are stuck on version of Yoast before V14 then use v3 o
WP Bootstrap Navwalker This code in the main repo branch is undergoing a big shakeup to bring it in line with recent standards and to merge and test t
WordPress Update Handler A WordPress package for updating custom plugins and themes based on an JSON REST API response from a custom update server. Ch
Suspend WP A WordPress plugin to suspend WordPress sites automagically. Simple and lightweight, no annoying ads and fancy settings. ?? Demo (coming so
A simple platform information plugin for WordPress. Shows you environment variables, PHP settings and more.
ClioWP Settings Page ClioWP Setting Page is a free WordPress Plugin which creates a sample Settings Page. This βtestβ page contains almost any type of
WPGraphQL JWT Authentication This plugin extends the WPGraphQL plugin to provide authentication using JWT (JSON Web Tokens) JSON Web Tokens are an ope
?? WP GraphQL Lock This plugin enables query locking for WPGraphQL by implementing persisted GraphQL queries. Persisted GraphQL queries allow a GraphQ
WPGraphQL Persisted Queries Persisted GraphQL queries allow a GraphQL client to optimistically send a hash of the query instead of the full query; if
WPGraphQL Send Email Plugin One of the simple things about a traditional WordPress sites is sending emails, this plugin makes it easy to do this via a
WPGraphQL Content Blocks (Structured Content) This WPGraphQL plugin returns a WordPress postβs content as a shallow tree of blocks and allows for some
WPGraphQL Polylang Extension Extend WPGraphQL schema with language data from the Polylang plugin. Features For posts and terms (custom ones too!) Adds
WpGraphQLCrb A Wordpress wrapper to expose Carbon Fields to WpGraphQL queries. Important This is just the first version. There is a lot of work to be