@Test void testCanReadRestrictedFieldWithAppropriateAccess() throws JSONException { String graphQLRequest = document( selection( field( "book", selection( field("user1SecretField") ) ) ) ).toQuery(); String graphQLResponse = document( selection( field( "book", selection( field("user1SecretField", "this is a secret for user 1 only1") ) ) ) ).toResponse(); Response response = endpoint.post(uriInfo, user1, graphQLRequestToJSON(graphQLRequest)); assert200EqualBody(response, graphQLResponse); }
@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);  }