@Produces(value="application/json") public class GraphqlResourceBase extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static String |
APPLICATION_GRAPHQL |
protected GraphqlCache |
graphqlCache |
| Constructor and Description |
|---|
GraphqlResourceBase() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
executeAsync(graphql.ExecutionInput input,
graphql.GraphQL graphql,
javax.ws.rs.container.AsyncResponse asyncResponse) |
protected void |
get(String query,
String operationName,
String variables,
graphql.GraphQL graphql,
javax.servlet.http.HttpServletRequest httpRequest,
javax.ws.rs.container.AsyncResponse asyncResponse,
StargateBridgeClient bridge)
Handles a GraphQL GET request.
|
protected static javax.ws.rs.WebApplicationException |
graphqlError(javax.ws.rs.core.Response.Status status,
graphql.GraphqlErrorException error) |
protected static javax.ws.rs.WebApplicationException |
graphqlError(javax.ws.rs.core.Response.Status status,
String message) |
protected boolean |
isAuthorized(String keyspaceName,
StargateBridgeClient bridge) |
protected void |
postGraphql(String query,
graphql.GraphQL graphql,
javax.servlet.http.HttpServletRequest httpRequest,
javax.ws.rs.container.AsyncResponse asyncResponse,
StargateBridgeClient bridge)
Handles a GraphQL POST request that uses the "application/graphql" content type.
|
protected void |
postJson(GraphqlJsonBody jsonBody,
String queryFromUrl,
graphql.GraphQL graphql,
javax.servlet.http.HttpServletRequest httpRequest,
javax.ws.rs.container.AsyncResponse asyncResponse,
StargateBridgeClient bridge)
Handles a GraphQL POST request that uses the
MediaType.APPLICATION_JSON content type. |
protected void |
postMultipartJson(GraphqlJsonBody jsonBody,
org.glassfish.jersey.media.multipart.FormDataMultiPart allParts,
graphql.GraphQL graphql,
javax.servlet.http.HttpServletRequest httpRequest,
javax.ws.rs.container.AsyncResponse asyncResponse,
StargateBridgeClient bridge)
Handles a GraphQL POST request that uses the
MediaType.MULTIPART_FORM_DATA content
type, allowing file arguments. |
protected static final String APPLICATION_GRAPHQL
@Inject protected GraphqlCache graphqlCache
protected void get(String query, String operationName, String variables, graphql.GraphQL graphql, javax.servlet.http.HttpServletRequest httpRequest, javax.ws.rs.container.AsyncResponse asyncResponse, StargateBridgeClient bridge)
The payload is provided via URL parameters.
protected void postJson(GraphqlJsonBody jsonBody, String queryFromUrl, graphql.GraphQL graphql, javax.servlet.http.HttpServletRequest httpRequest, javax.ws.rs.container.AsyncResponse asyncResponse, StargateBridgeClient bridge)
MediaType.APPLICATION_JSON content type.
Such a request normally comprises a JSON-encoded body, but the spec also allows the query to be passed as a URL parameter.
protected void postMultipartJson(GraphqlJsonBody jsonBody, org.glassfish.jersey.media.multipart.FormDataMultiPart allParts, graphql.GraphQL graphql, javax.servlet.http.HttpServletRequest httpRequest, javax.ws.rs.container.AsyncResponse asyncResponse, StargateBridgeClient bridge)
MediaType.MULTIPART_FORM_DATA content
type, allowing file arguments.
It follows the GraphQL multipart request specification.
Example cURL call:
curl http://host:port/path/to/graphql \
-F operations='{ "query": "query ($file: Upload!) { someQuery(file: $file) }", "variables": { "file": null } };type=application/json'
-F map='{ "filePart": ["variables.file"] }'
-FfilePart=@/path/to/file.txt
The first part MUST declare a JSON content type ("type=application/json" in the example above).
This method assumes that its argument come from properly annotated arguments in a Jersey resource; see the existing callers for an example.
jsonBody - the JSON payload containing the GraphQL "operations object" to execute (eg
{query=..., variables=...}). It's parsed from the operations
part in the request.allParts - the whole multipart request, consisting of: the operations part
(ignored since we've already parsed it above), a map part containing a map
that specifies which GraphQL variable each file corresponds to, and an arbitrary number of
file parts named after the keys of the files map.graphql - the GraphQL schema to use for execution.protected void postGraphql(String query, graphql.GraphQL graphql, javax.servlet.http.HttpServletRequest httpRequest, javax.ws.rs.container.AsyncResponse asyncResponse, StargateBridgeClient bridge)
The request body is the GraphQL query directly.
protected static void executeAsync(graphql.ExecutionInput input,
graphql.GraphQL graphql,
@Suspended
javax.ws.rs.container.AsyncResponse asyncResponse)
protected boolean isAuthorized(String keyspaceName, StargateBridgeClient bridge)
protected static javax.ws.rs.WebApplicationException graphqlError(javax.ws.rs.core.Response.Status status,
String message)
protected static javax.ws.rs.WebApplicationException graphqlError(javax.ws.rs.core.Response.Status status,
graphql.GraphqlErrorException error)
Copyright © 2022. All rights reserved.