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

additionalResolvers child field arguments aren't passed through to the backend / all fields are requested #1257

Open
paales opened this issue Dec 7, 2020 · 2 comments

Comments

@paales
Copy link

paales commented Dec 7, 2020

We're very happy what GraphQL Mesh is offering! Thanks for the hard work.

Added the following to my .meshrc.json, this does seem to work:

{
  "additionalTypeDefs": "extend type MagentoCategory { category: CategoryTree }",
  "additionalResolvers": [
    {
      "type": "MagentoCategory",
      "field": "category",
      "requiredSelectionSet": "{ url }",
      "targetSource": "Magento GraphQL",
      "targetMethod": "categories",
      "args": { "filters.url_path.eq": "{root.url}", "pageSize": "1" },
      "returnData": "items[0]",
      "resultDepth": 4
    }
  ]
}

To fetch the data I can now do:

query {
  pages(where: { url: "page/home" }) {
    content {
      __typename
      ... on RowProductGrid {
        magentoCategory {
          category {
            url_path
            product_count
            name
            products(pageSize:2) {
              items {
                name
              }
            }
          }
        }
      }
    }
  }
}

What I'd expect:
I'd expect the pageSize: 2 to be passed.

What actually happens:
It doesn't pass the argument and returns too many results

Schermafbeelding 2020-12-07 om 14 14 42

@paales
Copy link
Author

paales commented Dec 12, 2020

Also, it seems that is requesting every field on the planet from the backend instead of only selecting the fields that are requested. I was wondering if this could be cleaned up in some way, as this chokes the backend?

I was already trying to figure out why it was choking when I set the depth to a relatively high value, but that explains it.

Schermafbeelding 2020-12-12 om 14 24 38

I'd expect the backend query to only fetch the fields that are actually requested by the query?

@paales paales changed the title additionalResolvers child field arguments aren't passed through to the backend additionalResolvers child field arguments aren't passed through to the backend / all fields are requested Dec 14, 2020
@paales
Copy link
Author

paales commented Dec 17, 2020

@ardatan Maybe I can help with implementing the feature, but I hit a roadblock, maybe you can help a little bit

I can't find any existing tests that test the current additionalResolvers functionality. Maybe you can help me and set up a test?

Maybe a small thing: The additionalResolvers are handled in the config package, doesn't seem the right place for such a functionality?

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