ylefebvre / link-library

Link Library WordPress Plugin source code. Main plugin available from wordpress.org site
https://wordpress.org/plugins/link-library/
GNU General Public License v2.0
6 stars 2 forks source link

Added WPgraphql support #15

Closed ifoi closed 1 year ago

ifoi commented 1 year ago

I am trying to use links library with a headless wordpress, I noticed that the library data was not been exposed to graphql, so i added the graphql support.

I followed the suggestions in this post .. https://www.thestrugglingdeveloper.com/2020/12/03/how-to-add-or-expose-a-custom-posttype-in-wpgraphql-extension/

ylefebvre commented 1 year ago

Thanks for the contribution. I will only be able to look into this pull request in a few weeks when I come back from a business trip. I am not planning any updates to Link Library so no worries about an update overwriting your local changes. Instead of putting all of these parameters directly in the post type definition, I might check to see if I can detect the installation of this graphql plugin and only then add the extra parameters.

Yannick

On Tue, Oct 18, 2022 at 3:48 PM Ifo Ikede @.***> wrote:

I am trying to use links library with a headless wordpress, I noticed that the library data was not been exposed to graphql, so i added the graphql support.

I followed the suggestions in this post .. https://www.thestrugglingdeveloper.com/2020/12/03/how-to-add-or-expose-a-custom-posttype-in-wpgraphql-extension/ http://url

You can view, comment on, or merge this pull request online at:

https://github.com/ylefebvre/link-library/pull/15 Commit Summary

File Changes

(1 file https://github.com/ylefebvre/link-library/pull/15/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/ylefebvre/link-library/pull/15, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCYFXYUXIFV6ZOEWYYHBCDWD35HFANCNFSM6AAAAAARINOINQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ifoi commented 1 year ago

Regarding checking to sere if graphql is installed, before enabling support for it. What if graphql plugin is installed after Link-library ?

Which reminds me, if i want to make sure that my updates are being used, do i have to deactivate and reactive the plugin? SO that it reloads " link-library.php "

More or less asking if my edits to link-library.php are reloaded by WordPress upon saving the file.? because at the moment, the nodes are note showing up on WpGraphql.

have a good trip and hello from a fellow Canuck.

ylefebvre commented 1 year ago

The approach I took to detect if GraphQL was installed was the following:

if ( class_exists( 'WPGraphQL' ) ) { $post_type_args['show_in_graphql'] = true; $post_type_args['hierarchical'] = true; $post_type_args['graphql_single_name'] = 'linklibrary'; $post_type_args['graphql_plural_name'] = 'linklibrary'; }

With this technique, the extra array elements are added into the post type argument array if it detects that the class is present. The order in which plugins are installed does not matter. This checks if the plugin is running on the site. This code change is available in version 7.4.1.