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

Custom taxonomies not returning correct data #823

Closed
seagyn opened this issue Apr 25, 2019 · 0 comments · Fixed by #824
Closed

Custom taxonomies not returning correct data #823

seagyn opened this issue Apr 25, 2019 · 0 comments · Fixed by #824
Assignees

Comments

@seagyn
Copy link

seagyn commented Apr 25, 2019

When making a query to a custom taxonomy, I am getting inconsistent results. 1 taxonomy will return terms from another and sometimes it errors with: Method WPGraphQL\\Data\\Loader\\TermObjectLoader::loadKeys is expected to return an array with keys but got: null

Some example queries:

This returns terms from another custom tax

query GetCarMakes($first: Int, $after: String) {
    carMakes(first: $first, after: $after) {
      edges {
        node {
          id
          name
            carMakeId
        }
      }
    }
  }

This errors:

query GetCarModels($first: Int, $after: String) {
    carModels(first: $first, after: $after) {
      edges {
        node {
          id
          name
            carModelId
        }
      }
    }
  }

This is how I registered the tax (the other is identical):

register_taxonomy(
        'car_make',
        [ 'car', 'fixxrs' ],
        [
            'label'               => __( 'Make', 'fixxr-features' ),
            'public'              => false,
            'show_ui'             => true,
            'show_in_graphql'     => true,
            'graphql_single_name' => 'CarMake',
            'graphql_plural_name' => 'CarMakes',
            'hierarchical'        => true,
        ]
    );
jasonbahl added a commit to jasonbahl/wp-graphql that referenced this issue Apr 25, 2019
wp-graphql#823 - This fixes some funkiness in the TermObjectLoader, where we were using `get_term_by()` without the taxonomy passed. This now gets the term object from the queried term instead of getting from the cache
jasonbahl added a commit to jasonbahl/wp-graphql that referenced this issue Apr 25, 2019
…or TermObjectLoader, and makes sure term queries work for Custom Post Types
jasonbahl added a commit to jasonbahl/wp-graphql that referenced this issue Apr 25, 2019
jasonbahl added a commit to jasonbahl/wp-graphql that referenced this issue Apr 25, 2019
jasonbahl added a commit to jasonbahl/wp-graphql that referenced this issue Apr 25, 2019
@jasonbahl jasonbahl self-assigned this Apr 25, 2019
jasonbahl added a commit that referenced this issue Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants