Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work for custom post types? #2

Closed
rasmustaarnby opened this issue Dec 29, 2017 · 1 comment
Closed

Does not work for custom post types? #2

rasmustaarnby opened this issue Dec 29, 2017 · 1 comment

Comments

@rasmustaarnby
Copy link

Hi,

Firstly, great little plugin.

I was having trouble adding a meta field for a custom post type. After some debugging, I found that the plugin is being loaded before the custom post types are.

Issue
The plugin instantiates on graphql_init, which I think is the locigal place to hook in. However, wp-graphql instantiates on after_setup_theme, which is before custom post types are added on the init hook.
https://codex.wordpress.org/Plugin_API/Action_Reference

So even though you register your meta field through the register_meta function, it won't get added because the post type hasn't been added yet.

Solution
Moving the plugin to load on do_graphql_request instead of graphql_init seems to do the trick. I'm unaware of any side effects by doing this, if there are any.

I would sugget to either move the plugin to load on do_graphql_request. If this is not a good solution please let me know and I'll prepare a PR for wp-graphql with solution for a second hook that fires on init.

Regards,
Rasmus

@rasmustaarnby
Copy link
Author

Fixed in #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant