Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect GraphQL request body Media type and example #6614

Open
linforestzhang opened this issue Jan 13, 2025 · 0 comments
Open

Incorrect GraphQL request body Media type and example #6614

linforestzhang opened this issue Jan 13, 2025 · 0 comments

Comments

@linforestzhang
Copy link

linforestzhang commented Jan 13, 2025

Describe the bug

On the Swagger-UI of the Global Test Server above:

curl -X 'POST' \
  'https://hapi.fhir.org/baseR4/Patient/596569/$graphql' \
  -H 'accept: application/fhir+json' \
  -H 'Content-Type: application/fhir+json' \
  -d '{
  "resourceType" : "Parameters",
  "parameter" : [
    {
    "name" : "query",
    "valueString" : "{name{text,given,family}}"
  }
]}'

OR

curl -X 'POST' \
  'https://hapi.fhir.org/baseR4/Patient/596569/$graphql' \
  -H 'accept: application/fhir+json' \
  -H 'Content-Type: application/fhir+json' \
  -d '{ 
   "query": "{name{text,given,family}}"
}'

it returns Status 500 and the following response data for both the two kinds of request body structure:

{
  "resourceType": "OperationOutcome",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">...</div>"
  },
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "HAPI-0389: Failed to call access method: java.lang.NullPointerException: Cannot invoke \"String.contains(java.lang.CharSequence)\" because \"theQueryBody\" is null"
    }
  ]
}

Using Postman, it works for the Global Test Server:

curl --location 'https://hapi.fhir.org/baseR4/Patient/596569/$graphql' \
--header 'Content-Type: application/json' \
--data '{
   "query": "{name{text,given,family}}"
}'

Guessing the cause of Status 500, which stems from the Swagger-UI of the Global Test Server:

 -H 'accept: application/fhir+json' \
  -H 'Content-Type: application/fhir+json' \

It should be:

 -H 'accept: application/json' \
  -H 'Content-Type: application/json' \

Misleading example for POST request body:

{
  "resourceType": "Parameters"
}

Snapshot about the issue:
image

In addition, the GraphQL GET request needs a 'query' input box used to specify the query expression.
image
Otherwise, it would return a Status 400:

Response body

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "HAPI-1144: Unable to parse empty GraphQL expression"
    }
  ]
}

Environment (please complete the following information):

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant