5276 the graphql request results in an http 400 error (#5278)
* fixed issue, added test * added change logs --------- Co-authored-by: Steven Li <steven@smilecdr.com>
This commit is contained in:
parent
650fbe541c
commit
3e46f71542
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 5276
|
||||
title: "Previously, GraphQL queries will error when using base resource search parameters such as '_id' after search parameter rebuild.
|
||||
This has been fixed."
|
|
@ -237,6 +237,31 @@ public class GraphQLR4Test extends BaseResourceProviderR4Test {
|
|||
myCaptureQueriesListener.logSelectQueries();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId_Search_Patient() throws IOException {
|
||||
initTestPatients();
|
||||
|
||||
String query = "{PatientList(_id: " + myPatientId0.getIdPart() + ") {id}}";
|
||||
HttpGet httpGet = new HttpGet(myServerBase + "/$graphql?query=" + UrlUtil.escapeUrlParam(query));
|
||||
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(httpGet)) {
|
||||
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(resp);
|
||||
|
||||
@Language("json")
|
||||
String expected = """
|
||||
{
|
||||
"PatientList":[{
|
||||
"id":" """ + myPatientId0 + """
|
||||
/_history/1"
|
||||
}]
|
||||
}""";
|
||||
assertEquals(TestUtil.stripWhitespace(DATA_PREFIX +
|
||||
expected +
|
||||
DATA_SUFFIX), TestUtil.stripWhitespace(resp));
|
||||
}
|
||||
}
|
||||
|
||||
private void initTestPatients() {
|
||||
Patient p = new Patient();
|
||||
p.addName()
|
||||
|
|
|
@ -131,4 +131,21 @@ public interface ISearchParamRegistry {
|
|||
}
|
||||
return availableSearchParamDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the search params for a resource. First, check the resource itself, then check the top-level `Resource` resource and combine the two.
|
||||
*
|
||||
* @param theResourceType the resource type.
|
||||
*
|
||||
* @return the {@link ResourceSearchParams} that has all the search params.
|
||||
*/
|
||||
default ResourceSearchParams getRuntimeSearchParams(String theResourceType) {
|
||||
ResourceSearchParams availableSearchParams =
|
||||
getActiveSearchParams(theResourceType).makeCopy();
|
||||
ResourceSearchParams resourceSearchParams = getActiveSearchParams("Resource");
|
||||
resourceSearchParams
|
||||
.getSearchParamNames()
|
||||
.forEach(param -> availableSearchParams.addSearchParamIfAbsent(param, resourceSearchParams.get(param)));
|
||||
return availableSearchParams;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class DaoRegistryGraphQLStorageServices implements IGraphQLStorageService
|
|||
RuntimeResourceDefinition typeDef = fhirContext.getResourceDefinition(theType);
|
||||
|
||||
SearchParameterMap params = new SearchParameterMap();
|
||||
ResourceSearchParams searchParams = mySearchParamRegistry.getActiveSearchParams(typeDef.getName());
|
||||
ResourceSearchParams searchParams = mySearchParamRegistry.getRuntimeSearchParams(typeDef.getName());
|
||||
|
||||
for (Argument nextArgument : resourceSearchParam) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue