Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

No Form Fields Available when Building with Gatsby #449

Open
2 of 3 tasks
pseelinger opened this issue Feb 3, 2025 · 6 comments
Open
2 of 3 tasks

No Form Fields Available when Building with Gatsby #449

pseelinger opened this issue Feb 3, 2025 · 6 comments
Labels
status: needs info 🔎 Needs more info before action can be taken

Comments

@pseelinger
Copy link

Description

Using GraphQL IDE inside the CMS:
Image
Using GraphiQL during gatsby develop
Image

Since upgrading to v0.13.0, form fields return from the GraphQL endpoint fine in the admin, but using gatsby-source-wordpress, any attempt to fetch formFields returns an empty array. I tried directly hitting my GraphQL endpoint using Httpie to make sure this wasn't an authentication issue, and it returns the fields just fine.

Steps to reproduce

Install the plugins below and test the following queries. The frontend of the site should use Gatsby with gatsby-source-wordpress installed:

Backend Query:

  gfForms {
    edges {
      node {
        formFields {
          edges {
            node {
              type
            }
          }
        }
      }
    }
  }
}

Frontend Query:

  allWpGfForm {
    edges {
      node {
        formFields {
          nodes {
            type
          }
        }
      }
    }
  }
}

Additional context

Tested this with just WPGraphQL, WP Gatsby, and WP GraphQL for Gravity Forms activated on the site.

Plugin Version

0.13.0.1

Gravity Forms Version

2.9.2

WordPress Version

6.7.1

WPGraphQL Version

1.31.1

Additional enviornmental details

PHP version: 8.3.16
WP Gatsby: 2.3.3
gatsby-source-wordpress: 7.14.0

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for Gravity Forms, WPGraphQL, and WPGraphQL for Gravity Forms

  • Yes
  • My issue is with a specific 3rd-party plugin.
@justlevine
Copy link
Member

Thanks for reporting this @pseelinger !

Please take a look at the debugging steps mentioned in this comment: #448 (comment)

While idk if the issues are related, what is related is how Gatsby hides all the pertinent debug information. Hopefully those logs should be able to point to whatever is tripping Gatsby up 🤞

@justlevine justlevine added the status: needs info 🔎 Needs more info before action can be taken label Feb 3, 2025
@pseelinger
Copy link
Author

Thanks for the quick response @justlevine

I've attached my two queries below using the debug steps from Gatsby. The backend query does work if I hit it from GraphQL playground. I'll keep looking into this, but maybe this note is relevant?

Note: A common cause of this problem is that you're using ACF and you've named multiple fields with the same name but in different field groups. Identify conflicting field names and rename them.

node-list-query-backend.txt
node-list-query-frontend.txt

@justlevine
Copy link
Member

The backend query does work if I hit it from GraphQL playground.

What versions (of both WPGraphQL and WPGraphQL for GF) were the last to work in Gatsby.

If there's backend error, then that means the issue is probably with WPGatsby (or gatsby-source-wordpress) automagical transformations. Hoping that narrowing down the version diff will point to an obvious conflict.

maybe this note is relevant?

Note: A common cause of this problem is that you're using ACF and you've named multiple fields with the same name but in different field groups. Identify conflicting field names and rename them.

I'm hoping that for the sake of all this debugging you've disabled all WordPress plugins/custom code except for WPGraphQL, WPGraphQL for GF, and WPGatsby. So it shouldn't be a problem ;)

@pseelinger
Copy link
Author

What versions (of both WPGraphQL and WPGraphQL for GF) were the last to work in Gatsby.

Form fields appear using WPGraphQL 1.31.1 with WPGraphQL for Gravity Forms 0.12.6.1, as well with any version of WP GraphQL from 1.26. I only start to see this after hitting 0.13.0 on WPGraphQL for Gravity Forms. I tried a couple different combinations with 0.13.0.1 and got the same issue. I'm also aware gatsby-source-wordpress hasn't gotten significant updates in a while and might be the real source of the issue as this plugin appears to be outputting data correctly to everything else.

I'm hoping that for the sake of all this debugging you've disabled all WordPress plugins/custom code except for WPGraphQL, WPGraphQL for GF, and WPGatsby. So it shouldn't be a problem ;)

Oh definitely. I have a separate repo set up only with those plugins to reproduce the issue. My thought was maybe there was a conflict in Gravity Forms definitions, but looking through the types in the two queries I posted here I don't see any.

@justlevine
Copy link
Member

What versions (of both WPGraphQL and WPGraphQL for GF) were the last to work in Gatsby.

Form fields appear using WPGraphQL 1.31.1 with WPGraphQL for Gravity Forms 0.12.6.1, as well with any version of WP GraphQL from 1.26. I only start to see this after hitting 0.13.0 on WPGraphQL for Gravity Forms.

This sadly (but unsurprisingly) tracks, as v0.13.0 refactored the connection resolvers to adopt the Connection Resolver API that were made in WPGraphQL v1.26.0, which was already pretty finickiy in WPGatsby.

Also adds context to #448 , which seems to have been introduced in the same timeframe involving a similarly-refactored ConnectionResolver.

Next step is figuring out what the actual source of the issue is (really hard to debug anything related to gatsby, especially without a particular error message to look at), and only then will I be able to say if this is something we can fix on our side or if WPGatsby has finally EOLd.

Any chance you have something in you WordPress debug.log, does gatsby's response change if you enable WPGraphQL Debugging (in settings or wp-config.php)?

@pseelinger
Copy link
Author

So nothing in the debug log other than an 8.3 warning about Gatsby's action monitor, which I already tested fixing and doesn't seem to have an effect. That is until I turned on GRAPHQL_DEBUG. After turning that on I get two things:

[05-Feb-2025 13:02:48 UTC] PHP Deprecated:  preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /Users/patrickseelinger/Sites/gatsby-test-cms/web/app/plugins/wp-graphql/src/Router.php on line 278

[05-Feb-2025 13:03:02 UTC] PHP Warning:  Undefined array key "GfFieldChoice" in /Users/patrickseelinger/Sites/gatsby-test-cms/web/app/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Type/Schema.php on line 437

This reminds me I probably should have mentioned this is a roots.io Bedrock WordPress setup. I don't think that would have any effect, but I should have mentioned it before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs info 🔎 Needs more info before action can be taken
Projects
None yet
Development

No branches or pull requests

2 participants