GraphQL Integration

Created on 23 October 2024, about 1 month ago

Problem/Motivation

Currently it is possible to use the referenced view by the default handling of GraphQL Core Schema .
However, this integration will drop any of the reference field handling which pre-configures the views executable.
It would be great to be able to fully re-use the handling of this module to execute the referenced view.

Proposed resolution

Add the necessary GraphQL Core Schema extensions.
As far as I can tell this won't introduce any other dependencies on module level and hence I don't think it warrants creating an extra module.

Remaining tasks

  1. Write integration
  2. Try to figure out how to write tests
  3. Review

User interface changes

none

API changes

none

Data model changes

none

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇨🇭Switzerland das-peter

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @das-peter
  • Merge request !71Issue #3482668: GraphQL Integration → (Open) created by das-peter
  • Pipeline finished with Success
    about 1 month ago
    Total: 232s
    #317980
  • 🇨🇭Switzerland das-peter

    Integration added.
    Before the integration one could execute the referenced view like this:

    query ViewsReferenceFieldDemo {
      entityById(entityType: PARAGRAPH, id: 110) {
        ... on ParagraphViewsReferenceFieldDemo {
          bpViewRawField {
            first {
              entity {
                executable(displayId: "block_1") {
                  execute {
                    rows {
                      __typename
                      id
                      label
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    

    The change keeps this behavior untouched - but you can now use the following query to execute the view with viewsreference pre-configured:

    query ViewsReferenceFieldDemo {
      entityById(entityType: PARAGRAPH, id: 110) {
        ... on ParagraphViewsReferenceFieldDemo {
          bpViewRawField {
            first {
              executable {
                execute {
                  rows {
                    __typename
                    id
                    label
                  }
                }
              }
            }
          }
        }
      }
    }
    

    I had to duplicate quite a bit of code from \Drupal\viewsreference\Plugin\Field\FieldFormatter\ViewsReferenceFieldFormatter::viewElements().
    I think it's worth considering outsouring the preparation / building of the view into maybe a trait.

Production build 0.71.5 2024