drupal-graphql / drupal-graphql/graphql-views

viewDerivatives not understanding gql query variables

Open
#37 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
10
Forks
20
PR merge metrics
No merged PRs in 30d

Description

Hi all,

First of all thanks for this really powerful module!!

I believe there is a bug on how the `viewDerivative` process the `ViewsFilterInput`.

**Sample gql:**

```
query ($entityId: String!, $entityLanguage: LanguageId!, $langcode: String!) {
one: nodeById(id: $entityId, language: $entityLanguage) {
id: entityId
title: entityLabel
... on NodePage {
fieldContent {
component: entity {
... on ParagraphCatalog {
fieldView {
view: viewDerivative(filter: {langcode: "en"}) {
... on PostsGraphql1ViewResult {
results {
... on NodePost {
entityId
entityLabel
langcode {
value
}
}
}
}
}
}
}
}
}
}
}
two: nodeById(id: $entityId, language: $entityLanguage) {
id: entityId
title: entityLabel
... on NodePage {
fieldContent {
component: entity {
... on ParagraphCatalog {
fieldView {
view: viewDerivative(filter: {langcode: $langcode}) {
... on PostsGraphql1ViewResult {
results {
... on NodePost {
entityId
entityLabel
langcode {
value
}
}
}
}
}
}
}
}
}
}
}
three: postsGraphql1View(filter: {langcode: $langcode}) {
results {
langcode {
value
}
}
}
}
```

and here is the view:

Screen Shot 2020-06-23 at 19 08 39

- query `one` works just fine when using `view: viewDerivative(filter: {langcode: "en"}) {` (notice the hardcoded string for the language code).
- query `two` does not work when using `view: viewDerivative(filter: {langcode: $langcode}) {` (notice that here I'm using the variable.
- query `three` also works fine when using `three: postsGraphql1View(filter: {langcode: $langcode}) {` (here I'm using a variable but using the Query directly.

I already tried using `contextualFilter` instead of `filter` and the same behaviour happens.

Is there any workaround for this kind of scenario?

Thanks in advance!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.