Class GraphqlServiceContexts

java.lang.Object
com.linecorp.armeria.server.graphql.GraphqlServiceContexts

@UnstableApi public final class GraphqlServiceContexts extends Object
Retrieves the current ServiceRequestContext from a GraphQLContext or DataFetchingEnvironment.
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.linecorp.armeria.server.ServiceRequestContext
    get(graphql.GraphQLContext graphQLContext)
    Retrieves the current ServiceRequestContext from the specified GraphQLContext.
    static com.linecorp.armeria.server.ServiceRequestContext
    get(graphql.schema.DataFetchingEnvironment environment)
    Retrieves the current ServiceRequestContext from the specified DataFetchingEnvironment.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

      public static com.linecorp.armeria.server.ServiceRequestContext get(graphql.GraphQLContext graphQLContext)
      Retrieves the current ServiceRequestContext from the specified GraphQLContext. For example:
      
       new DataFetcher<>() {
           @Override
           public String get(DataFetchingEnvironment env) throws Exception {
               final GraphQLContext graphQLContext = env.getGraphQlContext();
               final ServiceRequestContext ctx = GraphqlServiceContexts.get(graphQLContext);
               // ...
           }
       };
       
      Throws:
      IllegalStateException - if the specified GraphQLContext doesn't contain a ServiceRequestContext.
    • get

      public static com.linecorp.armeria.server.ServiceRequestContext get(graphql.schema.DataFetchingEnvironment environment)
      Retrieves the current ServiceRequestContext from the specified DataFetchingEnvironment. For example:
      
       new DataFetcher<>() {
           @Override
           public String get(DataFetchingEnvironment env) throws Exception {
               final ServiceRequestContext ctx = GraphqlServiceContexts.get(env);
               // ...
           }
       };
       
      Throws:
      IllegalStateException - if the specified DataFetchingEnvironment doesn't contain a ServiceRequestContext.