wp-graphql / wp-graphql-acf

WPGraphQL for Advanced Custom Fields
https://wpgraphql.com/acf
627 stars 123 forks source link

Null user fields #307

Closed garryburch closed 1 year ago

garryburch commented 2 years ago

In WP with WPGraphQL for Advanced Custom Fields Version 0.5.3 & WP GraphQL Version 1.6.10 & WP Gatsby Version 2.1.1

I can see the user field nerf in WP Graphql IDE:

Screenshot_20220112_131307

Yet after gatsby build and @ http://localhost:8000/__graphql

Screenshot_20220112_131241

my local

System: OS: Linux 5.11 KDE neon 5.23 CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11900H @ 2.50GHz Shell: 5.0.17 - /bin/bash Binaries: Node: 14.18.2 - ~/.nvm/versions/node/v14.18.2/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v14.18.2/bin/yarn npm: 6.14.15 - ~/.nvm/versions/node/v14.18.2/bin/npm Languages: Python: 2.7.18 - /usr/bin/python Browsers: Chrome: 97.0.4692.71 Firefox: 95.0.1 npmPackages: gatsby: ^4.4.0 => 4.4.0 gatsby-background-image: ^1.6.0 => 1.6.0 gatsby-cli: ^4.4.0 => 4.4.0 gatsby-image: ^3.11.0 => 3.11.0 gatsby-plugin-algolia: ^0.25.0 => 0.25.0 gatsby-plugin-breadcrumb: ^12.1.1 => 12.3.0 gatsby-plugin-canonical-urls: ^4.4.0 => 4.4.0 gatsby-plugin-csp: ^1.1.3 => 1.1.3 gatsby-plugin-feed: ^4.4.0 => 4.4.0 gatsby-plugin-google-tagmanager: ^4.4.0 => 4.4.0 gatsby-plugin-image: ^2.4.0 => 2.4.0 gatsby-plugin-manifest: ^4.4.0 => 4.4.0 gatsby-plugin-netlify: ^4.0.0-next.0 => 4.0.0-next.0 gatsby-plugin-postcss: ^5.4.0 => 5.4.0 gatsby-plugin-react-helmet: ^5.4.0 => 5.4.0 gatsby-plugin-react-svg: ^3.1.0 => 3.1.0 gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0 gatsby-plugin-remove-trailing-slashes: ^4.4.0 => 4.4.0 gatsby-plugin-robots-txt: ^1.5.5 => 1.6.14 gatsby-plugin-sass: ^5.4.0 => 5.4.0 gatsby-plugin-sharp: ^4.4.0 => 4.4.0 gatsby-plugin-sitemap: ^5.4.0 => 5.4.0 gatsby-plugin-styled-components: ^5.4.0 => 5.4.0 gatsby-source-atom: ^0.3.0 => 0.3.0 gatsby-source-filesystem: ^4.4.0 => 4.4.0 gatsby-source-wordpress: 6.4.0 => 6.4.0 gatsby-transformer-sharp: ^4.4.0 => 4.4.0 npmGlobalPackages: gatsby-cli: 4.4.0

Thanks for any info - you rock!

emanuelemacri commented 1 year ago

Same issue 😢

andresantiagohellmann commented 1 year ago

Same issue 😢2

jasonbahl commented 1 year ago

Hey, so this issue is most likely related to Access Control.

Users are not all public entities.

When making authenticated requests in GraphQL you can see users that you might not be able to see when making public requests.

Users in WordPress are not public if they have not written any content in public-facing post types. In traditional WordPress, the only way to see these users is by logging into the admin. WPGraphQL respects these rules and does not return non-public users to public GraphQL requests.

My hunch is that you're using user IDs as values of ACF fields, querying them in GraphiQL (old versions were authenticated by default, and the newer versions have an Auth Switch toggle where you can execute as public or authenticated).

If you can see the user while authenticated but cannot while making public requests, this means the user is not a public entity.

If you want to make all users Public, regardless of whether they've published public content, you could do something like the following: https://www.wpgraphql.com/recipes/make-all-users-public

If you don't believe this is related to the User Model's Access Control logic, please provide additional steps to reproduce in a new issue.


Also, while I'm here, I highly recommend checking out the new version of WPGraphQL for ACF being re-written completely from the ground up. It's getting close to a stable release on WordPress.org and will be the version we'll be supporting going forward. You can check it out here: https://github.com/wp-graphql/wpgraphql-acf