Fix versioned API incompatibility with GraphQL

This commit is contained in:
James Agnew 2019-08-20 08:35:27 -04:00
parent df5eb48c24
commit ce879b3863
4 changed files with 25 additions and 2 deletions

View File

@ -69,6 +69,11 @@ public class VersionedApiConverterInterceptor extends InterceptorAdapter {
@Override
public boolean outgoingResponse(RequestDetails theRequestDetails, ResponseDetails theResponseDetails, HttpServletRequest theServletRequest, HttpServletResponse theServletResponse) throws AuthenticationException {
IBaseResource responseResource = theResponseDetails.getResponseResource();
if (responseResource == null) {
return true;
}
String[] formatParams = theRequestDetails.getParameters().get(Constants.PARAM_FORMAT);
String accept = null;
if (formatParams != null && formatParams.length > 0) {
@ -92,7 +97,6 @@ public class VersionedApiConverterInterceptor extends InterceptorAdapter {
wantVersion = FhirVersionEnum.forVersionString(wantVersionString);
}
IBaseResource responseResource = theResponseDetails.getResponseResource();
FhirVersionEnum haveVersion = responseResource.getStructureFhirVersionEnum();
IBaseResource converted = null;

View File

@ -70,7 +70,7 @@ public abstract class BaseSearchParamRegistry<SP extends IBaseResource> implemen
private volatile Map<String, Map<String, RuntimeSearchParam>> myActiveSearchParams;
private volatile long myLastRefresh;
@Autowired
@autowired
private IInterceptorBroadcaster myInterceptorBroadcaster;
@Override

View File

@ -403,6 +403,21 @@ public class ResponseHighlightingInterceptorTest {
}
@Test
public void testHighlightGraphQLResponseNonHighlighted() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/A/$graphql?query=" + UrlUtil.escapeUrlParam("{name}"));
httpGet.addHeader("Accept", "application/jon");
CloseableHttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8);
status.close();
ourLog.info("Resp: {}", responseContent);
assertEquals(200, status.getStatusLine().getStatusCode());
assertThat(responseContent, stringContainsInOrder("{\"foo\":\"bar\"}"));
}
@Test
public void testHighlightException() throws Exception {
ResponseHighlighterInterceptor ic = ourInterceptor;

View File

@ -44,6 +44,10 @@
SubscriptionDstu2Config incorrectly pointed to a DSTU3 configuration file. This
has been corrected.
</action>
<action type="fix">
When using the VersionedApiConverterInterceptor, GraphQL responses failed with an HTTP
500 error.
</action>
</release>
<release version="4.0.0" date="2019-08-14" description="Igloo">
<action type="add">