GithubHelp home page GithubHelp logo

graphql-views's Introduction

GraphQL Views for Drupal

Build Status Code Coverage Code Quality

With graphql_views enabled a GraphQL views display can be added to any view in the system.

Results can be sorted, filtered based on content fields, and relationships can be added. There is also the option to return either the full entities, just a selection of fields, or even search results taken straight from a search server.

Any GraphQL views display will provide a field that will adapt to the views configuration:

  • The fields name will be composed of the views and displays machine names or configured manually.
  • If the view is configured with pagination, the field will accept pager arguments and return the result list and count field instead of the entity list directly.
  • Any exposed filters will be added to the filters input type that can be used to pass filter values into the view.
  • Any contextual filters will be added to the contextual_filters input type.
  • If a contextual filters validation criteria match an existing GraphQL type, the field will be added to this type too, and the value will be populated from the current result context.

Read more on:

Please also refer to the main Drupal GraphQL module for further information.

graphql-views's People

Contributors

bastnic avatar blazeyo avatar dan2k3k4 avatar fubhy avatar jmarkel avatar lennardwesterveld avatar lestatv avatar mkhamash avatar pasqualle avatar pmelab avatar visabhishek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql-views's Issues

Create release alpha6

Hi,

I need to use your module with the latest fixes (in particular the #14 ).
Can you create a new release please ?

Thanks a lot
Best regards,
Allan

Preview in an UI

Currently preview in a Views UI at /admin/structure/views/view/% does nothing.

It would be useful to at least print entity IDs or their label, so we can quickly prototype view settings.

Missing schema graphql_query_name

Drupal\Core\Config\Schema\SchemaIncompleteException : Schema errors for views.view.node_faq_query with the following errors: views.view.node_faq_query:display.graphql_1.display_options.graphql_query_name missing schema

Crashes when rendering fields

When displaying fields you cannot render fields you will get the following error.

NOTICE: PHP message: Uncaught PHP Exception LogicException: "Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead.

ATM I need to display these as raw values to avoid crashing.

viewDerivatives not understanding gql query variables

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!

PHP 8.2 update: Access array offset on value of type null

Avoid lots of warnings in dblog with this patch.

Environment built with these new components:

  • Drupal 10.1.4
  • PHP 8.2.11

Notifications to eliminate:

  • Warning: Trying to access array offset on value of type null in Drupal\graphql_views\Plugin\GraphQL\Fields\View->resolveValues() (line 101 of C:\xampp\htdocs\cia-drupal\docroot\modules\contrib\graphql_views\src\Plugin\GraphQL\Fields\View.php)
  • Warning: Trying to access array offset on value of type null in Drupal\graphql_views\Plugin\GraphQL\Fields\View->Drupal\graphql_views\Plugin\GraphQL\Fields{closure}() (line 118 of C:\xampp\htdocs\cia-drupal\docroot\modules\contrib\graphql_views\src\Plugin\GraphQL\Fields\View.php)

array_offset_on_value_of_type_null.patch

D10 comaptibility

Hi together

We need to make this module d10 compatible.
Basically just the info files core_version_requirement needs to be adjusted

Could you help me with the workflow of getting this into a graphql_views release?

Thanks and regards,
Jan

Drupal 9 compatibility

Code report:

CONTRIBUTED PROJECTS

GraphQL Views 8.x-1.0
Scanned on Wed, 06/03/2020 - 23:52.

1 error found. 8 warnings found.

modules/contrib/graphql_views/src/Plugin/views/row/GraphQLEntityRow.php:
┌─────────┬──────┬──────────────────────────────────────────────────────────────┐
│ STATUS │ LINE │ MESSAGE │
├─────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Fix now │ 64 │ Parameter $entityManager of method │
│ │ │ Drupal\graphql_views\Plugin\views\row\GraphQLEntityRow::__co │
│ │ │ nstruct() has typehint with deprecated interface │
│ │ │ Drupal\Core\Entity\EntityManagerInterface. Deprecated in │
│ │ │ drupal:8.0.0 and is removed from drupal:9.0.0. │
│ │ │ │
└─────────┴──────┴──────────────────────────────────────────────────────────────┘

modules/contrib/graphql_views/tests/src/Kernel/ContextualViewsTest.php:
┌──────────┬──────┬───────────────────────────────────────────────────────────┐
│ STATUS │ LINE │ MESSAGE │
├──────────┼──────┼───────────────────────────────────────────────────────────┤
│ Check │ │ Class Drupal\Tests\graphql_views\Kernel\ViewsTestBase not │
│ manually │ │ found and could not be autoloaded. │
│ │ │ │
│ Check │ 12 │ Class Drupal\Tests\graphql_views\Kernel\ViewsTestBase not │
│ manually │ │ found and could not be autoloaded. │
│ │ │ │
└──────────┴──────┴───────────────────────────────────────────────────────────┘

modules/contrib/graphql_views/tests/src/Kernel/ViewsTest.php:
┌──────────┬──────┬───────────────────────────────────────────────────────────┐
│ STATUS │ LINE │ MESSAGE │
├──────────┼──────┼───────────────────────────────────────────────────────────┤
│ Check │ │ Class Drupal\Tests\graphql_views\Kernel\ViewsTestBase not │
│ manually │ │ found and could not be autoloaded. │
│ │ │ │
│ Check │ 11 │ Class Drupal\Tests\graphql_views\Kernel\ViewsTestBase not │
│ manually │ │ found and could not be autoloaded. │
│ │ │ │
└──────────┴──────┴───────────────────────────────────────────────────────────┘

modules/contrib/graphql_views/tests/src/Kernel/ViewsTestBase.php:
┌──────────┬──────┬─────────────────────────────────────────────────────────────┐
│ STATUS │ LINE │ MESSAGE │
├──────────┼──────┼─────────────────────────────────────────────────────────────┤
│ Check │ │ Class │
│ manually │ │ Drupal\Tests\graphql_core\Kernel\GraphQLContentTestBase not │
│ │ │ found and could not be autoloaded. │
│ │ │ │
│ Check │ 17 │ Class │
│ manually │ │ Drupal\Tests\graphql_core\Kernel\GraphQLContentTestBase not │
│ │ │ found and could not be autoloaded. │
│ │ │ │
└──────────┴──────┴─────────────────────────────────────────────────────────────┘

modules/contrib/graphql_views/graphql_views.info.yml:
┌──────────┬──────┬────────────────────────────────────────────────────────────┐
│ STATUS │ LINE │ MESSAGE │
├──────────┼──────┼────────────────────────────────────────────────────────────┤
│ Check │ 0 │ Add core_version_requirement: ^8 || ^9 to │
│ manually │ │ modules/contrib/graphql_views/graphql_views.info.yml to │
│ │ │ designate that the module is compatible with Drupal 9. See │
│ │ │ https://drupal.org/node/3070687. │
│ │ │ │
└──────────┴──────┴────────────────────────────────────────────────────────────┘

modules/contrib/graphql_views/tests/modules/graphql_views_test/graphql_views_tes
t.info.yml:
┌──────────┬──────┬──────────────────────────────────────────────────────────────┐
│ STATUS │ LINE │ MESSAGE │
├──────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Check │ 0 │ Add core_version_requirement: ^8 || ^9 to │
│ manually │ │ modules/contrib/graphql_views/tests/modules/graphql_views_te │
│ │ │ st/graphql_views_test.info.yml to designate that the module │
│ │ │ is compatible with Drupal 9. See │
│ │ │ https://drupal.org/node/3070687. │
│ │ │ │
└──────────┴──────┴──────────────────────────────────────────────────────────────┘

Caching issues with search api view

I have caching issues on graphql queries on views that displays a search api index. New content is not being displayed and changes to content are not being reflected. Are there cache tags missing?

Adding an exposed filter breaks GraphiQL

Full error:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException</em>:  in <em class="placeholder">Drupal\graphql\Plugin\GraphQL\PluggableSchemaBuilder-&gt;findByName()</em> (line <em class="placeholder">122</em> of <em class="placeholder">modules/graphql/src/Plugin/GraphQL/PluggableSchemaBuilder.php</em>). <pre class="backtrace">Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase-&gt;buildArgumentType(Object, Array) (Line: 34)
Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase-&gt;buildArguments(Object) (Line: 45)
Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase-&gt;getDefinition(Object) (Line: 94)
Drupal\graphql\Plugin\GraphQL\Schemas\SchemaPluginBase-&gt;Drupal\graphql\Plugin\GraphQL\Schemas\{closure}(Object)
array_map(Object, Array) (Line: 95)
Drupal\graphql\Plugin\GraphQL\Schemas\SchemaPluginBase-&gt;extractDefinitions(Array) (Line: 72)
Drupal\graphql\Plugin\GraphQL\Schemas\SchemaPluginBase-&gt;getSchema() (Line: 139)
Drupal\graphql\GraphQL\Schema\SchemaLoader-&gt;getSchema(&#039;default&#039;) (Line: 86)
Drupal\graphql\GraphQL\Execution\QueryProcessor-&gt;processQuery(&#039;default&#039;, &#039;    query IntrospectionQuery {
      __schema {
        queryType { name }
        mutationType { name }
        subscriptionType { name }
        types {
          ...FullType
        }
        directives {
          name
          description
          locations
          args {
            ...InputValue
          }
        }
      }
    }

    fragment FullType on __Type {
      kind
      name
      description
      fields(includeDeprecated: true) {
        name
        description
        args {
          ...InputValue
        }
        type {
          ...TypeRef
        }
        isDeprecated
        deprecationReason
      }
      inputFields {
        ...InputValue
      }
      interfaces {
        ...TypeRef
      }
      enumValues(includeDeprecated: true) {
        name
        description
        isDeprecated
        deprecationReason
      }
      possibleTypes {
        ...TypeRef
      }
    }

    fragment InputValue on __InputValue {
      name
      description
      type { ...TypeRef }
      defaultValue
    }

    fragment TypeRef on __Type {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                  }
                }
              }
            }
          }
        }
      }
    }&#039;) (Line: 131)
Drupal\graphql\GraphQL\Utility\Introspection-&gt;introspect(&#039;default&#039;) (Line: 77)
Drupal\graphql\Controller\ExplorerController-&gt;viewExplorer(&#039;default&#039;)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 576)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
</pre>

This one works:
working-example-views.view.user_articles.yml.txt

This one breaks the explorer:
views.view.user_articles.yml.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.