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

Filter widgets by certain sidebar doesn't work with GraphQL #7

Open
mwardew opened this issue Jun 25, 2019 · 0 comments
Open

Filter widgets by certain sidebar doesn't work with GraphQL #7

mwardew opened this issue Jun 25, 2019 · 0 comments

Comments

@mwardew
Copy link

mwardew commented Jun 25, 2019

Hello.

I use Gatsby, Wordpress, plugin for gatsby gatsby-source-wordpress and this wp-api-menus-widgets-endpoints plugin.

My goal is to access widgets that belongs to certain sidebar - home_right_1.

Inside endpoint description it should work and it works.. but I can't create right GraphQL query - "Limit result set to widgets assigned to this sidebar."

Endpoint:

    "namespace": "wp/v2",
    "methods": [
        "GET",
        "POST"
    ],
    "endpoints": [
        {
            "methods": [
                "GET"
            ],
            "args": {
                "context": {
                "required": false,
                "default": "view",
                "description": "Scope under which the request is made; determines fields present in response.",
                "type": "string"
            },
            "page": {
                "required": false,
                "default": 1,
                "description": "Current page of the collection.",
                "type": "integer"
            },
            "per_page": {
                "required": false,
                "default": 10,
                "description": "Maximum number of items to be returned in result set.",
                "type": "integer"
            },
            "search": {
                "required": false,
                "description": "Limit results to those matching a string.",
                "type": "string"
            },
            "sidebar": {
                "required": false,
                "description": "Limit result set to widgets assigned to this sidebar.",
                "type": "string"
            }
        }
}

This works in browser - output is exactly what I need

wp-json/wp/v2/widgets?sidebar=home_right_1

However I have a problem with GraphQL query. I thought I can do something like this.

{
  allWordpressWpWidgets( filter: {
      sidebar: {
          eq: "home_right_1"
      }
  } ) {
    edges {
      node {
        title
      }
    }
  }
}

It doesn't work.. But if I want for example only sticky posts I can easily do that.

{
  allWordpressPost( filter: {
      sticky: {
          eq: true
      }
  } ) {
    edges {
      node {
        title
      }
    }
  }
}

Is possible to get only widgets that belongs to sidebar or not?

Thank you

@kadamwhite kadamwhite transferred this issue from WP-API/menus-endpoints Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant