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

error in gatsby-node js on active plugin in the wordpress #169

Closed
tinelli22 opened this issue Sep 11, 2020 · 9 comments
Closed

error in gatsby-node js on active plugin in the wordpress #169

tinelli22 opened this issue Sep 11, 2020 · 9 comments
Assignees
Labels
Location Rules Issues related to ACF Location Rules Needs to be reproduced status: awaiting author response Additional information has been requested from the author

Comments

@tinelli22
Copy link

When I active the plugin wp-graphql-acf-master, my gatsby project in gatsby-node.js launch this error:

const { data } = await graphql(`

Error: Names must match /^[_a-zA-Z][_a-zA-Z0-9]$/ but "" does not.
Names must match /^[_a-zA-Z][_a-zA-Z0-9]
$/ but "" does not.

  • graphql-runner.ts:98 GraphQLRunner.validate
    [...]/[gatsby]/src/query/graphql-runner.ts:98:22

  • graphql-runner.ts:162 GraphQLRunner.query
    [....]/[gatsby]/src/query/graphql-runner.ts:162:25

  • create-graphql-runner.ts:59
    [...]/[gatsby]/src/bootstrap/create-graphql-runner.ts:59:8

  • gatsby-node.js:58 Object.exports.createPages
    ------//-----
    A part of the code:

exports.createPages = async ({ actions, graphql }) => {
const { createPage } = actions
......
const PostTemplate = path.resolve(./src/templates/blog/Post/index.js)

const { data } = await graphql(`
.............
..................
}

@jasonbahl jasonbahl self-assigned this Sep 11, 2020
@jasonbahl
Copy link
Contributor

@tinelli22 this looks like perhaps you've added an ACF Field Group with an empty graphQLFieldName setting.

Can you make sure any field groups you have in ACF have a GraphQL Field Name set?

Screen Shot 2020-09-11 at 8 59 06 AM

@jasonbahl jasonbahl added the status: awaiting author response Additional information has been requested from the author label Sep 11, 2020
@tinelli22
Copy link
Author

tinelli22 commented Sep 11, 2020

I create only one, following your example on "WPGraphQL for ACF" youtube

@hashinteractive
Copy link

hashinteractive commented Sep 23, 2020

I'm getting this same error on gatsby develop command and it's erring out:

Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "" does not.

The GraphQL Field Name is populated and it's showing up in the WPGraphiQL explorer but when I go to build/develop with Gatsby it's throwing this error.

ACF Settings:

image

WPGraphiQL Explorer:

image

Gatsby Develop/Build Error:

image

Any ideas what this might be causing this?

@jasonbahl
Copy link
Contributor

Can you provide exports of your ACF field groups? Perhaps there's something in the Field Group registration that can help replicate this.

@jasonbahl
Copy link
Contributor

@hashinteractive are you also using Custom Post Type UI and WPGraphQL for Custom Post Type UI by chance?

@hashinteractive
Copy link

@jasonbahl thanks for taking a look. I'm not using Custom Post Type UI

I believe it had something to do with when the fieldGroup was saved the fieldGroup name (for graphql schema) was somehow saved as empty (even though I had filled out the GraphQL Field Name) and even if I changed/updated the GraphQL Field Name it still was throwing this error (despite clearing data cache using gatsby clean).

Tyler addressed this issue and might be resolved on Gatsby side: gatsbyjs/gatsby-source-wordpress-experimental#169

I had to resolve this by creating a new instance of WordPress, installed required plugins (WP GraphQL, WP Gatsby) and porting data over. It was early on in the project so I wasn't too far in so it wasn't a big deal for me but anyone further along in a project getting this error might have other concerns.

@jasonbahl
Copy link
Contributor

Ok. Interesting.

Ya, my only thought is that somehow some ACF Field Groups were saved with show_in_graphql => true but no graphql_field_name.

I'll see if I can reproduce this and guard against it.

@jasonbahl jasonbahl added the Location Rules Issues related to ACF Location Rules label Mar 30, 2021
@jasonbahl jasonbahl added this to the ACF Schema Location Rules milestone Mar 30, 2021
@jasonbahl jasonbahl removed this from Upcoming in ACF Schema Location Rules Mar 30, 2021
@hashinteractive
Copy link

That might have been the case, I have not done any programmatic definition for the the ACF Field Group such as show_in_graphql => true and always have used the GUI on the ACF Field Group editor to name the field but maybe for some reason it wasn't saving (or saving as an empty string) in the admin editor and that was creating the error. I haven't been able to reproduce since.

image

@jasonbahl
Copy link
Contributor

WPGraphQL v0.5.0 has a lot of improvements to the settings fields.

I've not been able to reproduce this issue, even pre-v0.5.0, but I believe the changes to v0.5.0 guard against this even more.

I'm going to close this, but if the issue persists after v0.5.0, please open a new issue with clear steps to reproduce and we'll look into it further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Location Rules Issues related to ACF Location Rules Needs to be reproduced status: awaiting author response Additional information has been requested from the author
Projects
None yet
Development

No branches or pull requests

3 participants