@Test void testSuccessfulMutation() throws JSONException { Author author = new Author(); author.setId(2L); Book book = new Book(); book.setId(123); book.setTitle("my new book!"); book.setAuthors(Sets.newHashSet(author)); String graphQLRequest = document( mutation( selection( field( "book", arguments( argument("op", "UPSERT"), argument("data", book) ), selections( field("id"), field("title"), field("user1SecretField") ) ) ) ) ).toQuery(); String expected = document( selection( field( "book", selections( field("id", "2"), field("title", "my new book!"), field("user1SecretField", "this is a secret for user 1 only1") ) ) ) ).toResponse(); Response response = endpoint.post(uriInfo, user1, graphQLRequestToJSON(graphQLRequest)); assert200EqualBody(response, expected); graphQLRequest = document( selection( field( "book", selections( field("id"), field("title"), field( "authors", selections( field("id"), field("name") ) ) ) ) ) ).toQuery(); expected = document( selection( field( "book", selections( field("id", "1"), field("title", "My first book"), field( "authors", selections( field("id", "1"), field("name", "Ricky Carmichael") ) ) ), selections( field("id", "2"), field("title", "my new book!"), field( "authors", selections( field("id", "2"), field("name", "The Silent Author") ) ) ) ) ) ).toResponse(); response = endpoint.post(uriInfo, user1, graphQLRequestToJSON(graphQLRequest)); assert200EqualBody(response, expected); }
@POST @Consumes(MediaType.APPLICATION_JSON) public Response post( @Context UriInfo uriInfo, @Context SecurityContext securityContext, String graphQLDocument) { ElideResponse response = runner.run(uriInfo.getBaseUri().toString(), graphQLDocument, getUser.apply(securityContext)); return Response.status(response.getResponseCode()).entity(response.getBody()).build(); }
GraphQLEndpoint { @POST @Consumes(MediaType.APPLICATION_JSON) public Response post( @Context UriInfo uriInfo, @Context SecurityContext securityContext, String graphQLDocument) { ElideResponse response = runner.run(uriInfo.getBaseUri().toString(), graphQLDocument, getUser.apply(securityContext)); return Response.status(response.getResponseCode()).entity(response.getBody()).build(); } }
GraphQLEndpoint { @POST @Consumes(MediaType.APPLICATION_JSON) public Response post( @Context UriInfo uriInfo, @Context SecurityContext securityContext, String graphQLDocument) { ElideResponse response = runner.run(uriInfo.getBaseUri().toString(), graphQLDocument, getUser.apply(securityContext)); return Response.status(response.getResponseCode()).entity(response.getBody()).build(); } @Inject  GraphQLEndpoint(
            @Named("elide") Elide elide,
            @Named("elideUserExtractionFunction") DefaultOpaqueUserFunction getUser); }
GraphQLEndpoint { @POST @Consumes(MediaType.APPLICATION_JSON) public Response post( @Context UriInfo uriInfo, @Context SecurityContext securityContext, String graphQLDocument) { ElideResponse response = runner.run(uriInfo.getBaseUri().toString(), graphQLDocument, getUser.apply(securityContext)); return Response.status(response.getResponseCode()).entity(response.getBody()).build(); } @Inject  GraphQLEndpoint(
            @Named("elide") Elide elide,
            @Named("elideUserExtractionFunction") DefaultOpaqueUserFunction getUser); @POST @Consumes(MediaType.APPLICATION_JSON) Response post(
            @Context UriInfo uriInfo,
            @Context SecurityContext securityContext,
            String graphQLDocument); }
GraphQLEndpoint { @POST @Consumes(MediaType.APPLICATION_JSON) public Response post( @Context UriInfo uriInfo, @Context SecurityContext securityContext, String graphQLDocument) { ElideResponse response = runner.run(uriInfo.getBaseUri().toString(), graphQLDocument, getUser.apply(securityContext)); return Response.status(response.getResponseCode()).entity(response.getBody()).build(); } @Inject  GraphQLEndpoint(
            @Named("elide") Elide elide,
            @Named("elideUserExtractionFunction") DefaultOpaqueUserFunction getUser); @POST @Consumes(MediaType.APPLICATION_JSON) Response post(
            @Context UriInfo uriInfo,
            @Context SecurityContext securityContext,
            String graphQLDocument);  }