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

WordPress settings can't be queried? #29684

Closed
jasonbahl opened this issue Nov 24, 2020 · 13 comments · Fixed by #29718
Closed

WordPress settings can't be queried? #29684

jasonbahl opened this issue Nov 24, 2020 · 13 comments · Fixed by #29718
Assignees
Labels
topic: source-wordpress Related to Gatsby's integration with WordPress

Comments

@jasonbahl
Copy link
Contributor

It appears there is some sort of regression with settings from WordPress.

Trying to query:

{
  wp {
    generalSettings {
      title
    }
  }
}

Doesn't work. It says that a databaseId and uri are required input for querying the wp field.

Screen Shot 2020-11-24 at 9 57 33 AM

@jonlow
Copy link
Contributor

jonlow commented Jan 8, 2021

Also having this issue


Gatsby
"gatsby-source-wordpress-experimental": "^7.0.6"

Wordpress 5.4.4
 "wp-graphql/wp-graphql-acf": "^0.4.0",
 "wp-graphql/wp-graphql": "1.1.3",
 

@TylerBarnes TylerBarnes transferred this issue from gatsbyjs/gatsby-source-wordpress-experimental Feb 22, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 22, 2021
@TylerBarnes TylerBarnes added topic: source-wordpress Related to Gatsby's integration with WordPress and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Feb 22, 2021
@TylerBarnes TylerBarnes self-assigned this Feb 22, 2021
@TylerBarnes
Copy link
Contributor

@jonlow apologies for the delay here - I'm investigating this now. In the meantime if you're still running into this issue you can get around it by querying for allWp instead and using the only node it returns:

{
  allWp {
    nodes {
      allSettings {
        discussionSettingsDefaultCommentStatus
      }
    }
  }
}

allWp.nodes[0].allSettings.discussionSettingsDefaultCommentStatus

@jasonbahl
Copy link
Contributor Author

@TylerBarnes curious why settings are considered nodes in Gatsby? Possibly that's the bug? The settings objects don't implement the Node interface. . .this seems like a bug to me. I wouldn't expect to query settings as a node

@TylerBarnes
Copy link
Contributor

Everything is a node in Gatsby so this is required. When we eventually add support for multiple instances of the plugin you'll want to be able to select which site you want to get settings from too 👍

@TylerBarnes
Copy link
Contributor

{
  wp(url: "http://mysite.com/graphql") {
   stuffs
  }
}

@jasonbahl
Copy link
Contributor Author

jasonbahl commented Feb 22, 2021

@TylerBarnes ah, interesting. Since settings objects don't have an ID, they don't follow the node spec.

But I suppose if you are identifying them by the origin endpoint, they might indeed have a unique identifier. 🤔

@TylerBarnes
Copy link
Contributor

They do have an id :) it's the site url - I set it when I create each node.

@TylerBarnes
Copy link
Contributor

It seems the problem here is the plugin is somehow adding the input args from another node type. I'm not sure why yet but I'll get to the bottom of it soon

@jasonbahl
Copy link
Contributor Author

jasonbahl commented Feb 22, 2021

Ah, ya, since that's a departure from WPGraphQL, that should probably be documented then. Is that why we weren't able to query them individually then? Do we need to query:

{
  wp(url: { eq: { "mysite.com/graphql" }} ) {
    ...settings
  }
}

@TylerBarnes
Copy link
Contributor

It's undocumented right now because the plugin only supports a single instance. Using { wp { ...settings } } works right now because there can only ever be 1 Wp node. Your example will be in the docs in the future but it will still break right now actually. It seems some other interface input args are somehow being applied so that databaseId and uri are required which doesn't make sense.

@TylerBarnes
Copy link
Contributor

@jasonbahl @jonlow the reason is you both have types in your WPGQL schema named "Filter" and Gatsby has a bug where it then uses fields from this type to create input filter arguments for other node types resulting in broken queries.

@jasonbahl
Copy link
Contributor Author

@TylerBarnes interesting. In my case this is the filters post type for documenting WPGraphQL filters: https://www.wpgraphql.com/filters/

@TylerBarnes
Copy link
Contributor

This is fixed in gatsby-source-wordpress@4.0.4!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: source-wordpress Related to Gatsby's integration with WordPress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants