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

Added possibility to explore the actual field selection tree #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 13, 2020

  1. Added possibility to explore the actual field selection tree

    Each resolver's context will now be able to access through the graph
    of elements that were selected as part of the execution of this resolve via the standard
    go context's value.
    
    The returned field is an interface representing a subset of the functionality of the
    internal/exec/selected package, enough for the developer to know what was queried by the
    user.
    
    I'm opening the PR to start a discussion about offering this feature to end user of the
    library. We have started using it in our own fork of the library.
    
    ##### Design
    
    This introduces new API interfaces the would become part of the standard library.
    
    The interface is currently a simple wrapper around elements of
    `internal/exec/selected/Selection` interface needed to "walk" the selected field.
    Hopefully, I got the structure right.
    
    I've currently used `Identifier()` instead of `Name()` and `Aliased()` instead of `Alias` to not renamed the field's name
    since there would be conflict with struct fields in the `internal/exec/selected/Selection`
    package. If we agree, the internal struct could change so the interface has the best name.
    
    A future addition that I forsee could be:
    - A "path" retrieval syntax "a la" gjson to quickly extract some nodes of the selection, for
      example with the star wars element ".search[]" that would return all type assertion nodes
      below the `search` field. Exact semantic to be discussed.
    - Maybe a visitor pattern to ease the walking of the selection tree.
    Matthieu Vachon committed Nov 13, 2020
    Configuration menu
    Copy the full SHA
    1576055 View commit details
    Browse the repository at this point in the history