@Test void testFailedMutationAndRead() throws IOException, JSONException { Author author = new Author(); author.setId(2L); Book book = new Book(); book.setId(1); book.setTitle("my new book!"); book.setAuthors(Sets.newHashSet(author)); String graphQLRequest = document( selection( field( "book", arguments( argument("op", "UPSERT"), argument("data", book) ), selections( field("id"), field("title") ) ) ) ).toQuery(); Response response = endpoint.post(uriInfo, user2, graphQLRequestToJSON(graphQLRequest)); assertHasErrors(response); graphQLRequest = document( selection( field( "book", selections( field("id"), field("title") ) ) ) ).toQuery(); String expected = document( selection( field( "book", selections( field("id", "1"), field("title", "My first book") ) ) ) ).toResponse(); response = endpoint.post(uriInfo, user2, 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);  }