Skip to content

viewDerivatives not understanding gql query variables #37

Open
@julpod

Description

@julpod

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions