├── .coveralls.yml ├── .dockerignore ├── .editorconfig ├── .env.dist ├── .env.testing ├── .github └── workflows │ ├── testing-integration.yml │ └── upload-schema-artifact.yml ├── .vscode ├── launch.json └── settings.json ├── DEVELOPMENT.md ├── README.md ├── codeception.dist.yml ├── composer.json ├── docker-compose.yml ├── docker ├── Dockerfile ├── Dockerfile.testing └── app.setup.sh ├── docs ├── field-group-examples-export.json ├── fields │ ├── accordion.md │ ├── button-group.md │ ├── checkbox.md │ ├── clone.md │ ├── color-picker.md │ ├── date-picker.md │ ├── date-time-picker.md │ ├── email.md │ ├── file.md │ ├── flexible-content.md │ ├── gallery.md │ ├── google-map.md │ ├── group.md │ ├── image.md │ ├── link.md │ ├── message.md │ ├── number.md │ ├── oembed.md │ ├── page-link.md │ ├── password.md │ ├── post-object.md │ ├── radio.md │ ├── range.md │ ├── relationship.md │ ├── repeater.md │ ├── select.md │ ├── tab.md │ ├── taxonomy.md │ ├── text-area.md │ ├── text.md │ ├── time-picker.md │ ├── true-false.md │ ├── url.md │ ├── user.md │ └── wysiwyg.md └── img │ ├── button-group-field-input.png │ ├── button-group-field-query.png │ ├── checkbox-field-input.png │ ├── checkbox-field-query.png │ ├── color-picker-field-input.png │ ├── color-picker-field-query.png │ ├── date-picker-field-input.png │ ├── date-picker-field-query.png │ ├── date-time-picker-field-input.png │ ├── date-time-picker-field-query.png │ ├── email-field-input.png │ ├── email-field-query.png │ ├── field-group-show-in-graphql.png │ ├── file-field-input.png │ ├── file-field-query.png │ ├── flex-field-input.png │ ├── flex-field-input2.png │ ├── flex-field-query.png │ ├── flex-field-query2.png │ ├── flex-field-union-possible-types.png │ ├── gallery-field-input.png │ ├── gallery-field-query.png │ ├── group-field-input.png │ ├── group-field-query.png │ ├── image-field-input.png │ ├── image-field-query.png │ ├── link-field-input.png │ ├── link-field-query.png │ ├── location-rule-post-type-post.png │ ├── map-field-input.png │ ├── map-field-query.png │ ├── multi-select-field-input.png │ ├── multi-select-field-query.png │ ├── number-field-input.png │ ├── number-field-query.png │ ├── oEmbed-field-input.png │ ├── oembed-field-query.png │ ├── page-link-field-input-2.png │ ├── page-link-field-input.png │ ├── page-link-field-possible-types.png │ ├── page-link-field-post-type-config.png │ ├── page-link-field-query-2.png │ ├── page-link-field-query-page.png │ ├── page-link-field-query-post.png │ ├── page-link-field-query.png │ ├── password-field-input.png │ ├── post-object-field-input-multi.png │ ├── post-object-field-input-page.png │ ├── post-object-field-input-post.png │ ├── post-object-field-possible-types.png │ ├── post-object-field-post-type-config.png │ ├── post-object-field-query-multi.png │ ├── post-object-field-query-page.png │ ├── post-object-field-query-post.png │ ├── radio-button-field-input.png │ ├── range-field-input.png │ ├── relationship-field-input.png │ ├── relationship-field-possible-types.png │ ├── relationship-field-post-type-config.png │ ├── repeater-field-input.png │ ├── repeater-field-query.png │ ├── select-field-input.png │ ├── select-field-query.png │ ├── taxonomy-field-input.png │ ├── taxonomy-field-query.png │ ├── taxonomy-field-taxonomy-config.png │ ├── text-area-field-input.png │ ├── text-field-config.png │ ├── text-field-input.png │ ├── text-field-query.png │ ├── time-picker-field-input.png │ ├── true-false-field-input.png │ ├── url-field-input.png │ ├── user-field-input-multiple.png │ ├── user-field-input.png │ ├── user-field-query-multiple.png │ ├── user-field-query.png │ ├── wysiwyg-field-input.png │ └── wysiwyg-field-query.png ├── readme.txt ├── src ├── class-acf.php ├── class-acfsettings.php ├── class-config.php ├── js │ └── main.js └── location-rules.php ├── vendor ├── autoload.php └── composer │ ├── ClassLoader.php │ ├── InstalledVersions.php │ ├── LICENSE │ ├── autoload_classmap.php │ ├── autoload_namespaces.php │ ├── autoload_psr4.php │ ├── autoload_real.php │ ├── autoload_static.php │ ├── installed.json │ ├── installed.php │ └── platform_check.php └── wp-graphql-acf.php /.coveralls.yml: -------------------------------------------------------------------------------- 1 | service_name: travis-ci 2 | coverage_clover: tests/_output/coverage.xml 3 | json_path: tests/_output/coveralls-upload.json 4 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # The following files should be ignored: 2 | # - unencrypted sensitive data 3 | # - files that are not checked into the code repository 4 | # - files that are not relevant to the Docker build 5 | 6 | .git 7 | .idea 8 | bin 9 | docker-output 10 | docs 11 | img 12 | 13 | tests/_output 14 | !tests/_output/.gitignore 15 | tests/_support/_generated 16 | !tests/_support/_generated/.gitignore 17 | 18 | vendor 19 | !vendor/autoload.php 20 | !vendor/ivome/graphql-relay-php/src 21 | !vendor/webonyx/graphql-php/src 22 | !vendor/composer 23 | 24 | .dockerignore 25 | .gitignore 26 | .travis.yml 27 | CODE_OF_CONDUCT.md 28 | CONTRIBUTING.md 29 | Dockerfile* 30 | ISSUE_TEMPLATE.md 31 | LICENSE 32 | PULL_REQUEST_TEMPLATE.md 33 | README.md 34 | readme.txt 35 | run-docker*.sh 36 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | # WordPress Coding Standards 5 | # https://make.wordpress.org/core/handbook/coding-standards/ 6 | 7 | root = true 8 | 9 | [*] 10 | charset = utf-8 11 | end_of_line = lf 12 | insert_final_newline = true 13 | trim_trailing_whitespace = true 14 | indent_style = tab 15 | indent_size = 4 16 | 17 | [{.jshintrc,*.json,*.yml}] 18 | indent_style = space 19 | indent_size = 2 20 | 21 | [{*.txt,wp-config-sample.php}] 22 | end_of_line = crlf 23 | -------------------------------------------------------------------------------- /.env.dist: -------------------------------------------------------------------------------- 1 | DB_NAME=wordpress 2 | DB_HOST=app_db 3 | DB_USER=wordpress 4 | DB_PASSWORD=wordpress 5 | 6 | WP_TABLE_PREFIX=wp_ 7 | WP_URL=http://localhost:8091 8 | WP_DOMAIN=localhost 9 | 10 | ADMIN_EMAIL=admin@example.com 11 | ADMIN_USERNAME=admin 12 | ADMIN_PASSWORD=password 13 | ADMIN_PATH=/wp-admin 14 | 15 | # Used by wp-config.php 16 | WORDPRESS_DB_HOST=${DB_HOST} 17 | WORDPRESS_DB_USER=${DB_USER} 18 | WORDPRESS_DB_PASSWORD=${DB_PASSWORD} 19 | WORDPRESS_DB_NAME=${DB_NAME} 20 | WORDPRESS_TABLE_PREFIX=${WP_TABLE_PREFIX} 21 | 22 | # Used by db container 23 | MYSQL_ROOT_PASSWORD=root 24 | MYSQL_DATABASE=${DB_NAME} 25 | MYSQL_USER=${DB_USER} 26 | MYSQL_PASSWORD=${DB_PASSWORD} 27 | 28 | # docker container env vars 29 | WP_VERSION=5.9 30 | PHP_VERSION=8.0 31 | WPGRAPHQL_VERSION=latest 32 | DATA_DUMP_DIR=/var/www/html/wp-content/plugins/wp-graphql-acf/tests/_data 33 | -------------------------------------------------------------------------------- /.env.testing: -------------------------------------------------------------------------------- 1 | # Used by wp-graphql image to create the WP 2 | DB_NAME=wordpress 3 | DB_HOST=testing_db 4 | DB_USER=wordpress 5 | DB_PASSWORD=wordpress 6 | 7 | WP_TABLE_PREFIX=wp_ 8 | WP_URL=http://localhost:8091 9 | WP_DOMAIN=localhost 10 | 11 | ADMIN_EMAIL=admin@example.com 12 | ADMIN_USERNAME=admin 13 | ADMIN_PASSWORD=password 14 | ADMIN_PATH=/wp-admin 15 | 16 | # Used by codeception WPBrowser 17 | TEST_SITE_DB_DSN=mysql:host=${DB_HOST};dbname=${DB_NAME} 18 | TEST_SITE_DB_HOST=${DB_HOST} 19 | TEST_SITE_DB_NAME=${DB_NAME} 20 | TEST_SITE_DB_USER=${DB_USER} 21 | TEST_SITE_DB_PASSWORD=${DB_PASSWORD} 22 | TEST_SITE_TABLE_PREFIX=${WP_TABLE_PREFIX} 23 | TEST_SITE_ADMIN_USERNAME=admin 24 | TEST_SITE_ADMIN_PASSWORD=password 25 | TEST_SITE_WP_ADMIN_PATH=/wp-admin 26 | WP_ROOT_FOLDER=/var/www/html 27 | 28 | TEST_DB_NAME=${DB_NAME} 29 | TEST_DB_HOST=${DB_HOST} 30 | TEST_DB_USER=${DB_USER} 31 | TEST_DB_PASSWORD=${DB_PASSWORD} 32 | TEST_TABLE_PREFIX=${WP_TABLE_PREFIX} 33 | 34 | TEST_SITE_WP_URL=http://localhost 35 | TEST_SITE_WP_DOMAIN=localhost 36 | TEST_SITE_ADMIN_EMAIL=admin@localhost 37 | 38 | # Used by wp-graphql-testing docker 39 | TESTS_DIR=tests 40 | TESTS_OUTPUT=tests/_output 41 | TESTS_DATA=tests/_data 42 | TESTS_SUPPORT=tests/_support 43 | TESTS_ENVS=tests/_envs 44 | 45 | SUITES=wpunit 46 | SKIP_TESTS_CLEANUP=1 47 | 48 | # Used by wp-config.php 49 | WORDPRESS_DB_HOST=${DB_HOST} 50 | WORDPRESS_DB_USER=${DB_USER} 51 | WORDPRESS_DB_PASSWORD=${DB_PASSWORD} 52 | WORDPRESS_DB_NAME=${DB_NAME} 53 | WORDPRESS_TABLE_PREFIX=${WP_TABLE_PREFIX} 54 | 55 | # Used by db container 56 | MYSQL_ROOT_PASSWORD=root 57 | MYSQL_DATABASE=${DB_NAME} 58 | MYSQL_USER=${DB_USER} 59 | MYSQL_PASSWORD=${DB_PASSWORD} 60 | 61 | # docker container env vars 62 | WP_VERSION=5.9 63 | PHP_VERSION=8.0 64 | WPGRAPHQL_VERSION=latest 65 | DATA_DUMP_DIR=/var/www/html/wp-content/plugins/wp-graphql-acf/tests/_data 66 | -------------------------------------------------------------------------------- /.github/workflows/testing-integration.yml: -------------------------------------------------------------------------------- 1 | name: Testing Integration 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | - master 8 | pull_request: 9 | branches: 10 | - develop 11 | - master 12 | paths: 13 | - '**.php' 14 | - '.github/workflows/*.yml' 15 | - '!docs/**' 16 | 17 | jobs: 18 | continuous_integration: 19 | runs-on: ubuntu-latest 20 | strategy: 21 | matrix: 22 | php: [ '8.0', '7.4', '7.3' ] 23 | wordpress: [ '6.0', '5.9', '5.8', '5.7.2', '5.6', '5.5.3' ] 24 | include: 25 | - php: '8.0' 26 | wordpress: '5.7.2' 27 | WPGRAPHQL_VERSION: 'v1.5.3' 28 | - php: '7.4' 29 | wordpress: '5.7.2' 30 | coverage: 1 31 | - php: '7.4' 32 | wordpress: '5.7.2' 33 | WPGRAPHQL_VERSION: 'v1.5.3' 34 | - php: '7.4' 35 | wordpress: '5.7.2' 36 | WPGRAPHQL_VERSION: 'v1.3.5' 37 | - php: '7.4' 38 | wordpress: '5.7.2' 39 | WPGRAPHQL_VERSION: 'v1.2.6' 40 | - php: '7.4' 41 | wordpress: '5.7.2' 42 | WPGRAPHQL_VERSION: 'v1.1.8' 43 | - php: '7.4' 44 | wordpress: '5.7.2' 45 | WPGRAPHQL_VERSION: 'v1.0.5' 46 | - php: '7.4' 47 | wordpress: '5.7.2' 48 | WPGRAPHQL_VERSION: 'v0.15.5' 49 | - php: '7.4' 50 | wordpress: '5.7.2' 51 | WPGRAPHQL_VERSION: 'v0.14.0' 52 | - php: '7.4' 53 | wordpress: '5.7.2' 54 | WPGRAPHQL_VERSION: 'v0.13.3' 55 | - php: '7.4' 56 | wordpress: '5.7.2' 57 | WPGRAPHQL_VERSION: 'v0.12.3' 58 | - php: '7.4' 59 | wordpress: '5.7.2' 60 | WPGRAPHQL_VERSION: 'v0.11.0' 61 | - php: '7.4' 62 | wordpress: '5.7.2' 63 | WPGRAPHQL_VERSION: 'v0.11.0' 64 | - php: '7.4' 65 | wordpress: '5.5.3' 66 | - php: '7.3' 67 | wordpress: '5.5.3' 68 | exclude: 69 | - php: '8.0' 70 | wordpress: '5.5.3' 71 | - php: '7.3' 72 | wordpress: '6.0' 73 | fail-fast: false 74 | name: WordPress ${{ matrix.wordpress }} on PHP ${{ matrix.php }} 75 | steps: 76 | - name: Checkout 77 | uses: actions/checkout@v2 78 | 79 | - name: Install PHP 80 | uses: shivammathur/setup-php@v2 81 | with: 82 | php-version: ${{ matrix.php }} 83 | tools: composer:v2 84 | extensions: json, mbstring, zip, unzip 85 | 86 | - name: Get Composer Cache Directory 87 | id: composercache 88 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" 89 | 90 | - name: Cache dependencies 91 | uses: actions/cache@v2 92 | with: 93 | path: ${{ steps.composercache.outputs.dir }} 94 | key: php-${{ matrix.php }}-${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 95 | restore-keys: php-${{ matrix.php }}-${{ runner.os }}-composer- 96 | 97 | - name: Install dependencies 98 | run: composer install 99 | 100 | - name: Build container image 101 | env: 102 | PHP_VERSION: ${{ matrix.php }} 103 | WP_VERSION: ${{ matrix.wordpress }} 104 | run: | 105 | docker-compose build \ 106 | --build-arg WP_VERSION=${{ matrix.wordpress }} \ 107 | --build-arg PHP_VERSION=${{ matrix.php }} \ 108 | --build-arg DOCKER_REGISTRY=ghcr.io/wp-graphql/ 109 | 110 | - name: Run Tests w/ Docker. 111 | env: 112 | COVERAGE: ${{ matrix.coverage }} 113 | USING_XDEBUG: ${{ matrix.coverage }} 114 | DEBUG: ${{ matrix.debug }} 115 | SKIP_TESTS_CLEANUP: ${{ matrix.coverage }} 116 | PHP_VERSION: ${{ matrix.php }} 117 | WP_VERSION: ${{ matrix.wordpress }} 118 | DOCKER_REGISTRY: ghcr.io/wp-graphql/ 119 | run: composer run-test 120 | 121 | - name: Push Codecoverage to Coveralls.io 122 | if: ${{ matrix.coverage == 1 }} 123 | env: 124 | COVERALLS_RUN_LOCALLY: 1 125 | COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} 126 | run: vendor/bin/php-coveralls -v 127 | -------------------------------------------------------------------------------- /.github/workflows/upload-schema-artifact.yml: -------------------------------------------------------------------------------- 1 | name: Upload Schema Artifact 2 | 3 | on: 4 | release: 5 | types: [ published ] 6 | 7 | jobs: 8 | run: 9 | runs-on: ubuntu-latest 10 | name: Generate and Upload WPGraphQL for ACF Schema Artifact 11 | services: 12 | mariadb: 13 | image: mariadb 14 | ports: 15 | - 3306:3306 16 | env: 17 | MYSQL_ROOT_PASSWORD: root 18 | # Ensure docker waits for mariadb to start 19 | options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v2 23 | 24 | - name: Setup PHP w/ Composer & WP-CLI 25 | uses: shivammathur/setup-php@v2 26 | with: 27 | php-version: 8.0 28 | extensions: mbstring, intl, bcmath, exif, gd, mysqli, opcache, zip, pdo_mysql 29 | coverage: none 30 | tools: composer, wp-cli 31 | 32 | - name: Setup WordPress 33 | run: | 34 | composer run install-test-env 35 | 36 | - name: Install WP CLI for ACF 37 | run: | 38 | wp plugin install https://github.com/hoppinger/advanced-custom-fields-wpcli/archive/refs/heads/master.zip --activate --path="/tmp/wordpress" 39 | - name: Import test Field Group 40 | run: | 41 | wp acf import --json_file="${GITHUB_WORKSPACE}/docs/field-group-examples-export.json" --path="/tmp/wordpress" 42 | - name: Generate the Static Schema 43 | run: | 44 | cd /tmp/wordpress/ 45 | # Output: /tmp/schema.graphql 46 | wp graphql generate-static-schema 47 | - name: Upload schema as release artifact 48 | uses: softprops/action-gh-release@v1 49 | with: 50 | files: /tmp/schema.graphql 51 | env: 52 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 53 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Listen for Xdebug", 6 | "type": "php", 7 | "request": "launch", 8 | "port": 9003, 9 | "xdebugSettings": { 10 | "max_children": 128, 11 | "max_data": 1024, 12 | "max_depth": 3, 13 | "show_hidden": 1 14 | }, 15 | "pathMappings": { 16 | "/var/www/html/wp-content/plugins/wp-graphql-acf": "${workspaceFolder}", 17 | "/var/www/html/wp-content/plugins/wp-graphql": "${workspaceFolder}../wp-graphql", 18 | "/var/www/html/wp-content/plugins/acf": "${workspaceFolder}/wp-content/plugins/acf", 19 | "/var/www/html": "${workspaceFolder}/wordpress", 20 | } 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "phpcs.standard": "./phpcs.ruleset.xml", 3 | "phpcs.ignorePatterns": ["vendor"], 4 | "phpcs.executablePath": "./vendor/bin/phpcs", 5 | "phpcbf.onsave": true, 6 | "phpcbf.executablePath": "./vendor/bin/phpcbf", 7 | // "phpcbf.standard": "./phpcs.ruleset.xml", 8 | "phpcbf.configSearch": true, 9 | "editor.formatOnSaveTimeout": 5000, 10 | "phpcbf.debug": true, 11 | "editor.formatOnSave": true 12 | } 13 | -------------------------------------------------------------------------------- /DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | # Using Docker For Local Development 2 | 3 | ## WordPress Site 4 | 5 | The `app` docker image starts a running WordPress site with the local wp-graphql-acf directory installed and activated. Local changes to the source code is immediately reflects in the app. 6 | 7 | 1. Build the plugin. 8 | 1.1 `composer install` or `docker run -v $PWD:/app composer --ignore-platform-reqs install` 9 | 1. Run `composer build-app` to build the `app` docker image. 10 | 1. Run `composer build-test` to build the `testing` docker image. 11 | 1. Run `composer run-app` to start the WordPress site. 12 | 1. Browse to http://localhost:8091/ to access the running WordPress app. 13 | 1. Browse to http://localhost:8091/wp-admin/ to access the admin dashboard. Username is 'admin'. Password is 'password'. 14 | 15 | ## Testing Suite 16 | 17 | The `testing` docker image starts a running WordPress and runs the codeception test suites. 18 | 19 | 1. Run `composer build-test` to build the `testing` docker image. 20 | 1. Run `composer run-test` to start the `testing` image and run the codeception tests. 21 | 22 | # Using XDebug 23 | 24 | ## Local WordPress Site With XDebug 25 | Use an environment variable USING_XDEBUG to start the docker image and WordPress with xdebug configured to use port 9003 to communicated with your IDE. 26 | 27 | ``` 28 | export USING_XDEBUG=1 29 | composer run-app 30 | ``` 31 | 32 | Start the debugger in your IDE. Set breakpoints. 33 | 34 | Load the app in http://localhost:8091/. 35 | 36 | ## Using XDebug With Tests 37 | 38 | Use the environment variable USING_XDEBUG to run tests with xdebug configured to use port 9003 to communicated with your IDE. 39 | 40 | ``` 41 | export USING_XDEBUG=1 42 | composer run-test 43 | ``` 44 | 45 | Start the debugger in your IDE. Set breakpoints. 46 | 47 | ## Configure VSCode IDE Launch File 48 | 49 | Create or add the following configuration to your .vscode/launch.json in the root directory. Restart VSCode. Start the debug listener before running the app or testing images. 50 | 51 | If you have WordPress core files in a directory for local development, you can add the location to the `pathMappings` for debug step through. 52 | 53 | ``` 54 | { 55 | "version": "0.2.0", 56 | "configurations": [ 57 | { 58 | "name": "Listen for Xdebug", 59 | "type": "php", 60 | "request": "launch", 61 | "port": 9003, 62 | "xdebugSettings": { 63 | "max_children": 128, 64 | "max_data": 1024, 65 | "max_depth": 3, 66 | "show_hidden": 1 67 | }, 68 | "pathMappings": { 69 | "/var/www/html/wp-content/plugins/wp-graphql-acf": "${workspaceFolder}", 70 | "/var/www/html/wp-content/plugins/wp-graphql": "${workspaceFolder}../wp-graphql", 71 | "/var/www/html": "${workspaceFolder}/wordpress", 72 | } 73 | } 74 | ] 75 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WPGraphQL for Advanced Custom Fields 2 | 3 | ---- 4 | 5 | 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 6 | 7 | This plugin has gone through a complete re-architecture and this repository will soon be archived. 8 | 9 | We recommend you upgrade to the new WPGraphQL for ACF v2.0+ at your earliest convenience. 10 | 11 | The new version contains breaking changes, so update with caution. Below are some resources to help: 12 | 13 | - UPGRADE GUIDE: https://acf.wpgraphql.com/upgrade-guide 14 | - NEW PLUGIN REPO: https://github.com/wp-graphql/wpgraphql-acf 15 | - NEW PLUGIN ON WORDPRESS.ORG: https://wordpress.org/plugins/wpgraphql-acf 16 | - NEW PLUGIN ON COMPOSER: https://packagist.org/packages/wp-graphql/wpgraphql-acf 17 | - NEW PLUGIN ON WPPACKAGIST: https://wpackagist.org/search?q=wpgraphql-acf&type=any&search= 18 | 19 | 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 20 | ---- 21 | 22 | WPGraphQL for Advanced Custom Fields automatically exposes your ACF fields to the WPGraphQL Schema. 23 | 24 | - [Install and Activate](#install-and-activate) 25 | - [Installing from Github](#install-from-github) 26 | - [Installing with Composer](#install-with-composer) 27 | - [Dependencies](#dependencies) 28 | - [Adding Fields to the WPGraphQL Schema](#adding-fields-to-wpgraphql) 29 | - [Supported Fields](#supported-fields) 30 | - [Accordion](./docs/fields/accordion.md) 31 | - [Button Group](./docs/fields/button-group.md) 32 | - [Checkbox](./docs/fields/checkbox.md) 33 | - [Clone](./docs/fields/clone.md) 34 | - [Color Picker](./docs/fields/color-picker.md) 35 | - [Date Picker](./docs/fields/date-picker.md) 36 | - [Date/Time Picker](./docs/fields/date-time-picker.md) 37 | - [Email](./docs/fields/email.md) 38 | - [File](./docs/fields/file.md) 39 | - [Flexible Content](./docs/fields/flexible-content.md) 40 | - [Gallery](./docs/fields/gallery.md) 41 | - [Google Map](./docs/fields/google-map.md) 42 | - [Group](./docs/fields/group.md) 43 | - [Image](./docs/fields/image.md) 44 | - [Link](./docs/fields/link.md) 45 | - [Message](./docs/fields/message.md) 46 | - [Number](./docs/fields/number.md) 47 | - [Oembed](./docs/fields/oembed.md) 48 | - [Page Link](./docs/fields/page-link.md) 49 | - [Password](./docs/fields/password.md) 50 | - [Post Object](./docs/fields/post-object.md) 51 | - [Radio](./docs/fields/radio.md) 52 | - [Range](./docs/fields/range.md) 53 | - [Relationship](./docs/fields/relationship.md) 54 | - [Repeater](./docs/fields/repeater.md) 55 | - [Select](./docs/fields/select.md) 56 | - [Tab](./docs/fields/tab.md) 57 | - [Taxonomy](./docs/fields/taxonomy.md) 58 | - [Text](./docs/fields/text.md) 59 | - [Text Area](./docs/fields/text-area.md) 60 | - [Time Picker](./docs/fields/time-picker.md) 61 | - [True/False](./docs/fields/true-false.md) 62 | - [Url](./docs/fields/url.md) 63 | - [User](./docs/fields/user.md) 64 | - [WYSIWYG](./docs/fields/wysiwyg.md) 65 | - [Options Pages](#options-pages) 66 | - [Location Rules](#location-rules) 67 | 68 | ## Install and Activate 69 | 70 | WPGraphQL for Advanced Custom Fields is not currently available on the WordPress.org repository, so you must download it from Github, or Composer. 71 | 72 | ### Installing From Github 73 | 74 | To install the plugin from Github, you can [download the latest release zip file](https://github.com/wp-graphql/wp-graphql-acf/archive/master.zip), upload the Zip file to your WordPress install, and activate the plugin. 75 | 76 | [Click here](https://wordpress.org/support/article/managing-plugins/) to learn more about installing WordPress plugins from a Zip file. 77 | 78 | ### Installing from Composer 79 | 80 | `composer require wp-graphql/wp-graphql-acf` 81 | 82 | ## Dependencies 83 | 84 | In order to use WPGraphQL for Advanced Custom Fields, you must have [WPGraphQL](https://github.com/wp-graphql/wp-graphql) and [Advanced Custom Fields](https://advancedcustomfields.com) (free or pro) installed and activated. 85 | 86 | ## Adding Fields to the WPGraphQL Schema 87 | 88 | **TL;DR:** [Here's a video](https://www.youtube.com/watch?v=rIg4MHc8elg) showing an overview of usage. 89 | 90 | Advanced Custom Fields, or ACF for short, enables users to add Field Groups, either using a [Graphical User Interface](https://www.advancedcustomfields.com/resources/creating-a-field-group/), [PHP code](https://www.advancedcustomfields.com/resources/register-fields-via-php/), or [local JSON](https://www.advancedcustomfields.com/resources/local-json/) to various screens in the WordPress dashboard, such as (but not limited to) the Edit Post, Edit User and Edit Term screens. 91 | 92 | Whatever method you use to register ACF fields to your WordPress site should work with WPGraphQL for Advanced Custom Fields. For the sake of simplicity, the documentation below will _primarily_ use the Graphic User Interface for examples. 93 | 94 | ### Add ACF Fields to the WPGraphQL Schema 95 | 96 | The first step in using Advanced Custom Fields with WPGraphQL is to [create an ACF Field Group](https://www.advancedcustomfields.com/resources/creating-a-field-group/). 97 | 98 | By default, field groups are _not_ exposed to WPGraphQL. You must opt-in to expose your ACF Field Groups and fields to the WPGraphQL Schema as some information managed by your ACF fields may not be intended for exposure in a queryable API like WPGraphQL. 99 | 100 | #### Show in GraphQL Setting 101 | 102 | To have your ACF Field Group show in the WPGraphQL Schema, you need to configure the Field Group to "Show in GraphQL". 103 | 104 | ##### Using the ACF GUI 105 | 106 | When using the ACF Graphic User Interface for creating fields, WPGraphQL for Advanced Custom Fields adds a **Show in GraphQL** field to Field Groups. 107 | 108 | Setting the value of this field to "Yes" will show the field group in the WPGraphQL Schema, if a [GraphQL Field Name](#graphql-field-name) is also set 109 | 110 |  111 | 112 | ##### Registering Fields in PHP 113 | 114 | When registering ACF Fields in PHP, you need to add `show_in_graphql` and `graphql_field_name` when defining your field group. See below as an example. 115 | 116 | ```php 117 | function my_acf_add_local_field_groups() { 118 | 119 | acf_add_local_field_group(array( 120 | 'key' => 'group_1', 121 | 'title' => 'My Group', 122 | 'show_in_graphql' => true, 123 | 'graphql_field_name' => 'myGroup', 124 | 'fields' => array ( 125 | array ( 126 | 'key' => 'field_1', 127 | 'label' => 'Sub Title', 128 | 'name' => 'sub_title', 129 | 'type' => 'text', 130 | ) 131 | ), 132 | 'location' => array ( 133 | array ( 134 | array ( 135 | 'param' => 'post_type', 136 | 'operator' => '==', 137 | 'value' => 'post', 138 | ), 139 | ), 140 | ), 141 | )); 142 | 143 | } 144 | 145 | add_action('acf/init', 'my_acf_add_local_field_groups'); 146 | ``` 147 | 148 | Each individual field will inherit its GraphQL name from the supplied `name` tag. In this example, `sub_title` will become `subTitle` when requested through GraphQL. If you want more granular control, you can pass `graphql_field_name` to each individual field as well. 149 | 150 | ## Supported Fields 151 | 152 | In order to document interacting with the fields in GraphQL, an example field group has been created with one field of each type. 153 | 154 | To replicate the same field group documented here you can download the [example field group](https://github.com/wp-graphql/wp-graphql-acf/blob/master/docs/field-group-examples-export.json) and [import it](https://support.advancedcustomfields.com/forums/topic/importing-exporting-acf-settings/) into your environment. 155 | 156 | For the sake of documentation, this example field group has the [location rule](#location-rules) set to "Post Type is equal to Post", which will allow for the fields to be entered when creating and editing Posts in the WordPress dashboard, and will expose the fields to the `Post` type in the WPGraphQL Schema. 157 | 158 |  159 | 160 | ## Options Pages 161 | 162 | **Reference**: https://www.advancedcustomfields.com/add-ons/options-page/ 163 | 164 | To add an option page and expose it to the graphql schema, simply add 'show_in_graphql' => true when you register an option page. 165 | 166 | **Example Usage** 167 | 168 | ```php 169 | function register_acf_options_pages() { 170 | 171 | // check function exists 172 | if ( ! function_exists( 'acf_add_options_page' ) ) { 173 | return; 174 | } 175 | 176 | // register options page 177 | $my_options_page = acf_add_options_page( 178 | array( 179 | 'page_title' => __( 'My Options Page' ), 180 | 'menu_title' => __( 'My Options Page' ), 181 | 'menu_slug' => 'my-options-page', 182 | 'capability' => 'edit_posts', 183 | 'show_in_graphql' => true, 184 | ) 185 | ); 186 | } 187 | 188 | add_action( 'acf/init', 'register_acf_options_pages' ) 189 | Example Query 190 | query GetMyOptionsPage { 191 | myOptionsPage { 192 | someCustomField 193 | } 194 | } 195 | ``` 196 | 197 | Alternatively, it's you can check the Fields API Reference to learn about exposing your custom fields to the Schema. 198 | 199 | ## Location Rules 200 | 201 | Advanced Custom Fields field groups are added to the WordPress dashboard by being assigned "Location Rules". 202 | 203 | WPGraphQL for Advanced Custom Fields uses the Location Rules to determine where in the GraphQL Schema the field groups/fields should be added to the Schema. 204 | 205 | For example, if a Field Group were assigned to "Post Type is equal to Post", then the field group would show in the WPGraphQL Schema on the `Post` type, allowing you to query for ACF fields of the Post, anywhere you can interact with the `Post` type in the Schema. 206 | 207 | ### Supported Locations 208 | 209 | @todo: Document supported location rules and how they map from ACF to the WPGraphQL Schema 210 | 211 | ### Why aren't all location rules supported? 212 | 213 | You might notice that some location rules don't add fields to the Schema. This is because some location rules are based on context that doesn't exist when the GraphQL Schema is generated. 214 | 215 | For example, if you have a location rule to show a field group only on a specific page, how would that be exposed the the Schema? There's no Type in the Schema for just one specific page. 216 | 217 | If you're not seeing a field group in the Schema, look at the location rules, and think about _how_ the field group would be added to a Schema that isn't aware of context like which admin page you're on, what category a Post is assigned to, etc. 218 | 219 | If you have ideas on how these specific contextual rules should be handled in WPGraphQL, submit an issue so we can consider how to best support it! 220 | -------------------------------------------------------------------------------- /codeception.dist.yml: -------------------------------------------------------------------------------- 1 | paths: 2 | tests: '%TESTS_DIR%' 3 | output: '%TESTS_OUTPUT%' 4 | data: '%TESTS_DATA%' 5 | support: '%TESTS_SUPPORT%' 6 | envs: '%TESTS_ENVS%' 7 | params: 8 | - .env.testing 9 | actor_suffix: Tester 10 | settings: 11 | colors: true 12 | memory_limit: 1024M 13 | coverage: 14 | enabled: true 15 | remote: false 16 | c3_url: '%WP_URL%/wp-content/plugins/wp-graphql-acf/wp-graphql-acf.php' 17 | include: 18 | - src/* 19 | exclude: 20 | - wp-graphql-acf.php 21 | - vendor/* 22 | show_only_summary: false 23 | extensions: 24 | enabled: 25 | - Codeception\Extension\RunFailed 26 | commands: 27 | - Codeception\Command\GenerateWPUnit 28 | - Codeception\Command\GenerateWPRestApi 29 | - Codeception\Command\GenerateWPRestController 30 | - Codeception\Command\GenerateWPRestPostTypeController 31 | - Codeception\Command\GenerateWPAjax 32 | - Codeception\Command\GenerateWPCanonical 33 | - Codeception\Command\GenerateWPXMLRPC 34 | modules: 35 | config: 36 | WPDb: 37 | dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%' 38 | user: '%DB_USER%' 39 | password: '%DB_PASSWORD%' 40 | populator: 'mysql -u $user -p$password -h $host $dbname < $dump' 41 | dump: 'tests/_data/dump.sql' 42 | populate: false 43 | cleanup: true 44 | waitlock: 0 45 | url: '%WP_URL%' 46 | urlReplacement: true 47 | tablePrefix: '%WP_TABLE_PREFIX%' 48 | WPBrowser: 49 | url: '%WP_URL%' 50 | wpRootFolder: '%WP_ROOT_FOLDER%' 51 | adminUsername: '%ADMIN_USERNAME%' 52 | adminPassword: '%ADMIN_PASSWORD%' 53 | adminPath: '/wp-admin' 54 | cookies: false 55 | REST: 56 | depends: WPBrowser 57 | url: '%WP_URL%' 58 | WPFilesystem: 59 | wpRootFolder: '%WP_ROOT_FOLDER%' 60 | plugins: '/wp-content/plugins' 61 | mu-plugins: '/wp-content/mu-plugins' 62 | themes: '/wp-content/themes' 63 | uploads: '/wp-content/uploads' 64 | WPLoader: 65 | wpRootFolder: '%WP_ROOT_FOLDER%' 66 | dbName: '%TEST_DB_NAME%' 67 | dbHost: '%TEST_DB_HOST%' 68 | dbUser: '%TEST_DB_USER%' 69 | dbPassword: '%TEST_DB_PASSWORD%' 70 | tablePrefix: '%TEST_TABLE_PREFIX%' 71 | domain: '%TEST_SITE_WP_DOMAIN%' 72 | adminEmail: '%TEST_SITE_ADMIN_EMAIL%' 73 | title: 'Test' 74 | plugins: 75 | - wp-graphql-acf/tests/_bootstrap/bootstrap.php 76 | - advanced-custom-fields-pro/acf.php 77 | - wp-graphql/wp-graphql.php 78 | - wp-graphql-acf/wp-graphql-acf.php 79 | activatePlugins: 80 | - wp-graphql-acf/tests/_bootstrap/bootstrap.php 81 | - advanced-custom-fields-pro/acf.php 82 | - wp-graphql/wp-graphql.php 83 | - wp-graphql-acf/wp-graphql-acf.php 84 | configFile: 'tests/_data/config.php' 85 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wp-graphql/wp-graphql-acf", 3 | "description": "Advanced Custom Fields bindings for wp-graphql", 4 | "type": "wordpress-plugin", 5 | "license": "GPL-3.0+", 6 | "authors": [{ 7 | "name": "jasonbahl", 8 | "email": "jasonbahl@mac.com" 9 | }], 10 | "config": { 11 | "optimize-autoloader": true, 12 | "process-timeout": 0, 13 | "allow-plugins": { 14 | "dealerdirect/phpcodesniffer-composer-installer": true, 15 | "phpstan/extension-installer": true 16 | } 17 | }, 18 | "autoload": { 19 | "psr-4": { 20 | "WPGraphQL\\ACF\\": "src/" 21 | }, 22 | "classmap": [ 23 | "src/" 24 | ] 25 | }, 26 | "scripts": { 27 | "install-test-env": "bash bin/install-test-env.sh", 28 | "docker-build": "bash bin/run-docker.sh build", 29 | "docker-run": "bash bin/run-docker.sh run", 30 | "docker-destroy": "docker-compose down", 31 | "build-and-run": [ 32 | "@docker-build", 33 | "@docker-run" 34 | ], 35 | "build-app": "@docker-build -a", 36 | "build-test": "@docker-build -t", 37 | "run-app": "@docker-run -a", 38 | "run-test": "@docker-run -t", 39 | "lint": "vendor/bin/phpcs", 40 | "phpcs-i": [ 41 | "php ./vendor/bin/phpcs -i" 42 | ], 43 | "check-cs": [ 44 | "php ./vendor/bin/phpcs src" 45 | ], 46 | "fix-cs": [ 47 | "php ./vendor/bin/phpcbf src" 48 | ], 49 | "phpstan": ["phpstan analyze --ansi --memory-limit=1G"] 50 | }, 51 | "require": { 52 | "php": "^7.1 || ^8.0" 53 | }, 54 | "require-dev": { 55 | "lucatume/wp-browser": "^2.4", 56 | "codeception/module-asserts": "^1.0", 57 | "codeception/module-phpbrowser": "^1.0", 58 | "codeception/module-webdriver": "^1.0", 59 | "codeception/module-db": "^1.0", 60 | "codeception/module-filesystem": "^1.0", 61 | "codeception/module-cli": "^1.0", 62 | "codeception/util-universalframework": "^1.0", 63 | "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", 64 | "wp-coding-standards/wpcs": "2.1.1", 65 | "phpcompatibility/phpcompatibility-wp": "2.1.0", 66 | "squizlabs/php_codesniffer": "3.5.4", 67 | "phpstan/phpstan": "^0.12.64", 68 | "phpunit/phpunit": "^8.5", 69 | "szepeviktor/phpstan-wordpress": "^0.7.1", 70 | "codeception/module-rest": "^1.2", 71 | "wp-graphql/wp-graphql-testcase": "~2.1", 72 | "simpod/php-coveralls-mirror": "^3.0", 73 | "phpstan/extension-installer": "^1.1" 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.3' 2 | 3 | services: 4 | app: 5 | depends_on: 6 | - app_db 7 | build: 8 | context: . 9 | dockerfile: docker/Dockerfile 10 | image: wp-graphql-acf:latest-wp${WP_VERSION}-php${PHP_VERSION} 11 | volumes: 12 | - '.:/var/www/html/wp-content/plugins/wp-graphql-acf' 13 | - './.log/app:/var/log/apache2' 14 | env_file: 15 | - .env.dist 16 | environment: 17 | USING_XDEBUG: ${USING_XDEBUG:-} 18 | ports: 19 | - '8091:80' 20 | networks: 21 | local: 22 | 23 | app_db: 24 | image: mariadb:10.2 25 | env_file: 26 | - .env.dist 27 | ports: 28 | - '3306' 29 | networks: 30 | local: 31 | 32 | testing: 33 | depends_on: 34 | - testing_db 35 | build: 36 | context: . 37 | dockerfile: docker/Dockerfile.testing 38 | image: wp-graphql-acf-testing:latest-wp${WP_VERSION}-php${PHP_VERSION} 39 | volumes: 40 | - '.:/var/www/html/wp-content/plugins/wp-graphql-acf' 41 | - './.log/testing:/var/log/apache2' 42 | - './codeception.dist.yml:/var/www/html/wp-content/plugins/wp-graphql-acf/codeception.yml' 43 | env_file: 44 | - .env.testing 45 | environment: 46 | WP_URL: http://localhost 47 | USING_XDEBUG: ${USING_XDEBUG:-} 48 | networks: 49 | local: 50 | 51 | testing_db: 52 | image: mariadb:10.2 53 | env_file: 54 | - .env.testing 55 | ports: 56 | - '3306' 57 | networks: 58 | local: 59 | 60 | networks: 61 | local: 62 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG WP_VERSION 2 | ARG PHP_VERSION 3 | ARG DOCKER_REGISTRY 4 | 5 | FROM ${DOCKER_REGISTRY:-}wp-graphql:latest-wp${WP_VERSION}-php${PHP_VERSION} 6 | 7 | # Move the base image app setup script out of the way 8 | # Put our shell script in place which will invoke the base image script 9 | RUN cp /usr/local/bin/app-setup.sh /usr/local/bin/original-app-setup.sh 10 | COPY docker/app.setup.sh /usr/local/bin/app-setup.sh 11 | -------------------------------------------------------------------------------- /docker/Dockerfile.testing: -------------------------------------------------------------------------------- 1 | ARG WP_VERSION 2 | ARG PHP_VERSION 3 | ARG DOCKER_REGISTRY 4 | 5 | FROM ${DOCKER_REGISTRY:-}wp-graphql-testing:latest-wp${WP_VERSION}-php${PHP_VERSION} 6 | 7 | # Move the base image app setup script out of the way 8 | # Put our shell script in place which will invoke the base image script 9 | RUN cp /usr/local/bin/app-setup.sh /usr/local/bin/original-app-setup.sh 10 | COPY docker/app.setup.sh /usr/local/bin/app-setup.sh 11 | 12 | ENV PROJECT_DIR="${PLUGINS_DIR}/wp-graphql-acf" 13 | 14 | RUN echo "pcov.directory = /var/www/html/wp-content/plugins/wp-graphql-acf" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini 15 | -------------------------------------------------------------------------------- /docker/app.setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script is run by the wp-graphql entrypoint.sh script as app-setup.sh. 3 | 4 | # Run the base wp-graphql image setup script then our setup. 5 | . /usr/local/bin/original-app-setup.sh 6 | 7 | PLUGINS_DIR=${PLUGINS_DIR-.} 8 | echo "Plugins dir ($PLUGINS_DIR)" 9 | 10 | if [ ! -f "${PLUGINS_DIR}/wp-graphql/wp-graphql.php" ]; then 11 | # WPGRAPHQL_VERSION in format like v1.2.3 or latest 12 | echo "Install wp-graphql version (${WPGRAPHQL_VERSION})" 13 | if [[ -z ${WPGRAPHQL_VERSION} || "${WPGRAPHQL_VERSION}" == "latest" ]]; then 14 | echo "Installing latest WPGraphQL from WordPress.org" 15 | wp plugin install wp-graphql --activate --allow-root 16 | else 17 | echo "Installing WPGraphQL from Github" 18 | wp plugin install "https://downloads.wordpress.org/plugin/wp-graphql.${WPGRAPHQL_VERSION-1.4.3}.zip" --allow-root 19 | fi 20 | fi 21 | 22 | # Activate the plugin 23 | wp plugin install advanced-custom-fields --activate --allow-root 24 | wp plugin activate wp-graphql-acf --allow-root 25 | 26 | # Some version of acf-pro that let's tests pass. 27 | wp plugin install https://github.com/wp-premium/advanced-custom-fields-pro/archive/refs/heads/master.zip --activate --allow-root 28 | -------------------------------------------------------------------------------- /docs/field-group-examples-export.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "key": "group_60468a2b40d13", 4 | "title": "ACF Docs", 5 | "fields": [ 6 | { 7 | "key": "field_60468a428ad20", 8 | "label": "Text", 9 | "name": "text", 10 | "type": "text", 11 | "instructions": "", 12 | "required": 0, 13 | "conditional_logic": 0, 14 | "wrapper": { 15 | "width": "", 16 | "class": "", 17 | "id": "" 18 | }, 19 | "show_in_graphql": 1, 20 | "default_value": "", 21 | "placeholder": "", 22 | "prepend": "", 23 | "append": "", 24 | "maxlength": "" 25 | }, 26 | { 27 | "key": "field_60468c101f5bc", 28 | "label": "Text Area", 29 | "name": "text_area", 30 | "type": "textarea", 31 | "instructions": "", 32 | "required": 0, 33 | "conditional_logic": 0, 34 | "wrapper": { 35 | "width": "", 36 | "class": "", 37 | "id": "" 38 | }, 39 | "show_in_graphql": 1, 40 | "default_value": "", 41 | "placeholder": "", 42 | "maxlength": "", 43 | "rows": "", 44 | "new_lines": "" 45 | }, 46 | { 47 | "key": "field_60468c261f5bd", 48 | "label": "Number", 49 | "name": "number", 50 | "type": "number", 51 | "instructions": "", 52 | "required": 0, 53 | "conditional_logic": 0, 54 | "wrapper": { 55 | "width": "", 56 | "class": "", 57 | "id": "" 58 | }, 59 | "show_in_graphql": 1, 60 | "default_value": "", 61 | "placeholder": "", 62 | "prepend": "", 63 | "append": "", 64 | "min": "", 65 | "max": "", 66 | "step": "" 67 | }, 68 | { 69 | "key": "field_60468c7d1f5be", 70 | "label": "Range", 71 | "name": "range", 72 | "type": "range", 73 | "instructions": "", 74 | "required": 0, 75 | "conditional_logic": 0, 76 | "wrapper": { 77 | "width": "", 78 | "class": "", 79 | "id": "" 80 | }, 81 | "show_in_graphql": 1, 82 | "default_value": "", 83 | "min": "", 84 | "max": "", 85 | "step": "", 86 | "prepend": "", 87 | "append": "" 88 | }, 89 | { 90 | "key": "field_60468d7ed5271", 91 | "label": "Email", 92 | "name": "email", 93 | "type": "email", 94 | "instructions": "", 95 | "required": 0, 96 | "conditional_logic": 0, 97 | "wrapper": { 98 | "width": "", 99 | "class": "", 100 | "id": "" 101 | }, 102 | "show_in_graphql": 1, 103 | "default_value": "", 104 | "placeholder": "", 105 | "prepend": "", 106 | "append": "" 107 | }, 108 | { 109 | "key": "field_60468db4a3624", 110 | "label": "Url", 111 | "name": "url", 112 | "type": "url", 113 | "instructions": "", 114 | "required": 0, 115 | "conditional_logic": 0, 116 | "wrapper": { 117 | "width": "", 118 | "class": "", 119 | "id": "" 120 | }, 121 | "show_in_graphql": 1, 122 | "default_value": "", 123 | "placeholder": "" 124 | }, 125 | { 126 | "key": "field_60468dd9a7390", 127 | "label": "Password", 128 | "name": "password", 129 | "type": "password", 130 | "instructions": "", 131 | "required": 0, 132 | "conditional_logic": 0, 133 | "wrapper": { 134 | "width": "", 135 | "class": "", 136 | "id": "" 137 | }, 138 | "show_in_graphql": 1, 139 | "placeholder": "", 140 | "prepend": "", 141 | "append": "" 142 | }, 143 | { 144 | "key": "field_60468e38c3039", 145 | "label": "Image", 146 | "name": "image", 147 | "type": "image", 148 | "instructions": "", 149 | "required": 0, 150 | "conditional_logic": 0, 151 | "wrapper": { 152 | "width": "", 153 | "class": "", 154 | "id": "" 155 | }, 156 | "show_in_graphql": 1, 157 | "return_format": "array", 158 | "preview_size": "medium", 159 | "library": "all", 160 | "min_width": "", 161 | "min_height": "", 162 | "min_size": "", 163 | "max_width": "", 164 | "max_height": "", 165 | "max_size": "", 166 | "mime_types": "" 167 | }, 168 | { 169 | "key": "field_6046909b38734", 170 | "label": "File", 171 | "name": "file", 172 | "type": "file", 173 | "instructions": "", 174 | "required": 0, 175 | "conditional_logic": 0, 176 | "wrapper": { 177 | "width": "", 178 | "class": "", 179 | "id": "" 180 | }, 181 | "show_in_graphql": 1, 182 | "return_format": "array", 183 | "library": "all", 184 | "min_size": "", 185 | "max_size": "", 186 | "mime_types": "" 187 | }, 188 | { 189 | "key": "field_604690bb38735", 190 | "label": "Wysiwyg", 191 | "name": "wysiwyg", 192 | "type": "wysiwyg", 193 | "instructions": "", 194 | "required": 0, 195 | "conditional_logic": 0, 196 | "wrapper": { 197 | "width": "", 198 | "class": "", 199 | "id": "" 200 | }, 201 | "show_in_graphql": 1, 202 | "default_value": "", 203 | "tabs": "all", 204 | "toolbar": "full", 205 | "media_upload": 1, 206 | "delay": 0 207 | }, 208 | { 209 | "key": "field_604690cd38736", 210 | "label": "Oembed", 211 | "name": "oembed", 212 | "type": "oembed", 213 | "instructions": "", 214 | "required": 0, 215 | "conditional_logic": 0, 216 | "wrapper": { 217 | "width": "", 218 | "class": "", 219 | "id": "" 220 | }, 221 | "show_in_graphql": 1, 222 | "width": "", 223 | "height": "" 224 | }, 225 | { 226 | "key": "field_6047cac3147ba", 227 | "label": "Gallery", 228 | "name": "gallery", 229 | "type": "gallery", 230 | "instructions": "", 231 | "required": 0, 232 | "conditional_logic": 0, 233 | "wrapper": { 234 | "width": "", 235 | "class": "", 236 | "id": "" 237 | }, 238 | "show_in_graphql": 1, 239 | "return_format": "array", 240 | "preview_size": "medium", 241 | "insert": "append", 242 | "library": "all", 243 | "min": "", 244 | "max": "", 245 | "min_width": "", 246 | "min_height": "", 247 | "min_size": "", 248 | "max_width": "", 249 | "max_height": "", 250 | "max_size": "", 251 | "mime_types": "" 252 | }, 253 | { 254 | "key": "field_604690da38737", 255 | "label": "Select", 256 | "name": "select", 257 | "type": "select", 258 | "instructions": "", 259 | "required": 0, 260 | "conditional_logic": 0, 261 | "wrapper": { 262 | "width": "", 263 | "class": "", 264 | "id": "" 265 | }, 266 | "show_in_graphql": 1, 267 | "choices": { 268 | "choice_1": "Choice 1", 269 | "choice_2": "Choice 2" 270 | }, 271 | "default_value": false, 272 | "allow_null": 0, 273 | "multiple": 0, 274 | "ui": 0, 275 | "return_format": "value", 276 | "ajax": 0, 277 | "placeholder": "" 278 | }, 279 | { 280 | "key": "field_60469107346a9", 281 | "label": "Checkbox", 282 | "name": "checkbox", 283 | "type": "checkbox", 284 | "instructions": "", 285 | "required": 0, 286 | "conditional_logic": 0, 287 | "wrapper": { 288 | "width": "", 289 | "class": "", 290 | "id": "" 291 | }, 292 | "show_in_graphql": 1, 293 | "choices": { 294 | "choice_1": "Choice 1", 295 | "choice_2": "Choice 2" 296 | }, 297 | "allow_custom": 0, 298 | "default_value": [], 299 | "layout": "vertical", 300 | "toggle": 0, 301 | "return_format": "value", 302 | "save_custom": 0 303 | }, 304 | { 305 | "key": "field_6046914753efc", 306 | "label": "Radio Button", 307 | "name": "radio_button", 308 | "type": "radio", 309 | "instructions": "", 310 | "required": 0, 311 | "conditional_logic": 0, 312 | "wrapper": { 313 | "width": "", 314 | "class": "", 315 | "id": "" 316 | }, 317 | "show_in_graphql": 1, 318 | "choices": { 319 | "choice_1": "Choice 1", 320 | "choice_2": "Choice 2" 321 | }, 322 | "allow_null": 0, 323 | "other_choice": 0, 324 | "default_value": "", 325 | "layout": "vertical", 326 | "return_format": "value", 327 | "save_other_choice": 0 328 | }, 329 | { 330 | "key": "field_6046917b53efd", 331 | "label": "Button Group", 332 | "name": "button_group", 333 | "type": "button_group", 334 | "instructions": "", 335 | "required": 0, 336 | "conditional_logic": 0, 337 | "wrapper": { 338 | "width": "", 339 | "class": "", 340 | "id": "" 341 | }, 342 | "show_in_graphql": 1, 343 | "choices": { 344 | "choice_1": "Choice 1", 345 | "choice_2": "Choice 2" 346 | }, 347 | "allow_null": 0, 348 | "default_value": "", 349 | "layout": "horizontal", 350 | "return_format": "value" 351 | }, 352 | { 353 | "key": "field_604691d753ce6", 354 | "label": "True False", 355 | "name": "true_false", 356 | "type": "true_false", 357 | "instructions": "", 358 | "required": 0, 359 | "conditional_logic": 0, 360 | "wrapper": { 361 | "width": "", 362 | "class": "", 363 | "id": "" 364 | }, 365 | "show_in_graphql": 1, 366 | "message": "", 367 | "default_value": 0, 368 | "ui": 0, 369 | "ui_on_text": "", 370 | "ui_off_text": "" 371 | }, 372 | { 373 | "key": "field_6046928a53ce7", 374 | "label": "Link", 375 | "name": "link", 376 | "type": "link", 377 | "instructions": "", 378 | "required": 0, 379 | "conditional_logic": 0, 380 | "wrapper": { 381 | "width": "", 382 | "class": "", 383 | "id": "" 384 | }, 385 | "show_in_graphql": 1, 386 | "return_format": "array" 387 | }, 388 | { 389 | "key": "field_604692a202533", 390 | "label": "Post Object", 391 | "name": "post_object", 392 | "type": "post_object", 393 | "instructions": "", 394 | "required": 0, 395 | "conditional_logic": 0, 396 | "wrapper": { 397 | "width": "", 398 | "class": "", 399 | "id": "" 400 | }, 401 | "show_in_graphql": 1, 402 | "post_type": [ 403 | "post", 404 | "page" 405 | ], 406 | "taxonomy": "", 407 | "allow_null": 0, 408 | "multiple": 1, 409 | "return_format": "object", 410 | "ui": 1 411 | }, 412 | { 413 | "key": "field_60469560e9da6", 414 | "label": "Page Link", 415 | "name": "page_link", 416 | "type": "page_link", 417 | "instructions": "", 418 | "required": 0, 419 | "conditional_logic": 0, 420 | "wrapper": { 421 | "width": "", 422 | "class": "", 423 | "id": "" 424 | }, 425 | "show_in_graphql": 1, 426 | "post_type": [ 427 | "post", 428 | "page" 429 | ], 430 | "taxonomy": "", 431 | "allow_null": 0, 432 | "allow_archives": 1, 433 | "multiple": 0 434 | }, 435 | { 436 | "key": "field_60469ad3e9da7", 437 | "label": "Relationship", 438 | "name": "relationship", 439 | "type": "relationship", 440 | "instructions": "", 441 | "required": 0, 442 | "conditional_logic": 0, 443 | "wrapper": { 444 | "width": "", 445 | "class": "", 446 | "id": "" 447 | }, 448 | "show_in_graphql": 1, 449 | "post_type": [ 450 | "post", 451 | "page" 452 | ], 453 | "taxonomy": "", 454 | "filters": [ 455 | "search", 456 | "post_type", 457 | "taxonomy" 458 | ], 459 | "elements": "", 460 | "min": "", 461 | "max": "", 462 | "return_format": "object" 463 | }, 464 | { 465 | "key": "field_60469bf265bd6", 466 | "label": "Taxonomy", 467 | "name": "taxonomy", 468 | "type": "taxonomy", 469 | "instructions": "", 470 | "required": 0, 471 | "conditional_logic": 0, 472 | "wrapper": { 473 | "width": "", 474 | "class": "", 475 | "id": "" 476 | }, 477 | "show_in_graphql": 1, 478 | "taxonomy": "category", 479 | "field_type": "checkbox", 480 | "add_term": 1, 481 | "save_terms": 0, 482 | "load_terms": 0, 483 | "return_format": "id", 484 | "multiple": 0, 485 | "allow_null": 0 486 | }, 487 | { 488 | "key": "field_60469c1665bd7", 489 | "label": "User", 490 | "name": "user", 491 | "type": "user", 492 | "instructions": "", 493 | "required": 0, 494 | "conditional_logic": 0, 495 | "wrapper": { 496 | "width": "", 497 | "class": "", 498 | "id": "" 499 | }, 500 | "show_in_graphql": 1, 501 | "role": "", 502 | "allow_null": 0, 503 | "multiple": 1, 504 | "return_format": "array" 505 | }, 506 | { 507 | "key": "field_60469c2065bd8", 508 | "label": "Google Map", 509 | "name": "google_map", 510 | "type": "google_map", 511 | "instructions": "", 512 | "required": 0, 513 | "conditional_logic": 0, 514 | "wrapper": { 515 | "width": "", 516 | "class": "", 517 | "id": "" 518 | }, 519 | "show_in_graphql": 1, 520 | "center_lat": "", 521 | "center_lng": "", 522 | "zoom": "", 523 | "height": "" 524 | }, 525 | { 526 | "key": "field_60469d0dc197a", 527 | "label": "Date Picker", 528 | "name": "date_picker", 529 | "type": "date_picker", 530 | "instructions": "", 531 | "required": 0, 532 | "conditional_logic": 0, 533 | "wrapper": { 534 | "width": "", 535 | "class": "", 536 | "id": "" 537 | }, 538 | "show_in_graphql": 1, 539 | "display_format": "d\/m\/Y", 540 | "return_format": "d\/m\/Y", 541 | "first_day": 1 542 | }, 543 | { 544 | "key": "field_60469d19c197b", 545 | "label": "Date Time Picker", 546 | "name": "date_time_picker", 547 | "type": "date_time_picker", 548 | "instructions": "", 549 | "required": 0, 550 | "conditional_logic": 0, 551 | "wrapper": { 552 | "width": "", 553 | "class": "", 554 | "id": "" 555 | }, 556 | "show_in_graphql": 1, 557 | "display_format": "d\/m\/Y g:i a", 558 | "return_format": "d\/m\/Y g:i a", 559 | "first_day": 1 560 | }, 561 | { 562 | "key": "field_60469d27c197c", 563 | "label": "Time Picker", 564 | "name": "time_picker", 565 | "type": "time_picker", 566 | "instructions": "", 567 | "required": 0, 568 | "conditional_logic": 0, 569 | "wrapper": { 570 | "width": "", 571 | "class": "", 572 | "id": "" 573 | }, 574 | "show_in_graphql": 1, 575 | "display_format": "g:i a", 576 | "return_format": "g:i a" 577 | }, 578 | { 579 | "key": "field_60469d34c197d", 580 | "label": "Color Picker", 581 | "name": "color_picker", 582 | "type": "color_picker", 583 | "instructions": "", 584 | "required": 0, 585 | "conditional_logic": 0, 586 | "wrapper": { 587 | "width": "", 588 | "class": "", 589 | "id": "" 590 | }, 591 | "show_in_graphql": 1, 592 | "default_value": "" 593 | }, 594 | { 595 | "key": "field_60469d5933bce", 596 | "label": "Group", 597 | "name": "group", 598 | "type": "group", 599 | "instructions": "", 600 | "required": 0, 601 | "conditional_logic": 0, 602 | "wrapper": { 603 | "width": "", 604 | "class": "", 605 | "id": "" 606 | }, 607 | "show_in_graphql": 1, 608 | "layout": "block", 609 | "sub_fields": [ 610 | { 611 | "key": "field_6047ecb8e5cbc", 612 | "label": "Text Field In Group", 613 | "name": "text_field_in_group", 614 | "type": "text", 615 | "instructions": "", 616 | "required": 0, 617 | "conditional_logic": 0, 618 | "wrapper": { 619 | "width": "", 620 | "class": "", 621 | "id": "" 622 | }, 623 | "show_in_graphql": 1, 624 | "default_value": "", 625 | "placeholder": "", 626 | "prepend": "", 627 | "append": "", 628 | "maxlength": "" 629 | }, 630 | { 631 | "key": "field_6047eccce5cbd", 632 | "label": "Text Area Field In Group", 633 | "name": "text_area_field_in_group", 634 | "type": "textarea", 635 | "instructions": "", 636 | "required": 0, 637 | "conditional_logic": 0, 638 | "wrapper": { 639 | "width": "", 640 | "class": "", 641 | "id": "" 642 | }, 643 | "show_in_graphql": 1, 644 | "default_value": "", 645 | "placeholder": "", 646 | "maxlength": "", 647 | "rows": "", 648 | "new_lines": "" 649 | } 650 | ] 651 | }, 652 | { 653 | "key": "field_6047cb430101c", 654 | "label": "Repeater", 655 | "name": "repeater", 656 | "type": "repeater", 657 | "instructions": "", 658 | "required": 0, 659 | "conditional_logic": 0, 660 | "wrapper": { 661 | "width": "", 662 | "class": "", 663 | "id": "" 664 | }, 665 | "show_in_graphql": 1, 666 | "collapsed": "", 667 | "min": 0, 668 | "max": 0, 669 | "layout": "table", 670 | "button_label": "", 671 | "sub_fields": [ 672 | { 673 | "key": "field_6047cb620101d", 674 | "label": "Text Field In Repeater", 675 | "name": "text_field_in_repeater", 676 | "type": "text", 677 | "instructions": "", 678 | "required": 0, 679 | "conditional_logic": 0, 680 | "wrapper": { 681 | "width": "", 682 | "class": "", 683 | "id": "" 684 | }, 685 | "show_in_graphql": 1, 686 | "default_value": "", 687 | "placeholder": "", 688 | "prepend": "", 689 | "append": "", 690 | "maxlength": "" 691 | }, 692 | { 693 | "key": "field_6047cb740101e", 694 | "label": "Image Field In Repeater", 695 | "name": "image_field_in_repeater", 696 | "type": "image", 697 | "instructions": "", 698 | "required": 0, 699 | "conditional_logic": 0, 700 | "wrapper": { 701 | "width": "", 702 | "class": "", 703 | "id": "" 704 | }, 705 | "show_in_graphql": 1, 706 | "return_format": "array", 707 | "preview_size": "medium", 708 | "library": "all", 709 | "min_width": "", 710 | "min_height": "", 711 | "min_size": "", 712 | "max_width": "", 713 | "max_height": "", 714 | "max_size": "", 715 | "mime_types": "" 716 | } 717 | ] 718 | }, 719 | { 720 | "key": "field_6047cb92951ce", 721 | "label": "Flexible Content", 722 | "name": "flexible_content", 723 | "type": "flexible_content", 724 | "instructions": "", 725 | "required": 0, 726 | "conditional_logic": 0, 727 | "wrapper": { 728 | "width": "", 729 | "class": "", 730 | "id": "" 731 | }, 732 | "show_in_graphql": 1, 733 | "layouts": { 734 | "layout_6047cb980608a": { 735 | "key": "layout_6047cb980608a", 736 | "name": "layout_one", 737 | "label": "Layout One", 738 | "display": "block", 739 | "sub_fields": [ 740 | { 741 | "key": "field_6047cc58951cf", 742 | "label": "Text", 743 | "name": "text", 744 | "type": "text", 745 | "instructions": "", 746 | "required": 0, 747 | "conditional_logic": 0, 748 | "wrapper": { 749 | "width": "", 750 | "class": "", 751 | "id": "" 752 | }, 753 | "show_in_graphql": 1, 754 | "default_value": "", 755 | "placeholder": "", 756 | "prepend": "", 757 | "append": "", 758 | "maxlength": "" 759 | }, 760 | { 761 | "key": "field_6047cc9b951d0", 762 | "label": "Another Text Field", 763 | "name": "another_text_field", 764 | "type": "text", 765 | "instructions": "", 766 | "required": 0, 767 | "conditional_logic": 0, 768 | "wrapper": { 769 | "width": "", 770 | "class": "", 771 | "id": "" 772 | }, 773 | "show_in_graphql": 1, 774 | "default_value": "", 775 | "placeholder": "", 776 | "prepend": "", 777 | "append": "", 778 | "maxlength": "" 779 | } 780 | ], 781 | "min": "", 782 | "max": "" 783 | }, 784 | "layout_6047eee191715": { 785 | "key": "layout_6047eee191715", 786 | "name": "layout_two", 787 | "label": "Layout Two", 788 | "display": "block", 789 | "sub_fields": [ 790 | { 791 | "key": "field_6047eeeb91716", 792 | "label": "Image", 793 | "name": "image", 794 | "type": "image", 795 | "instructions": "", 796 | "required": 0, 797 | "conditional_logic": 0, 798 | "wrapper": { 799 | "width": "", 800 | "class": "", 801 | "id": "" 802 | }, 803 | "show_in_graphql": 1, 804 | "return_format": "array", 805 | "preview_size": "medium", 806 | "library": "all", 807 | "min_width": "", 808 | "min_height": "", 809 | "min_size": "", 810 | "max_width": "", 811 | "max_height": "", 812 | "max_size": "", 813 | "mime_types": "" 814 | } 815 | ], 816 | "min": "", 817 | "max": "" 818 | }, 819 | "layout_6047eefa91717": { 820 | "key": "layout_6047eefa91717", 821 | "name": "layout_three", 822 | "label": "Layout Three", 823 | "display": "block", 824 | "sub_fields": [ 825 | { 826 | "key": "field_6047ef0291718", 827 | "label": "Gallery", 828 | "name": "gallery", 829 | "type": "gallery", 830 | "instructions": "", 831 | "required": 0, 832 | "conditional_logic": 0, 833 | "wrapper": { 834 | "width": "", 835 | "class": "", 836 | "id": "" 837 | }, 838 | "show_in_graphql": 1, 839 | "return_format": "array", 840 | "preview_size": "medium", 841 | "insert": "append", 842 | "library": "all", 843 | "min": "", 844 | "max": "", 845 | "min_width": "", 846 | "min_height": "", 847 | "min_size": "", 848 | "max_width": "", 849 | "max_height": "", 850 | "max_size": "", 851 | "mime_types": "" 852 | } 853 | ], 854 | "min": "", 855 | "max": "" 856 | } 857 | }, 858 | "button_label": "Add Row", 859 | "min": "", 860 | "max": "" 861 | } 862 | ], 863 | "location": [ 864 | [ 865 | { 866 | "param": "post_type", 867 | "operator": "==", 868 | "value": "post" 869 | } 870 | ] 871 | ], 872 | "menu_order": 0, 873 | "position": "normal", 874 | "style": "default", 875 | "label_placement": "top", 876 | "instruction_placement": "label", 877 | "hide_on_screen": "", 878 | "active": true, 879 | "description": "ACF Documentation Examples", 880 | "show_in_graphql": 1, 881 | "graphql_field_name": "acfDocs" 882 | } 883 | ] -------------------------------------------------------------------------------- /docs/fields/accordion.md: -------------------------------------------------------------------------------- 1 | # Accordion 2 | 3 | The Accordion Field in Advanced Custom Fields that lets users separate other fields in collapsible 4 | sections. 5 | 6 | This field is for administrative display purposes and is not exposed in WPGraphQL. 7 | 8 | ---- 9 | 10 | - **Next Field:** [Button Group](./button-group.md) 11 | -------------------------------------------------------------------------------- /docs/fields/button-group.md: -------------------------------------------------------------------------------- 1 | # Button Group Field 2 | 3 | Button Group fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | Button Group fields can be queried and a String will be returned. 6 | 7 | Here, we have a Button Group field named `button_group` on the Post Edit screen within the "ACF Docs" Field Group, and "Choice 2" is selected. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | buttonGroup 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "buttonGroup": "choice_2" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Accordion](./accordion.md) 40 | - **Next Field:** [Checkbox](./checkbox.md) 41 | 42 | -------------------------------------------------------------------------------- /docs/fields/checkbox.md: -------------------------------------------------------------------------------- 1 | # Checkbox Field 2 | 3 | Checkbox fields are added to the WPGraphQL Schema as a field with the Type `[ 'list_of' => 'String' ]`. 4 | 5 | Checkbox fields can be queried and a list (array) of Strings (the selected values) will be returned. 6 | 7 | Here, we have a Checkbox field named `checkbox` on the Post Edit screen within the "ACF Docs" Field Group, and "Choice 1" is selected. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | checkbox 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "checkbox": [ 31 | "choice_1" 32 | ] 33 | } 34 | } 35 | } 36 | } 37 | ``` 38 | 39 | ---- 40 | 41 | - **Previous Field:** [Button Group](./button-group.md) 42 | - **Next Field:** [Clone](./clone.md) 43 | 44 | -------------------------------------------------------------------------------- /docs/fields/clone.md: -------------------------------------------------------------------------------- 1 | # Clone Field 2 | 3 | The clone field is not fully supported (yet). We plan to support it in the future. 4 | 5 | ---- 6 | 7 | - **Previous Field:** [Checkbox](./checkbox.md) 8 | - **Next Field:** [Color Picker](./color-picker.md) 9 | 10 | -------------------------------------------------------------------------------- /docs/fields/color-picker.md: -------------------------------------------------------------------------------- 1 | # Color Picker Field 2 | 3 | The Color Picker field is added to the WPGraphQL Schema as field with the Type `String`. 4 | 5 | Color Picker fields can be queried and a String will be returned. 6 | 7 | Here, we have a Color Picker field named `color_picker` on the Post Edit screen within the "ACF Docs" Field Group, and "#dd3333" is the value. 8 | 9 |  10 | 11 | This field can be queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | colorPicker 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the result of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "colorPicker": "12:30 am" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Clone](./clone.md) 40 | - **Next Field:** [Date Picker](./date-picker.md) 41 | -------------------------------------------------------------------------------- /docs/fields/date-picker.md: -------------------------------------------------------------------------------- 1 | # Date Picker Field 2 | 3 | The Date Picker field is added to the WPGraphQL Schema as field with the Type `String`. 4 | 5 | Date Picker fields can be queried and a String will be returned. 6 | 7 | Here, we have a Date Picker field named `date_picker` on the Post Edit screen within the "ACF Docs" Field Group, and "13/03/2020" is the date set. 8 | 9 |  10 | 11 | This field can be queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | datePicker 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the result of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "datePicker": "13/03/2020" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Color Picker](./color-picker.md) 40 | - **Next Field:** [Date/Time Picker](./date-time-picker.md) 41 | -------------------------------------------------------------------------------- /docs/fields/date-time-picker.md: -------------------------------------------------------------------------------- 1 | # Date/Time Picker Field 2 | 3 | The Date/Time Picker field is added to the WPGraphQL Schema as field with the Type `String`. 4 | 5 | Date/Time Picker fields can be queried, and a String will be returned. 6 | 7 | Here, we have a Date/Time Picker field named `date_time_picker` on the Post Edit screen within the "ACF Docs" Field Group, and "20/03/2020 8:15 am" is the value. 8 | 9 |  10 | 11 | This field can be queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | dateTimePicker 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the result of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "dateTimePicker": "20/03/2020 8:15 am" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Date Picker](./date-picker.md) 40 | - **Next Field:** [Email](./email.md) 41 | -------------------------------------------------------------------------------- /docs/fields/email.md: -------------------------------------------------------------------------------- 1 | # Email Field 2 | 3 | Email fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | Email fields can be queried and a String will be returned. 6 | 7 | Here, we have an Email field named `email` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post( id: "acf-example-test" idType: URI ) { 16 | acfDocs { 17 | email 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "email": "test@example.com" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Date/Time Picker](./date-time-picker.md) 40 | - **Next Field:** [File](./file.md) 41 | -------------------------------------------------------------------------------- /docs/fields/file.md: -------------------------------------------------------------------------------- 1 | # File Field 2 | 3 | File fields are added to the WPGraphQL Schema as a field with the Type `MediaItem`. 4 | 5 | File fields can be queried and a MediaItem will be returned. 6 | 7 | The `MediaItem` type is an Object type that has it's own fields that can be selected. So, instead of _just_ getting the File ID returned and having to ask for the MediaItem object in a follow-up request, we can ask for fields available on the MediaItem Type. For this example, we ask for the `id` and `mediaItemUrl`. 8 | 9 | Here, we have a File field named `file` on the Post Edit screen within the "ACF Docs" Field Group. 10 | 11 |  12 | 13 | This field can be Queried in GraphQL like so: 14 | 15 | ```graphql 16 | { 17 | post(id: "acf-example-test", idType: URI) { 18 | acfDocs { 19 | file { 20 | id 21 | mediaItemUrl 22 | } 23 | } 24 | } 25 | } 26 | ``` 27 | 28 | And the results of the query would be: 29 | 30 | ```json 31 | { 32 | "data": { 33 | "post": { 34 | "acfDocs": { 35 | "file": { 36 | "id": "YXR0YWNobWVudDozMjQ=", 37 | "mediaItemUrl": "http://acf2.local/wp-content/uploads/2020/03/little-ceasars-receipt-01282020.pdf" 38 | } 39 | } 40 | } 41 | } 42 | } 43 | ``` 44 | 45 | ---- 46 | 47 | - **Previous Field:** [Email](./email.md) 48 | - **Next Field:** [Flexible Content](./flexible-content.md) 49 | -------------------------------------------------------------------------------- /docs/fields/flexible-content.md: -------------------------------------------------------------------------------- 1 | # Flexible Content Field 2 | 3 | The Flexible Content is a powerful ACF field that allows for groups of fields to be organized into "Layouts". 4 | 5 | These Layouts can be made up of other types of fields, and can be added and arranged in any order. 6 | 7 | Flexible Content Fields are added to the WPGraphQL Schema as a List Of [Unions](https://graphql.org/learn/schema/#union-types). 8 | 9 | The Union for a Flex Field is made up of each Layout in the Flex Field as the possible Types. 10 | 11 | In our example, we've created a Flex Field with 3 layouts named "Layout One", "Layout Two" and "Layout Three". In the Schema, we can see the Flex Field Union's Possible Types are these 3 layouts. 12 | 13 |  14 | 15 | Each of these Layout types will contain the fields defined for the layout and can be queried like fields in any other Group. 16 | 17 | Here's an example of a Flex Field named `flexible_content`, with 3 layouts: 18 | 19 | - Layout One 20 | - Text field named "text" 21 | - Text field named "another_text_field" 22 | - Layout Two 23 | - Image field named "image" 24 | - Layout Three 25 | - Gallery field named "gallery" 26 | 27 | Above are the possible layouts and their fields. These layouts can be added and arranged in any order. While we, as a GraphQL consumer, don't know ahead of time what order they will be in, we _do_ know what the possibilities are. 28 | 29 | Here's an example of a Flex Field named `flexible_content` with the values saved as "Layout One", "Layout Two" and "Layout Three", in that order, all populated with their respective fields. 30 | 31 |  32 | 33 | We can query this field like so: 34 | 35 | ```graphql 36 | { 37 | post(id: "acf-example-test", idType: URI) { 38 | acfDocs { 39 | flexibleContent { 40 | __typename 41 | ... on Post_Acfdocs_FlexibleContent_LayoutOne { 42 | text 43 | anotherTextField 44 | } 45 | ... on Post_Acfdocs_FlexibleContent_LayoutTwo { 46 | image { 47 | id 48 | sourceUrl(size: MEDIUM) 49 | } 50 | } 51 | ... on Post_Acfdocs_FlexibleContent_LayoutThree { 52 | gallery { 53 | id 54 | sourceUrl(size: MEDIUM) 55 | } 56 | } 57 | } 58 | } 59 | } 60 | } 61 | ``` 62 | 63 | and the results of the query would be: 64 | 65 | ```json 66 | { 67 | "data": { 68 | "post": { 69 | "acfDocs": { 70 | "flexibleContent": [ 71 | { 72 | "__typename": "Post_Acfdocs_FlexibleContent_LayoutOne", 73 | "text": "Text Value One", 74 | "anotherTextField": "Another Text Value" 75 | }, 76 | { 77 | "__typename": "Post_Acfdocs_FlexibleContent_LayoutTwo", 78 | "image": { 79 | "id": "YXR0YWNobWVudDoyNTY=", 80 | "sourceUrl": "http://acf2.local/wp-content/uploads/2020/02/babe-ruth-300x169.jpg" 81 | } 82 | }, 83 | { 84 | "__typename": "Post_Acfdocs_FlexibleContent_LayoutThree", 85 | "gallery": [ 86 | { 87 | "id": "YXR0YWNobWVudDoyNTY=", 88 | "sourceUrl": "http://acf2.local/wp-content/uploads/2020/02/babe-ruth-300x169.jpg" 89 | }, 90 | { 91 | "id": "YXR0YWNobWVudDoyNTU=", 92 | "sourceUrl": "http://acf2.local/wp-content/uploads/2020/02/babe-ruth-baseball-289x300.jpg" 93 | } 94 | ] 95 | } 96 | ] 97 | } 98 | } 99 | } 100 | } 101 | ``` 102 | 103 | If we were to re-arrange the layouts, so that the order was "Layout Three", "Layout One", "Layout Two", the results of the query would be: 104 | 105 | ```json 106 | "data": { 107 | "post": { 108 | "acfDocs": { 109 | "flexibleContent": [ 110 | { 111 | "__typename": "Post_Acfdocs_FlexibleContent_LayoutThree", 112 | "gallery": [ 113 | { 114 | "id": "YXR0YWNobWVudDoyNTY=", 115 | "sourceUrl": "http://acf2.local/wp-content/uploads/2020/02/babe-ruth-300x169.jpg" 116 | }, 117 | { 118 | "id": "YXR0YWNobWVudDoyNTU=", 119 | "sourceUrl": "http://acf2.local/wp-content/uploads/2020/02/babe-ruth-baseball-289x300.jpg" 120 | } 121 | ] 122 | } 123 | { 124 | "__typename": "Post_Acfdocs_FlexibleContent_LayoutOne", 125 | "text": "Text Value One", 126 | "anotherTextField": "Another Text Value" 127 | }, 128 | { 129 | "__typename": "Post_Acfdocs_FlexibleContent_LayoutTwo", 130 | "image": { 131 | "id": "YXR0YWNobWVudDoyNTY=", 132 | "sourceUrl": "http://acf2.local/wp-content/uploads/2020/02/babe-ruth-300x169.jpg" 133 | } 134 | }, 135 | ] 136 | } 137 | } 138 | } 139 | ``` 140 | 141 | ---- 142 | 143 | - **Previous Field:** [File](./file.md) 144 | - **Next Field:** [Gallery](./gallery.md) 145 | -------------------------------------------------------------------------------- /docs/fields/gallery.md: -------------------------------------------------------------------------------- 1 | # Gallery Field 2 | 3 | Gallery fields are added to the WPGraphQL Schema as a field with the Type of `['list_of' => 'MediaItem']`. 4 | 5 | Gallery fields can be queried and a list of MediaItem types will be returned. 6 | 7 | Since the type is a list, we can expect an array to be returned. And since the Type within the list is `MediaItem`, we can ask for fields we want returned for each `MediaItem` in the list. In this case, let's say we want to ask for the `id` of each image and the `sourceUrl`, (size large). 8 | 9 | Here, we have a Gallery field named `gallery` on the Post Edit screen within the "ACF Docs" Field Group. 10 | 11 |  12 | 13 | This field can be Queried in GraphQL like so: 14 | 15 | ```graphql 16 | { 17 | post(id: "acf-example-test", idType: URI) { 18 | acfDocs { 19 | gallery { 20 | id 21 | sourceUrl(size: LARGE) 22 | } 23 | } 24 | } 25 | } 26 | ``` 27 | 28 | and the results of the query would be: 29 | 30 | ```json 31 | { 32 | "data": { 33 | "post": { 34 | "acfDocs": { 35 | "gallery": [ 36 | { 37 | "id": "YXR0YWNobWVudDoyNTY=", 38 | "sourceUrl": "http://wpgraphql.local/wp-content/uploads/2020/02/babe-ruth.jpg" 39 | }, 40 | { 41 | "id": "YXR0YWNobWVudDoyNTU=", 42 | "sourceUrl": "http://wpgraphql.local/wp-content/uploads/2020/02/babe-ruth-baseball-986x1024.jpg" 43 | } 44 | ] 45 | } 46 | } 47 | } 48 | } 49 | ``` 50 | 51 | ---- 52 | 53 | - **Previous Field:** [Flexible Content](./flexible-content.md) 54 | - **Next Field:** [Google Map](./google-map.md) 55 | 56 | -------------------------------------------------------------------------------- /docs/fields/google-map.md: -------------------------------------------------------------------------------- 1 | # Google Map Field 2 | 3 | Google Map fields are added to the WPGraphQL Schema as the `ACF_GoogleMap` Type. 4 | 5 | The `ACF_GoogleMap` Type has fields that expose location data. The available fields are: 6 | 7 | - **city** (String): The city associated with the location 8 | - **country** (String): The country associated with the location 9 | - **countryShort** (String): The country abbreviation associated with the location 10 | - **latitude** (String): The latitude associated with the location 11 | - **longitude** (String): The longitude associated with the location 12 | - **placeId** (String): Place IDs uniquely identify a place in the Google Places database and on Google Maps. 13 | - **postCode** (String): The post code associated with the location 14 | - **state** (String): The state associated with the location 15 | - **stateShort** (String): The state abbreviation associated with the location 16 | - **streetAddress** (String): The street address associated with the location 17 | - **streetName** (String): The street name associated with the location 18 | - **streetNumber** (String): The street number associated with the location 19 | - **zoom** (String): The zoom defined with the location 20 | 21 | Here, we have a Google Map field named `google_map` on the Post Edit screen within the "ACF Docs" Field Group, set with the Address "1 Infinite Loop, Cupertino, CA 95014, USA" as the value. 22 | 23 |  24 | 25 | This field can be queried in GraphQL like so: 26 | 27 | ```graphql 28 | { 29 | post(id: "acf-example-test", idType: URI) { 30 | acfDocs { 31 | googleMap { 32 | streetAddress 33 | streetNumber 34 | streetName 35 | city 36 | state 37 | postCode 38 | countryShort 39 | } 40 | } 41 | } 42 | } 43 | ``` 44 | 45 | and the response would look like: 46 | 47 | ```json 48 | { 49 | "data": { 50 | "post": { 51 | "acfDocs": { 52 | "googleMap": { 53 | "streetAddress": "1 Infinite Loop, Cupertino, CA 95014, USA", 54 | "streetNumber": "1", 55 | "streetName": "Infinite Loop", 56 | "city": "Cupertino", 57 | "state": "California", 58 | "postCode": "95014", 59 | "placeId": "ChIJHTRqF7e1j4ARzZ_Fv8VA4Eo", 60 | "countryShort": "US" 61 | } 62 | } 63 | } 64 | } 65 | } 66 | ``` 67 | 68 | ---- 69 | 70 | - **Previous Field:** [Gallery](./gallery.md) 71 | - **Next Field:** [Group](./group.md) 72 | -------------------------------------------------------------------------------- /docs/fields/group.md: -------------------------------------------------------------------------------- 1 | # Group Field 2 | 3 | Group Fields are added to the WPGraphQL Schema as fields resolving to an Object Type named after the Group. 4 | 5 | Here, we have a Group field named `group` on the Post Edit screen within the "ACF Docs" Field Group. Within the "group" field, we have a Text Field named `text_field_in_group` and a Text Area field named `text_area_field_in_group` 6 | 7 |  8 | 9 | We can query the fields within the group like so: 10 | 11 | ```graphql 12 | { 13 | post(id: "acf-example-test", idType: URI) { 14 | acfDocs { 15 | group { 16 | textFieldInGroup 17 | textAreaFieldInGroup 18 | } 19 | } 20 | } 21 | } 22 | ``` 23 | 24 | And the results of the query would be: 25 | 26 | ```json 27 | { 28 | "data": { 29 | "post": { 30 | "acfDocs": { 31 | "group": { 32 | "textFieldInGroup": "Text value, in group", 33 | "textAreaFieldInGroup": "Text are value, in group" 34 | } 35 | } 36 | } 37 | } 38 | } 39 | ``` 40 | 41 | ---- 42 | 43 | - **Previous Field:** [Google Map](./google-map.md) 44 | - **Next Field:** [image](./image.md) 45 | -------------------------------------------------------------------------------- /docs/fields/image.md: -------------------------------------------------------------------------------- 1 | # Image Field 2 | 3 | Image fields are added to the WPGraphQL Schema as a field with the Type `MediaItem`. 4 | 5 | Image fields can be queried and a MediaItem will be returned. 6 | 7 | The `MediaItem` type is an Object type that has it's own fields that can be selected. So, instead of _just_ getting the Image ID returned and having to ask for the MediaItem object in a follow-up request, we can ask for fields available on the MediaItem Type. For this example, we ask for the `id` and `sourceUrl`. 8 | 9 | Here, we have an Image field named `image` on the Post Edit screen within the "ACF Docs" Field Group. 10 | 11 |  12 | 13 | This field can be Queried in GraphQL like so: 14 | 15 | ```graphql 16 | { 17 | post( id: "acf-example-test" idType: URI ) { 18 | acfDocs { 19 | image { 20 | id 21 | sourceUrl(size: MEDIUM) 22 | } 23 | } 24 | } 25 | } 26 | ``` 27 | 28 | And the results of the query would be: 29 | 30 | ```json 31 | { 32 | "data": { 33 | "post": { 34 | "acfDocs": { 35 | "image": { 36 | "id": "YXR0YWNobWVudDozMjM=", 37 | "sourceUrl": "http://wpgraphql.local/wp-content/uploads/2020/03/babe-ruth-300x169.jpg" 38 | } 39 | } 40 | } 41 | } 42 | } 43 | ``` 44 | 45 | ---- 46 | 47 | - **Previous Field:** [Group](./group.md) 48 | - **Next Field:** [Link](./link.md) 49 | -------------------------------------------------------------------------------- /docs/fields/link.md: -------------------------------------------------------------------------------- 1 | # Link Field 2 | 3 | Link fields are added to the WPGraphQL Schema as a field with the Type `ACF_Link`. 4 | 5 | Link fields can be queried and a `ACF_Link` will be returned. The ACF Link is an object with fields that can be selected. 6 | 7 | The available fields on the `ACF_Link` Type are: 8 | 9 | - **target** (String): The target of the link 10 | - **title** (String): The target of the link 11 | - **url** (String): The url of the link 12 | 13 | Here, we have a Link field named `link` on the Post Edit screen within the "ACF Docs" Field Group. 14 | 15 |  16 | 17 | This field can be Queried in GraphQL like so: 18 | 19 | ```graphql 20 | { 21 | post(id: "acf-example-test", idType: URI) { 22 | acfDocs { 23 | link { 24 | target 25 | title 26 | url 27 | } 28 | } 29 | } 30 | } 31 | ``` 32 | 33 | and the results of the query would be: 34 | 35 | ```json 36 | { 37 | "data": { 38 | "post": { 39 | "acfDocs": { 40 | "link": { 41 | "target": "", 42 | "title": "Hello world!", 43 | "url": "http://acf2.local/hello-world/" 44 | } 45 | } 46 | } 47 | } 48 | } 49 | ``` 50 | 51 | ---- 52 | 53 | - **Previous Field:** [Image](./image.md) 54 | - **Next Field:** [Message](./message.md) 55 | 56 | -------------------------------------------------------------------------------- /docs/fields/message.md: -------------------------------------------------------------------------------- 1 | # Message Field 2 | 3 | Message fields are not currently supported. 4 | 5 | ---- 6 | 7 | - **Previous Field:** [Link](./link.md) 8 | - **Next Field:** [Number](./number.md) 9 | -------------------------------------------------------------------------------- /docs/fields/number.md: -------------------------------------------------------------------------------- 1 | # Number Field 2 | 3 | Number fields are added to the WPGraphQL Schema as a field with the Type `Float`. 4 | 5 | Number fields can be queried, and a Float will be returned. 6 | 7 | Here, we have a Number field named `number` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post( id: "acf-example-test" idType: URI ) { 16 | acfDocs { 17 | number 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "number": 5 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Message](./message.md) 40 | - **Next Field:** [Oembed](./oembed.md) 41 | -------------------------------------------------------------------------------- /docs/fields/oembed.md: -------------------------------------------------------------------------------- 1 | # oEmbed Field 2 | 3 | oEmbed fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | oEmbed fields can be queried, and a String will be returned. 6 | 7 | Here, we have a oEmbed field named `oembed` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | oembed 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "oembed": "https://www.youtube.com/watch?v=ZEytXfaWwcc" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Number](./number.md) 40 | - **Next Field:** [Page Link](./page-link.md) 41 | 42 | -------------------------------------------------------------------------------- /docs/fields/page-link.md: -------------------------------------------------------------------------------- 1 | # Page Link Field 2 | 3 | Page Link fields are added to the WPGraphQL Schema as a field with a [Union](https://graphql.org/learn/schema/#union-types) of Possible Types the field is configured to allow. 4 | 5 | Since Page Link fields can be configured to be limited to certain Post Types, the Union will represent those Types. 6 | 7 | For example, if the Post Object field is configured to allow Posts of the `post` and `page` types to be selected: 8 | 9 |  10 | 11 | Then the Union type for the field will allow `Post` and `Page` types to be returned, as seen in the Schema via GraphiQL: 12 | 13 |  14 | 15 | Here, we have a Page Link field named `page_link` on the Post Edit screen within the "ACF Docs" Field Group, and the value is set to the "Sample Page" page. 16 | 17 |  18 | 19 | This field can be Queried in GraphQL like so: 20 | 21 | ```graphql 22 | { 23 | post(id: "acf-example-test", idType: URI) { 24 | acfDocs { 25 | pageLink { 26 | __typename 27 | ... on Post { 28 | id 29 | title 30 | date 31 | } 32 | ... on Page { 33 | id 34 | title 35 | } 36 | } 37 | } 38 | } 39 | } 40 | ``` 41 | 42 | and the results of the query would be: 43 | 44 | ```json 45 | { 46 | "data": { 47 | "post": { 48 | "acfDocs": { 49 | "pageLink": { 50 | "__typename": "Page", 51 | "id": "cGFnZToy", 52 | "title": "Sample Page" 53 | } 54 | } 55 | } 56 | } 57 | } 58 | ``` 59 | 60 | Here, we set the value to the "Hello World" Post: 61 | 62 |  63 | 64 | And the results of the same query are now: 65 | 66 | ```json 67 | { 68 | "data": { 69 | "post": { 70 | "acfDocs": { 71 | "pageLink": { 72 | "__typename": "Post", 73 | "id": "cG9zdDox", 74 | "title": "Hello world!", 75 | "date": "2020-02-20T23:12:21" 76 | } 77 | } 78 | } 79 | } 80 | } 81 | ``` 82 | 83 | ---- 84 | 85 | - **Previous Field:** [Oembed](./oembed.md) 86 | - **Next Field:** [Checkbox](./password.md) 87 | 88 | -------------------------------------------------------------------------------- /docs/fields/password.md: -------------------------------------------------------------------------------- 1 | # Password Field 2 | 3 | Password fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | Password fields can be queried, and a String will be returned. 6 | 7 | Here, we have a Password field named `password` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post( id: "acf-example-test" idType: URI ) { 16 | acfDocs { 17 | password 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "password": "123456" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Page Link](./page-link.md) 40 | - **Next Field:** [Post Object](./post-object.md) 41 | -------------------------------------------------------------------------------- /docs/fields/post-object.md: -------------------------------------------------------------------------------- 1 | # Post Object Field 2 | 3 | Post Object fields are added to the WPGraphQL Schema as a field with a [Union](https://graphql.org/learn/schema/#union-types) of Possible Types the field is configured to allow. 4 | 5 | If the field is configured to allow multiple selections, it will be added to the Schema as a List Of the Union Type. 6 | 7 | Since Post Object fields can be configured to be limited to certain Post Types, the Union will represent those Types. 8 | 9 | For example, if the Post Object field is configured to allow Posts of the `post` and `page` types to be selected: 10 | 11 |  12 | 13 | Then the Union type for the field will allow `Post` and `Page` types to be returned, as seen in the Schema via GraphiQL: 14 | 15 |  16 | 17 | Here, we have a Post Object field named `post_object` on the Post Edit screen within the "ACF Docs" Field Group, configured with the Post "Hello World!". 18 | 19 |  20 | 21 | As a GraphQL consumer, we don't know in advance if the value is going to be a Page or a Post. 22 | 23 | So we can specify, via GraphQL fragment, what fields we want if the object is a Post, or if it is a Page. 24 | 25 | This field can be Queried in GraphQL like so: 26 | 27 | ```graphql 28 | { 29 | post(id: "acf-example-test", idType: URI) { 30 | acfDocs { 31 | postObject { 32 | __typename 33 | ... on Post { 34 | id 35 | title 36 | date 37 | } 38 | ... on Page { 39 | id 40 | title 41 | } 42 | } 43 | } 44 | } 45 | } 46 | ``` 47 | 48 | and the results of the query would be: 49 | 50 | ```json 51 | { 52 | "data": { 53 | "post": { 54 | "acfDocs": { 55 | "postObject": { 56 | "__typename": "Post", 57 | "id": "cG9zdDox", 58 | "title": "Hello world!", 59 | "date": "2020-02-20T23:12:21" 60 | } 61 | } 62 | } 63 | } 64 | } 65 | ``` 66 | 67 | If the input of the field was saved as a Page, instead of a Post, like so: 68 | 69 |  70 | 71 | Then the same query above, would return the following results: 72 | 73 | ```json 74 | { 75 | "data": { 76 | "post": { 77 | "acfDocs": { 78 | "postObject": { 79 | "__typename": "Page", 80 | "id": "cGFnZToy", 81 | "title": "Sample Page" 82 | } 83 | } 84 | } 85 | } 86 | } 87 | ``` 88 | 89 | Now, if the field were configured to allow multiple values, the field would be added to the Schema as a `listOf`, returning an Array of the Union. 90 | 91 | If the field were set with a value of one Page, and one Post, like so: 92 | 93 |  94 | 95 | Then the results of the same query as above would be: 96 | 97 | ```json 98 | { 99 | "data": { 100 | "post": { 101 | "acfDocs": { 102 | "postObject": [ 103 | { 104 | "__typename": "Page", 105 | "id": "cGFnZToy", 106 | "title": "Sample Page" 107 | }, 108 | { 109 | "__typename": "Post", 110 | "id": "cG9zdDox", 111 | "title": "Hello world!", 112 | "date": "2020-02-20T23:12:21" 113 | } 114 | ] 115 | } 116 | } 117 | } 118 | } 119 | ``` 120 | 121 | ---- 122 | 123 | - **Previous Field:** [Password](./password.md) 124 | - **Next Field:** [Radio](./radio.md) 125 | 126 | -------------------------------------------------------------------------------- /docs/fields/radio.md: -------------------------------------------------------------------------------- 1 | # Radio Button Field 2 | 3 | Radio Button fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | Radio Button fields can be queried and a String will be returned. 6 | 7 | Here, we have a Radio Button field named `radio_button` on the Post Edit screen within the "ACF Docs" Field Group, and "Choice 2" is selected. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | radioButton 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "radioButton": "choice_2" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Post Object](./post-object.md) 40 | - **Next Field:** [Range](./range.md) 41 | -------------------------------------------------------------------------------- /docs/fields/range.md: -------------------------------------------------------------------------------- 1 | # Range Field 2 | 3 | Range fields are added to the WPGraphQL Schema as a field with the Type `Float`. 4 | 5 | Range fields can be queried, and a Float will be returned. 6 | 7 | Here, we have a Range field named `range` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post( id: "acf-example-test" idType: URI ) { 16 | acfDocs { 17 | range 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "range": 5 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Radio](./radio.md) 40 | - **Next Field:** [Relationship](./relationship.md) 41 | -------------------------------------------------------------------------------- /docs/fields/relationship.md: -------------------------------------------------------------------------------- 1 | # Relationship Field 2 | 3 | Relationship fields are added to the WPGraphQL Schema as a field with a [Union](https://graphql.org/learn/schema/#union-types) of Possible Types the field is configured to allow. 4 | 5 | Since Relationship fields can be configured to be limited to certain Post Types, the Union will represent those Types. 6 | 7 | For example, if the Post Object field is configured to allow Posts of the `post` and `page` types to be selected: 8 | 9 |  10 | 11 | Then the Union type for the field will allow `Post` and `Page` types to be returned, as seen in the Schema via GraphiQL: 12 | 13 |  14 | 15 | Here, we have a Relationship field named `relationship` on the Post Edit screen within the "ACF Docs" Field Group, and the value is set to "Hello World!" post, and the "Sample Page" page. 16 | 17 |  18 | 19 | This field can be Queried in GraphQL like so: 20 | 21 | ```graphql 22 | { 23 | post(id: "acf-example-test", idType: URI) { 24 | acfDocs { 25 | relationship { 26 | __typename 27 | ... on Post { 28 | id 29 | title 30 | date 31 | } 32 | ... on Page { 33 | id 34 | title 35 | } 36 | } 37 | } 38 | } 39 | } 40 | ``` 41 | 42 | and the results of the query would be: 43 | 44 | ```json 45 | { 46 | "data": { 47 | "post": { 48 | "acfDocs": { 49 | "relationship": [ 50 | { 51 | "__typename": "Post", 52 | "id": "cG9zdDox", 53 | "title": "Hello world!", 54 | "date": "2020-02-20T23:12:21" 55 | }, 56 | { 57 | "__typename": "Page", 58 | "id": "cGFnZToy", 59 | "title": "Sample Page" 60 | } 61 | ] 62 | } 63 | } 64 | } 65 | } 66 | ``` 67 | 68 | ---- 69 | 70 | - **Previous Field:** [Range](./range.md) 71 | - **Next Field:** [Repeater](./repeater.md) 72 | 73 | -------------------------------------------------------------------------------- /docs/fields/repeater.md: -------------------------------------------------------------------------------- 1 | # Repeater Field 2 | 3 | Repeater Fields are added to the Schema as a List Of the Type of group that makes up the fields. 4 | 5 | For example, we've created a Repeater Field that has a Text Field named `text_field_in_repeater` and an Image Field named `image_field_in_repeater`. 6 | 7 | Here, the Repeater Field is populated with 2 rows: 8 | - Row 1: 9 | - Text Field: Text Value 1 10 | - Image: 256 11 | - Row 2: 12 | - Text Field: Text Value 2 13 | - Image: 255 14 | 15 |  16 | 17 | This field can be queried in GraphQL like so: 18 | 19 | ```graphql 20 | { 21 | post(id: "acf-example-test", idType: URI) { 22 | acfDocs { 23 | repeater { 24 | textFieldInRepeater 25 | imageFieldInRepeater { 26 | databaseId 27 | id 28 | sourceUrl 29 | } 30 | } 31 | } 32 | } 33 | } 34 | ``` 35 | 36 | and the results of the query would be: 37 | 38 | ```json 39 | { 40 | "data": { 41 | "post": { 42 | "acfDocs": { 43 | "repeater": [ 44 | { 45 | "textFieldInRepeater": "Text Value 1", 46 | "imageFieldInRepeater": { 47 | "id": "YXR0YWNobWVudDoyNTY=", 48 | "sourceUrl": "http://acf2.local/wp-content/uploads/2020/02/babe-ruth.jpg" 49 | } 50 | }, 51 | { 52 | "textFieldInRepeater": "Text Value 2", 53 | "imageFieldInRepeater": { 54 | "id": "YXR0YWNobWVudDoyNTU=", 55 | "sourceUrl": "http://acf2.local/wp-content/uploads/2020/02/babe-ruth-baseball-scaled.jpg" 56 | } 57 | } 58 | ] 59 | } 60 | } 61 | } 62 | } 63 | ``` 64 | 65 | ---- 66 | 67 | - **Previous Field:** [Relationship](./relationship.md) 68 | - **Next Field:** [Select](./select.md) 69 | -------------------------------------------------------------------------------- /docs/fields/select.md: -------------------------------------------------------------------------------- 1 | # Select Field 2 | 3 | Select fields (when configured to _not_ allow mutliple selections) are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | Select fields, without multiple selections allowed, can be queried and a String will be returned. 6 | 7 | Here, we have a Select field named `select` on the Post Edit screen within the "ACF Docs" Field Group, and "Choice 1" is selected. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | select 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "select": "choice_1" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Repeater](./repeater.md) 40 | - **Next Field:** [Tab](./tab.md) 41 | -------------------------------------------------------------------------------- /docs/fields/tab.md: -------------------------------------------------------------------------------- 1 | # Tab Field 2 | 3 | Tab fields are not currently supported. 4 | 5 | ---- 6 | 7 | - **Previous Field:** [Select](./select.md) 8 | - **Next Field:** [Taxonomy](./taxonomy.md) 9 | -------------------------------------------------------------------------------- /docs/fields/taxonomy.md: -------------------------------------------------------------------------------- 1 | # Taxonomy Field 2 | 3 | The Taxonomy field is added to the GraphQL Schema as a List Of the Taxonomy Type. 4 | 5 | For example, if the field is configured to the "Category" taxonomy, then the field in the Schema will be a List of the Category type. 6 | 7 |  8 | 9 | Here, we have a Taxonomy field named `taxonomy` on the Post Edit screen within the "ACF Docs" Field Group, configured with the Category "Test Category". 10 | 11 |  12 | 13 | This field can be queried like so: 14 | 15 | ```graphql 16 | { 17 | post(id: "acf-example-test", idType: URI) { 18 | acfDocs { 19 | taxonomy { 20 | __typename 21 | id 22 | name 23 | } 24 | } 25 | } 26 | } 27 | ``` 28 | 29 | and the results of the query would be: 30 | 31 | ```json 32 | { 33 | "data": { 34 | "post": { 35 | "acfDocs": { 36 | "taxonomy": [ 37 | { 38 | "__typename": "Category", 39 | "id": "Y2F0ZWdvcnk6Mg==", 40 | "name": "Test Category" 41 | } 42 | ] 43 | } 44 | } 45 | } 46 | } 47 | ``` 48 | 49 | ---- 50 | 51 | - **Previous Field:** [Tab](./tab.md) 52 | - **Next Field:** [Text](./text.md) 53 | 54 | -------------------------------------------------------------------------------- /docs/fields/text-area.md: -------------------------------------------------------------------------------- 1 | # Text Area Field 2 | 3 | Text Area fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | Text Area fields can be queried and a String will be returned. 6 | 7 | Here, we have a Text Area field named `text_area` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post( id: "acf-example-test" idType: URI ) { 16 | acfDocs { 17 | textArea 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "textArea": "Text value" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Text](./text.md) 40 | - **Next Field:** [Time Picker](./time-picker.md) 41 | 42 | -------------------------------------------------------------------------------- /docs/fields/text.md: -------------------------------------------------------------------------------- 1 | # Text Field 2 | 3 | Text fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | Text fields can be queried and a String will be returned. 6 | 7 | Here, we have a Text field named `text` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post( id: "acf-example-test" idType: URI ) { 16 | acfDocs { 17 | text 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "text": "Text Value" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Taxonomy](./taxonomy.md) 40 | - **Next Field:** [Text Area](./text-area.md) 41 | 42 | -------------------------------------------------------------------------------- /docs/fields/time-picker.md: -------------------------------------------------------------------------------- 1 | # Time Picker Field 2 | 3 | The Time Picker field is added to the WPGraphQL Schema as field with the Type `String`. 4 | 5 | Time Picker fields can be queried and a String will be returned. 6 | 7 | Here, we have a Time Picker field named `time_picker` on the Post Edit screen within the "ACF Docs" Field Group, and "12:30 am" is the value. 8 | 9 |  10 | 11 | This field can be queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | timePicker 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the result of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "timePicker": "12:30 am" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Text Area](text-area.md) 40 | - **Next Field:** [True/False](true-false.md) 41 | 42 | -------------------------------------------------------------------------------- /docs/fields/true-false.md: -------------------------------------------------------------------------------- 1 | # True/False Field 2 | 3 | True/False fields are added to the WPGraphQL Schema as a field with the Type `Boolean`. 4 | 5 | True/False fields can be queried and a Boolean will be returned. 6 | 7 | Here, we have a True/False field named `true_false` on the Post Edit screen within the "ACF Docs" Field Group, and "true" is selected. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post(id: "acf-example-test", idType: URI) { 16 | acfDocs { 17 | trueFalse 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "trueFalse": true 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [Time Picker](./time-picker.md) 40 | - **Next Field:** [url](./url.md) 41 | 42 | -------------------------------------------------------------------------------- /docs/fields/url.md: -------------------------------------------------------------------------------- 1 | # URL Field 2 | 3 | Url fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | Url fields can be queried and a String will be returned. 6 | 7 | Here, we have a URL field named `url` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post( id: "acf-example-test" idType: URI ) { 16 | acfDocs { 17 | url 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "url": "https://wpgraphql.com" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [True/False](./true-false.md) 40 | - **Next Field:** [User](./user.md) 41 | 42 | -------------------------------------------------------------------------------- /docs/fields/user.md: -------------------------------------------------------------------------------- 1 | # User Field 2 | 3 | User fields are added to the WPGraphQL Schema as a field with a User type. 4 | 5 | Here, we have a User field named `user` on the Post Edit screen within the "ACF Docs" Field Group, set with the User "jasonbahl" as the value. 6 | 7 |  8 | 9 | This field can be queried in GraphQL like so: 10 | 11 | ```graphql 12 | { 13 | post(id: "acf-example-test", idType: URI) { 14 | acfDocs { 15 | user { 16 | id 17 | username 18 | firstName 19 | lastName 20 | } 21 | } 22 | } 23 | } 24 | ``` 25 | 26 | and the response would look like: 27 | 28 | ```json 29 | { 30 | "data": { 31 | "post": { 32 | "acfDocs": { 33 | "user": { 34 | "id": "dXNlcjox", 35 | "username": "jasonbahl", 36 | "firstName": "Jason", 37 | "lastName": "Bahl" 38 | } 39 | } 40 | } 41 | } 42 | } 43 | ``` 44 | 45 | If the field is configured to allow multiple selections, it's added to the Schema as a List Of the User type. 46 | 47 | Here, we have a User field named `user` on the Post Edit screen within the "ACF Docs" Field Group, set with the User "jasonbahl" and "WPGraphQL" as the value. 48 | 49 |  50 | 51 | and the response to the same query would look like: 52 | 53 | ```json 54 | { 55 | "data": { 56 | "post": { 57 | "acfDocs": { 58 | "user": [ 59 | { 60 | "id": "dXNlcjox", 61 | "username": "jasonbahl", 62 | "firstName": "Jason", 63 | "lastName": "Bahl" 64 | }, 65 | { 66 | "id": "dXNlcjoy", 67 | "username": "WPGraphQL", 68 | "firstName": "WP", 69 | "lastName": "GraphQL" 70 | } 71 | ] 72 | } 73 | } 74 | } 75 | } 76 | ``` 77 | 78 | ---- 79 | 80 | - **Previous Field:** [Url](./url.md) 81 | - **Next Field:** [WYSIWYG](./wysiwyg.md) 82 | -------------------------------------------------------------------------------- /docs/fields/wysiwyg.md: -------------------------------------------------------------------------------- 1 | # WYSIWYG Editor Field 2 | 3 | WYSIWYG fields are added to the WPGraphQL Schema as a field with the Type `String`. 4 | 5 | WYSIWYG fields can be queried and a String will be returned. 6 | 7 | Here, we have a WYSIWYG field named `wysiwyg` on the Post Edit screen within the "ACF Docs" Field Group. 8 | 9 |  10 | 11 | This field can be Queried in GraphQL like so: 12 | 13 | ```graphql 14 | { 15 | post( id: "acf-example-test" idType: URI ) { 16 | acfDocs { 17 | wysiwyg 18 | } 19 | } 20 | } 21 | ``` 22 | 23 | and the results of the query would be: 24 | 25 | ```json 26 | { 27 | "data": { 28 | "post": { 29 | "acfDocs": { 30 | "wysiwyg": "
Some content in a WYSIWYG field
\n" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ---- 38 | 39 | - **Previous Field:** [User](./user.md) 40 | -------------------------------------------------------------------------------- /docs/img/button-group-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/button-group-field-input.png -------------------------------------------------------------------------------- /docs/img/button-group-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/button-group-field-query.png -------------------------------------------------------------------------------- /docs/img/checkbox-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/checkbox-field-input.png -------------------------------------------------------------------------------- /docs/img/checkbox-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/checkbox-field-query.png -------------------------------------------------------------------------------- /docs/img/color-picker-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/color-picker-field-input.png -------------------------------------------------------------------------------- /docs/img/color-picker-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/color-picker-field-query.png -------------------------------------------------------------------------------- /docs/img/date-picker-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/date-picker-field-input.png -------------------------------------------------------------------------------- /docs/img/date-picker-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/date-picker-field-query.png -------------------------------------------------------------------------------- /docs/img/date-time-picker-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/date-time-picker-field-input.png -------------------------------------------------------------------------------- /docs/img/date-time-picker-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/date-time-picker-field-query.png -------------------------------------------------------------------------------- /docs/img/email-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/email-field-input.png -------------------------------------------------------------------------------- /docs/img/email-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/email-field-query.png -------------------------------------------------------------------------------- /docs/img/field-group-show-in-graphql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/field-group-show-in-graphql.png -------------------------------------------------------------------------------- /docs/img/file-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/file-field-input.png -------------------------------------------------------------------------------- /docs/img/file-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/file-field-query.png -------------------------------------------------------------------------------- /docs/img/flex-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/flex-field-input.png -------------------------------------------------------------------------------- /docs/img/flex-field-input2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/flex-field-input2.png -------------------------------------------------------------------------------- /docs/img/flex-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/flex-field-query.png -------------------------------------------------------------------------------- /docs/img/flex-field-query2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/flex-field-query2.png -------------------------------------------------------------------------------- /docs/img/flex-field-union-possible-types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/flex-field-union-possible-types.png -------------------------------------------------------------------------------- /docs/img/gallery-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/gallery-field-input.png -------------------------------------------------------------------------------- /docs/img/gallery-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/gallery-field-query.png -------------------------------------------------------------------------------- /docs/img/group-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/group-field-input.png -------------------------------------------------------------------------------- /docs/img/group-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/group-field-query.png -------------------------------------------------------------------------------- /docs/img/image-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/image-field-input.png -------------------------------------------------------------------------------- /docs/img/image-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/image-field-query.png -------------------------------------------------------------------------------- /docs/img/link-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/link-field-input.png -------------------------------------------------------------------------------- /docs/img/link-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/link-field-query.png -------------------------------------------------------------------------------- /docs/img/location-rule-post-type-post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/location-rule-post-type-post.png -------------------------------------------------------------------------------- /docs/img/map-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/map-field-input.png -------------------------------------------------------------------------------- /docs/img/map-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/map-field-query.png -------------------------------------------------------------------------------- /docs/img/multi-select-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/multi-select-field-input.png -------------------------------------------------------------------------------- /docs/img/multi-select-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/multi-select-field-query.png -------------------------------------------------------------------------------- /docs/img/number-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/number-field-input.png -------------------------------------------------------------------------------- /docs/img/number-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/number-field-query.png -------------------------------------------------------------------------------- /docs/img/oEmbed-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/oEmbed-field-input.png -------------------------------------------------------------------------------- /docs/img/oembed-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/oembed-field-query.png -------------------------------------------------------------------------------- /docs/img/page-link-field-input-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/page-link-field-input-2.png -------------------------------------------------------------------------------- /docs/img/page-link-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/page-link-field-input.png -------------------------------------------------------------------------------- /docs/img/page-link-field-possible-types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/page-link-field-possible-types.png -------------------------------------------------------------------------------- /docs/img/page-link-field-post-type-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/page-link-field-post-type-config.png -------------------------------------------------------------------------------- /docs/img/page-link-field-query-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/page-link-field-query-2.png -------------------------------------------------------------------------------- /docs/img/page-link-field-query-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/page-link-field-query-page.png -------------------------------------------------------------------------------- /docs/img/page-link-field-query-post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/page-link-field-query-post.png -------------------------------------------------------------------------------- /docs/img/page-link-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/page-link-field-query.png -------------------------------------------------------------------------------- /docs/img/password-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/password-field-input.png -------------------------------------------------------------------------------- /docs/img/post-object-field-input-multi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/post-object-field-input-multi.png -------------------------------------------------------------------------------- /docs/img/post-object-field-input-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/post-object-field-input-page.png -------------------------------------------------------------------------------- /docs/img/post-object-field-input-post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/post-object-field-input-post.png -------------------------------------------------------------------------------- /docs/img/post-object-field-possible-types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/post-object-field-possible-types.png -------------------------------------------------------------------------------- /docs/img/post-object-field-post-type-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/post-object-field-post-type-config.png -------------------------------------------------------------------------------- /docs/img/post-object-field-query-multi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/post-object-field-query-multi.png -------------------------------------------------------------------------------- /docs/img/post-object-field-query-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/post-object-field-query-page.png -------------------------------------------------------------------------------- /docs/img/post-object-field-query-post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/post-object-field-query-post.png -------------------------------------------------------------------------------- /docs/img/radio-button-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/radio-button-field-input.png -------------------------------------------------------------------------------- /docs/img/range-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/range-field-input.png -------------------------------------------------------------------------------- /docs/img/relationship-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/relationship-field-input.png -------------------------------------------------------------------------------- /docs/img/relationship-field-possible-types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/relationship-field-possible-types.png -------------------------------------------------------------------------------- /docs/img/relationship-field-post-type-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/relationship-field-post-type-config.png -------------------------------------------------------------------------------- /docs/img/repeater-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/repeater-field-input.png -------------------------------------------------------------------------------- /docs/img/repeater-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/repeater-field-query.png -------------------------------------------------------------------------------- /docs/img/select-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/select-field-input.png -------------------------------------------------------------------------------- /docs/img/select-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/select-field-query.png -------------------------------------------------------------------------------- /docs/img/taxonomy-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/taxonomy-field-input.png -------------------------------------------------------------------------------- /docs/img/taxonomy-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/taxonomy-field-query.png -------------------------------------------------------------------------------- /docs/img/taxonomy-field-taxonomy-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/taxonomy-field-taxonomy-config.png -------------------------------------------------------------------------------- /docs/img/text-area-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/text-area-field-input.png -------------------------------------------------------------------------------- /docs/img/text-field-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/text-field-config.png -------------------------------------------------------------------------------- /docs/img/text-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/text-field-input.png -------------------------------------------------------------------------------- /docs/img/text-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/text-field-query.png -------------------------------------------------------------------------------- /docs/img/time-picker-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/time-picker-field-input.png -------------------------------------------------------------------------------- /docs/img/true-false-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/true-false-field-input.png -------------------------------------------------------------------------------- /docs/img/url-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/url-field-input.png -------------------------------------------------------------------------------- /docs/img/user-field-input-multiple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/user-field-input-multiple.png -------------------------------------------------------------------------------- /docs/img/user-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/user-field-input.png -------------------------------------------------------------------------------- /docs/img/user-field-query-multiple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/user-field-query-multiple.png -------------------------------------------------------------------------------- /docs/img/user-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/user-field-query.png -------------------------------------------------------------------------------- /docs/img/wysiwyg-field-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/wysiwyg-field-input.png -------------------------------------------------------------------------------- /docs/img/wysiwyg-field-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wp-graphql/wp-graphql-acf/665d3f6ebb0364dacf81be57a80838dd0df87189/docs/img/wysiwyg-field-query.png -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === WPGraphQL for Advanced Custom Fields === 2 | Contributors: WPGraphQL, jasonbahl 3 | Donate link: https://wpgraphql.com/acf 4 | Tags: WPGraphQL, GraphQL, API, Advanced Custom Fields, ACF 5 | Requires at least: 5.0 6 | Tested up to: 5.1.1 7 | Stable tag: 0.6.2 8 | License: GPL-3 9 | License URI: https://www.gnu.org/licenses/gpl-3.0.html 10 | 11 | WPGraphQL for Advanced Custom Fields exposes ACF Field Groups and Fields to the WPGraphQL Schema. 12 | 13 | == Description == 14 | 15 | WPGraphQL for Advanced Custom Fields exposes ACF Field Groups and Fields to the WPGraphQL Schema, 16 | allowing for interacting with ACF field data using GraphQL Queries. 17 | 18 | == Changelog == 19 | 20 | SEE: https://github.com/wp-graphql/wp-graphql-acf/releases 21 | 22 | == Upgrade Notice == 23 | 24 | = 0.6.2 = 25 | 26 | NOTE: This is the final release of this plugin. Please migrate to the [new WPGraphQL for ACF](https://github.com/wp-graphql/wpgraphql-acf) at your earliest convenience. 27 | 28 | 29 | = 0.1.1 = 30 | ACF Field groups were not properly being added to the GraphQL Schema for Custom Post Types. This 31 | addresses that issue, so now Field groups that are set to "show_in_graphql" and are assigned to a 32 | Custom Post Type that's also set to "show_in_graphql" will now be present in the Schema. 33 | -------------------------------------------------------------------------------- /src/class-acf.php: -------------------------------------------------------------------------------- 1 | setup_constants(); 35 | self::$instance->includes(); 36 | self::$instance->actions(); 37 | self::$instance->filters(); 38 | self::$instance->init(); 39 | } 40 | 41 | /** 42 | * Fire off init action 43 | * 44 | * @param ACF $instance The instance of the WPGraphQL\ACF class 45 | */ 46 | do_action( 'graphql_acf_init', self::$instance ); 47 | 48 | /** 49 | * Return the WPGraphQL Instance 50 | */ 51 | return self::$instance; 52 | } 53 | 54 | /** 55 | * Throw error on object clone. 56 | * The whole idea of the singleton design pattern is that there is a single object 57 | * therefore, we don't want the object to be cloned. 58 | * 59 | * @access public 60 | * @return void 61 | */ 62 | public function __clone() { 63 | 64 | // Cloning instances of the class is forbidden. 65 | _doing_it_wrong( __FUNCTION__, esc_html__( 'The \WPGraphQL\ACF class should not be cloned.', 'wp-graphql-acf' ), '0.0.1' ); 66 | 67 | } 68 | 69 | /** 70 | * Disable unserializing of the class. 71 | * 72 | * @access protected 73 | * @return void 74 | */ 75 | public function __wakeup() { 76 | 77 | // De-serializing instances of the class is forbidden. 78 | _doing_it_wrong( __FUNCTION__, esc_html__( 'De-serializing instances of the \WPGraphQL\ACF class is not allowed', 'wp-graphql-acf' ), '0.0.1' ); 79 | 80 | } 81 | 82 | /** 83 | * Setup plugin constants. 84 | * 85 | * @access private 86 | * @return void 87 | */ 88 | private function setup_constants() { 89 | 90 | // Plugin Folder Path. 91 | if ( ! defined( 'WPGRAPHQL_ACF_PLUGIN_DIR' ) ) { 92 | define( 'WPGRAPHQL_ACF_PLUGIN_DIR', plugin_dir_path( __FILE__ . '/..' ) ); 93 | } 94 | 95 | // Plugin Folder URL. 96 | if ( ! defined( 'WPGRAPHQL_ACF_PLUGIN_URL' ) ) { 97 | define( 'WPGRAPHQL_ACF_PLUGIN_URL', plugin_dir_url( __FILE__ . '/..' ) ); 98 | } 99 | 100 | // Plugin Root File. 101 | if ( ! defined( 'WPGRAPHQL_ACF_PLUGIN_FILE' ) ) { 102 | define( 'WPGRAPHQL_ACF_PLUGIN_FILE', __FILE__ . '/..' ); 103 | } 104 | 105 | } 106 | 107 | /** 108 | * Include required files. 109 | * Uses composer's autoload 110 | * 111 | * @access private 112 | * @return void 113 | */ 114 | private function includes() { 115 | 116 | // Autoload Required Classes. 117 | } 118 | 119 | /** 120 | * Sets up actions to run at certain spots throughout WordPress and the WPGraphQL execution 121 | * cycle 122 | */ 123 | private function actions() { 124 | 125 | } 126 | 127 | /** 128 | * Setup filters 129 | */ 130 | private function filters() { 131 | 132 | /** 133 | * This filters any field that returns the `ContentTemplate` type 134 | * to pass the source node down to the template for added context 135 | */ 136 | add_filter( 'graphql_resolve_field', function( $result, $source, $args, $context, ResolveInfo $info, $type_name, $field_key, $field, $field_resolver ) { 137 | if ( isset( $info->returnType ) && strtolower( 'ContentTemplate' ) === strtolower( $info->returnType ) ) { 138 | if ( is_array( $result ) && ! isset( $result['node'] ) && ! empty( $source ) ) { 139 | $result['node'] = $source; 140 | } 141 | } 142 | return $result; 143 | }, 10, 9 ); 144 | 145 | } 146 | 147 | /** 148 | * Initialize 149 | */ 150 | private function init() { 151 | 152 | $config = new Config(); 153 | add_action( 'graphql_register_types', [ $config, 'init' ], 10, 1 ); 154 | 155 | $acf_settings = new ACF_Settings(); 156 | $acf_settings->init(); 157 | 158 | } 159 | 160 | } 161 | -------------------------------------------------------------------------------- /src/class-acfsettings.php: -------------------------------------------------------------------------------- 1 | is_acf6_or_higher = defined( 'ACF_MAJOR_VERSION' ) && version_compare( ACF_MAJOR_VERSION, 6, '>=' ); 25 | 26 | /** 27 | * Add settings to individual fields to allow each field granular control 28 | * over how it's shown in the GraphQL Schema 29 | */ 30 | add_action( 'acf/render_field_settings', [ $this, 'add_field_settings' ], 10, 1 ); 31 | 32 | /** 33 | * Enqueue scripts to enhance the UI of the ACF Field Group Settings 34 | */ 35 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_graphql_acf_scripts' ], 10, 1 ); 36 | 37 | /** 38 | * Register meta boxes for the ACF Field Group Settings 39 | */ 40 | add_action( 'add_meta_boxes', [ $this, 'register_meta_boxes' ] ); 41 | 42 | /** 43 | * Register an AJAX action and callback for converting ACF Location rules to GraphQL Types 44 | */ 45 | add_action( 'wp_ajax_get_acf_field_group_graphql_types', [ $this, 'ajax_callback' ] ); 46 | 47 | } 48 | 49 | /** 50 | * Handle the AJAX callback for converting ACF Location settings to GraphQL Types 51 | * 52 | * @return void 53 | */ 54 | public function ajax_callback() { 55 | 56 | if ( isset( $_POST['data'] ) ) { 57 | 58 | $form_data = []; 59 | 60 | parse_str( $_POST['data'], $form_data ); 61 | 62 | if ( empty( $form_data ) || ! isset( $form_data['acf_field_group'] ) ) { 63 | wp_send_json( __( 'No form data.', 'wp-graphql-acf' ) ); 64 | } 65 | 66 | $field_group = isset( $form_data['acf_field_group'] ) ? $form_data['acf_field_group'] : []; 67 | $rules = new LocationRules( [ $field_group ] ); 68 | $rules->determine_location_rules(); 69 | 70 | $group_name = isset( $field_group['graphql_field_name'] ) ? $field_group['graphql_field_name'] : $field_group['title']; 71 | $group_name = $rules->format_field_name( $group_name ); 72 | 73 | $all_rules = $rules->get_rules(); 74 | if ( isset( $all_rules[ $group_name ] ) ) { 75 | wp_send_json( [ 'graphql_types' => array_values( $all_rules[ $group_name ] ) ] ); 76 | } 77 | wp_send_json( [ 'graphql_types' => null ] ); 78 | } 79 | 80 | echo __( 'No location rules were found', 'wp-graphql-acf' ); 81 | wp_die(); 82 | } 83 | 84 | /** 85 | * Register the GraphQL Settings metabox for the ACF Field Group post type 86 | * 87 | * @return void 88 | */ 89 | public function register_meta_boxes() { 90 | add_meta_box( 'wpgraphql-acf-meta-box', __( 'GraphQL', 'wp-graphql-acf' ), [ 91 | $this, 92 | 'display_metabox' 93 | ], [ 'acf-field-group' ] ); 94 | } 95 | 96 | /** 97 | * Display the GraphQL Settings Metabox on the Field Group admin page 98 | * 99 | * @param $field_group_post_object 100 | */ 101 | public function display_metabox( $field_group_post_object ) { 102 | 103 | global $field_group; 104 | 105 | /** 106 | * Render a field in the Field Group settings to allow for a Field Group to be shown in GraphQL. 107 | */ 108 | acf_render_field_wrap( 109 | [ 110 | 'label' => __( 'Show in GraphQL', 'acf' ), 111 | 'instructions' => __( 'If the field group is active, and this is set to show, the fields in this group will be available in the WPGraphQL Schema based on the respective Location rules.' ), 112 | 'type' => 'true_false', 113 | 'name' => 'show_in_graphql', 114 | 'prefix' => 'acf_field_group', 115 | 'value' => isset( $field_group['show_in_graphql'] ) ? (bool) $field_group['show_in_graphql'] : false, 116 | 'ui' => 1, 117 | ], 118 | 'div', 119 | 'label', 120 | true 121 | ); 122 | 123 | /** 124 | * Render a field in the Field Group settings to set the GraphQL field name for the field group. 125 | */ 126 | acf_render_field_wrap( 127 | [ 128 | 'label' => __( 'GraphQL Field Name', 'acf' ), 129 | 'instructions' => __( 'The name of the field group in the GraphQL Schema. Names should not include spaces or special characters. Best practice is to use "camelCase".', 'wp-graphql-acf' ), 130 | 'type' => 'text', 131 | 'prefix' => 'acf_field_group', 132 | 'name' => 'graphql_field_name', 133 | 'required' => isset( $field_group['show_in_graphql'] ) ? (bool) $field_group['show_in_graphql'] : false, 134 | 'placeholder' => ! empty( $field_group['graphql_field_name'] ) ? $field_group['graphql_field_name'] : null, 135 | 'value' => ! empty( $field_group['graphql_field_name'] ) ? $field_group['graphql_field_name'] : null, 136 | ], 137 | 'div', 138 | 'label', 139 | true 140 | ); 141 | 142 | acf_render_field_wrap( 143 | [ 144 | 'label' => __( 'Manually Set GraphQL Types for Field Group', 'acf' ), 145 | 'instructions' => __( 'By default, ACF Field groups are added to the GraphQL Schema based on the field group\'s location rules. Checking this box will let you manually control the GraphQL Types the field group should be shown on in the GraphQL Schema using the checkboxes below, and the Location Rules will no longer effect the GraphQL Types.', 'wp-graphql-acf' ), 146 | 'type' => 'true_false', 147 | 'name' => 'map_graphql_types_from_location_rules', 148 | 'prefix' => 'acf_field_group', 149 | 'value' => isset( $field_group['map_graphql_types_from_location_rules'] ) ? (bool) $field_group['map_graphql_types_from_location_rules'] : false, 150 | 'ui' => 1, 151 | ], 152 | 'div', 153 | 'label', 154 | true 155 | ); 156 | 157 | $choices = Config::get_all_graphql_types(); 158 | acf_render_field_wrap( 159 | [ 160 | 'label' => __( 'GraphQL Types to Show the Field Group On', 'wp-graphql-acf' ), 161 | 'instructions' => __( 'Select the Types in the WPGraphQL Schema to show the fields in this field group on', 'wp-graphql-acf' ), 162 | 'type' => 'checkbox', 163 | 'prefix' => 'acf_field_group', 164 | 'name' => 'graphql_types', 165 | 'value' => ! empty( $field_group['graphql_types'] ) ? $field_group['graphql_types'] : [], 166 | 'toggle' => true, 167 | 'choices' => $choices, 168 | ], 169 | 'div', 170 | 'label', 171 | true 172 | ); 173 | 174 | ?> 175 |