Skip to content

Shared use of global and local context #2357

Closed

Description

@rstoyanchev

Currently the global and local context are exposed as an opaque Object which makes it a challenge for sharing across frameworks or components from different parties.

It would be great if GraphQL Java could help establish a common understanding of what the context type is as a generic container such as graphql.GraphQLContext so that different parties can agree on how to access or update it. Of course this would require awareness the context is a shared container and therefore keys need to be reasonably unique, or perhaps to use a single (unique) root key with a sub-map underneath, but this shouldn't be much of a challenge.

Given the widespread use of the existing context() and localContext(), these could be alternative methods that provide a migration path.

Activity

  1. bbakerman commented on Jun 5, 2021

    @bbakerman
    Member

    The PR I have up changes the global context object to be the more map like GraphqlContext shape and hence is better for sharing

    I am still torn on the idea of "local context" being a shared place for code. Perhaps if I had the time again it too should be a shaped container like GraphqlContext - however its also even more specific to the application layer because its opted into by DataFecthers themselves and creates a specific contract between parent fields and child fields

    I don't think it applies to Frameworks as much as say global context. Its actually more painful a change in a way as well. Well maybe its not but I am still not as convinced it will deliver the benefit that warrants the pain of change

  2. rstoyanchev commented on Jun 9, 2021

    @rstoyanchev
    Author

    Indeed I suggested the global and local context be updated so they are aligned with each other. If local context is proving more difficult, it could also be postponed until there is more motivation for it.

  3. added this to the 17.0 milestone on Jul 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions