This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Config for WPGraphQL ACF | |
| * | |
| * @package wp-graphql-acf | |
| */ | |
| namespace WPGraphQL\ACF; | |
| use WPGraphQL\Data\DataSource; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'graphql_post_object_connection_query_args', function( $args ) { | |
| $args['no_found_rows'] = false; | |
| return $args; | |
| } ); | |
| add_filter( 'graphql_connection_page_info', function( $page_info, $connection ) { | |
| $page_info['total'] = null; | |
| if ( $connection->get_query() instanceof \WP_Query ) { | |
| if ( isset( $connection->get_query()->found_posts ) ) { | |
| $page_info['total'] = (int) $connection->get_query()->found_posts; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_field( 'RootQuery', 'activeTheme', [ | |
| 'type' => 'Theme', | |
| 'description' => __( 'The currently active theme for the site', 'your-textdomain' ), | |
| 'resolve' => function() { | |
| $theme = wp_get_theme(); | |
| return new Theme( $theme ); | |
| } | |
| ] ); | |
| } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'init', function(){ | |
| register_post_type( 'stores', [ | |
| 'label' => 'Stores', | |
| 'show_in_graphql' => true, | |
| 'hierarchical' => true, | |
| 'graphql_single_name' => 'store', | |
| 'graphql_plural_name' => 'stores', | |
| 'public' => true, | |
| 'supports' => [ 'title', 'thumbnail', 'excerpt' ], | |
| ] ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import { | |
| TextField, | |
| TextFieldFragment | |
| ImageField, | |
| ImageFieldFragment | |
| } | |
| class Form extends React.Component { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_field( 'RootQuery', 'allUrls', [ | |
| 'type' => [ 'list_of' => 'String' ], | |
| 'description' => __( 'A list of all urls. Helpful for rendering sitemaps', 'your-textdomain' ), | |
| 'resolve' => function() { | |
| // Start collecting all URLS | |
| $meta_urls = array( get_home_url() ); | |
| $all_posts = [ 'site.com/post', 'site.com/post-2' ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_connection([ | |
| 'fromType' => 'ContentNode', | |
| 'toType' => 'MediaItem', | |
| 'fromFieldName' => 'attachedMedia', | |
| 'connectionArgs' => \WPGraphQL\Connection\PostObjects::get_connection_args(), | |
| 'resolve' => function( \WPGraphQL\Model\Post $source, $args, $context, $info ) { | |
| $resolver = new \WPGraphQL\Data\Connection\PostObjectConnectionResolver( $source, $args, $context, $info, 'attachment' ); | |
| $resolver->setQueryArg( 'post_parent', $source->ID ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_field( 'RootQuery', 'myNewField', [ | |
| 'type' => 'String', | |
| 'args' => [ | |
| 'myArg' => [ | |
| 'type' => 'String', | |
| ], | |
| ], | |
| 'resolve' => function( $source, $args, $context, $info ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_field( 'RootQuery', 'listOfStrings', [ | |
| 'type' => [ 'list_of' => 'String' ], | |
| 'resolve' => function() { | |
| return [ | |
| 'String One', | |
| 'String Two' | |
| ]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'graphql_register_types', function() { | |
| register_graphql_object_type( | |
| 'stuntPerformer', | |
| [ | |
| 'description' => __( 'Stunt PErformer', 'bsr' ), | |
| 'fields' => [ | |
| 'firstName' => [ | |
| 'type' => 'String', | |
| 'description' => 'fisrt name' |