Stream: hapi
Topic: GraphQL support in HAPI 4.0.0
Xiaocheng Luan (Aug 16 2019 at 21:09):
@James Agnew It's exciting that HAPI 4.0 comes with so many new features. We briefly checked on the GraphQL feature but wasn't able to find much HAPI-specific documentation on that. It would help if you could help clarify a few things:
(1) First of all, how would you characterize the maturity of HAPI's GraphQL support - I understand this is the first full roll out.
(2) Overall, would any of the operations be faster with GraphQL than with the standard search API, I would think not but would like to hear your view.
(3) HAPI's response to graphql does not seem to have the "wrapper" with a "data" element, is it intentional?
A couple of minor/detailed issues we noticed:
HAPI does not appear to support GET with graphql, is that the case (which isn't necessarily an issue)?
With a query like "{Patient(id:xx-123){id,name{given,family}}}", HAPI does not seem to like the dash in the id, which is a valid id character?
Thanks!
@Ye Wang @Paul Lynch
Grahame Grieve (Aug 16 2019 at 21:11):
(1) and (3) are for me, and on my list. I'll leave it to James to comment on (2)
James Agnew (Aug 16 2019 at 21:21):
Hi @Xiaocheng Luan
(1) First of all, how would you characterize the maturity of HAPI's GraphQL support
Definitely immature at this time. I very much doubt this feature has been heavily tested or brought into production by anyone yet. I am confident in the quality of the code and I certainly wouldn't call it a prototype or anything like that, but I'm also sure we'll find a few issues in the next little while as people start to use it.
(2) Overall, would any of the operations be faster with GraphQL than with the standard search API, I would think not but would like to hear your view.
The only difference I would expect is a savings due to the number of bytes going over the wire (which can be a significant savings in many cases). There are no specific database optimizations (yet) but there aren't any thing that would be slower there either.
(3) HAPI's response to graphql does not seem to have the "wrapper" with a "data" element, is it intentional?
Wow, well there's our first bug report. :) You are correct, we are missing that and it's not intentional. Will fix this.
HAPI does not appear to support GET with graphql, is that the case (which isn't necessarily an issue)?
I'm guessing you mean support for searching? That's coming very soon.
James Agnew (Aug 16 2019 at 21:22):
(oops, didn't see Grahame's reply when I wrote mine)
Grahame Grieve (Aug 16 2019 at 21:23):
on (2)... you can make a massive request with graphQL - potentially covering 1000s of resources. The request could take a long time to process - but it's still faster than making the requests individually, and including the latency as well
Grahame Grieve (Aug 16 2019 at 21:23):
@James Agnew - on 3 - I didn't update the java implementation for the tests - see
Grahame Grieve (Aug 16 2019 at 21:25):
[hapi-core]\org.hl7.fhir.r5\src\test\resources\graphql\server-tests.json
Xiaocheng Luan (Aug 16 2019 at 21:38):
Thanks for the quick and detailed response, @James Agnew
> HAPI does not appear to support GET with graphql, is that the case (which isn't necessarily an issue)? I'm guessing you mean support for searching? That's coming very soon.
I meant for a simple query like {name{family}}, POST works, but "graphql?query={name{family}}" does not :). Given the format of GraphQL I would think real code should use POST but GET may be handy for testing/examples.
Xiaocheng Luan (Aug 16 2019 at 21:39):
on (2)... you can make a massive request with graphQL - potentially covering 1000s of resources. The request could take a long time to process - but it's still faster than making the requests individually, and including the latency as well
Thanks for the insight @Grahame Grieve
James Agnew (Aug 18 2019 at 15:13):
Hi @Xiaocheng Luan - What do you mean by POST working but not GET? As far as I can see doing a get works fine.. e.g. http://hapi.fhir.org/baseR4/Patient/cf-1558990251926/$graphql?query={name{text,given,family}}
James Agnew (Aug 18 2019 at 15:14):
I do notice that we seem to be showing the wrong content type on that specific response.. but i think that's just the syntax highlighter getting it wrong.
David Hay (Aug 19 2019 at 18:31):
Interestingly, the link above works fine when I type it in a browser (or just click on the link) but get a status 500 with an empty OO when using PostMan...
Gino Canessa (Aug 19 2019 at 18:50):
Might help to trace... in PostMan it works if you set the Accept header to text/html. Fails with everything else.
James Agnew (Aug 19 2019 at 21:55):
Ah, just replicated this. I'll push up a fix in the next day or so. Thanks for the heads up!
Toni Vaa (Oct 02 2019 at 14:29):
So should HAPI GraphQL work with POST? Everything I try seems to result in:
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>Unable to parse GraphQL Expression: java.lang.NullPointerException</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
},
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "Unable to parse GraphQL Expression: java.lang.NullPointerException"
}
]
}
... However GET seems to be working...
James Agnew (Oct 02 2019 at 14:35):
Hmm... Yeah, that's almost certainly a HAPI bug. Can you file a ticket?
Toni Vaa (Oct 03 2019 at 08:11):
I created this to GitHub: https://github.com/jamesagnew/hapi-fhir/issues/1523. Will it suffice?
Hannes Ulrich (Oct 18 2019 at 12:47):
Does the new HAPI support GraphQL queries on system level without an ID? I would like to use GraphQL for quering all observations from a specific patient, e.g. query={Observation{id,subject{reference,resource(type:Patient(id:1))}}} ?
dsh (Jan 21 2020 at 05:01):
Is there any documentation on GraphQL to see how HAPI 4.0 supports it ?
James Agnew (Jan 24 2020 at 21:02):
@Daya Sharma unfortunately not much.. This is where you enable it though: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties#L58
Highly recommended to use 4.1.0 if you're using GraphQL, lots of fixes happened btween the 4.0.0 and 4.1.0 releases.
dsh (Jan 24 2020 at 22:14):
thanks @James Agnew
Eric Haas (Mar 18 2020 at 02:40):
Tried to run a graphQL query on the hapi r4 server (R4 Endpoint: http://hapi.fhir.org/baseR4) with the following query parameter
{'query': '{ObservationList(subject:example){id,valueQuantity{value,unit},effectivePeriod{start}}}'}
and got the following error:
Response Status Code = 500 {'resourceType': 'OperationOutcome', 'text': {'status': 'generated', 'div': ' Operation Outcome ERROR [] Unable to execute GraphQL Expression: Encountered a selection set on a scalar field type
note that that this query parameter:
{'query': '{ObservationList(subject:example){id,valueQuantity{value,unit},effectivePeriod}}'}
is successful despite the fact that the effectivePeriod is a complex element.
Eric Haas (Mar 18 2020 at 02:47):
(deleted)
Last updated: Apr 12 2022 at 19:14 UTC