Hube2 / acf-options-page-adder

Easy creation of options pages for ACF Pro
62 stars 14 forks source link

feat(wp-graphql): add support to add options page to GraphQL schema #53

Closed simptheshrimp closed 3 years ago

simptheshrimp commented 3 years ago

Both ACF and CPT UI offers the ability to add field, field group and custom post type to GraphQL schema. WP-GraphQL looks for show_in_graphql => 1 to add options page along with its associated fields to the schema.

Hube2 commented 3 years ago

I cannot tell what code has been altered because it appears that you have changed white-space from tab to spaces on every line and the dif shows me that every line has been changed. Can you give me specific information about what changes are made so that I do not need to manually compare the entire files

simptheshrimp commented 3 years ago

Yeah seems like the formatter kicked in and arranged the whole file. The lines added is 309-329 and 679-682.

Hube2 commented 3 years ago

I'm still a little confused. I can't find anything in ACF that references 'show_in_graphql' and I can't seem to find any reference to this in CPT UI. I am unfamiliar with this. Can you give me a little more background? I don't really have an issue adding this support, but I would like to know more about what I'm adding support for.

simptheshrimp commented 3 years ago

For ACF its actually the ACF extension plugin from WPGraphQL that adds it to the fields (https://github.com/wp-graphql/wp-graphql-acf) but in CPT UI its located in the external/wpgraphql.php file.

Sure thing! It is basically to enable adding your Options page to the GraphQL Schema. WPGraphQL handles all CPTs and ACFS (in the extension plugin linked) the same way by looking for the show_in_graphql option (https://github.com/wp-graphql/wp-graphql/blob/8e352b7588c35a218b814f4c44488627fda4624d/src/WPGraphQL.php#L420). So what this PR does is that it adds the same functionality as when you have ex.g. WPGraphQL and CPT UI activated and are creating a new CPT, you are prompted the option if you wanna add/expose this CPT and its fields to the schema and make it queryable, I put in the same option when creating your Options page, if WPGraphQL is active of course, to be able to add it to the schema.

Hube2 commented 3 years ago

I added the changes manually rather than change all the whitesapce back to what I like.