Class GraphqlServiceContexts
java.lang.Object
com.linecorp.armeria.server.graphql.GraphqlServiceContexts
Retrieves the current
ServiceRequestContext from a GraphQLContext or
DataFetchingEnvironment.-
Method Summary
Modifier and TypeMethodDescriptionstatic com.linecorp.armeria.server.ServiceRequestContextget(graphql.GraphQLContext graphQLContext) Retrieves the currentServiceRequestContextfrom the specifiedGraphQLContext.static com.linecorp.armeria.server.ServiceRequestContextget(graphql.schema.DataFetchingEnvironment environment) Retrieves the currentServiceRequestContextfrom the specifiedDataFetchingEnvironment.
-
Method Details
-
get
public static com.linecorp.armeria.server.ServiceRequestContext get(graphql.GraphQLContext graphQLContext) Retrieves the currentServiceRequestContextfrom the specifiedGraphQLContext. 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 specifiedGraphQLContextdoesn't contain aServiceRequestContext.
-
get
public static com.linecorp.armeria.server.ServiceRequestContext get(graphql.schema.DataFetchingEnvironment environment) Retrieves the currentServiceRequestContextfrom the specifiedDataFetchingEnvironment. For example:new DataFetcher<>() { @Override public String get(DataFetchingEnvironment env) throws Exception { final ServiceRequestContext ctx = GraphqlServiceContexts.get(env); // ... } };- Throws:
IllegalStateException- if the specifiedDataFetchingEnvironmentdoesn't contain aServiceRequestContext.
-