GraphQL add script?

hi folks,

I am using the bubble api plugin to do post GraphQL call. however it returns an error, “message”: “No query string was present”. how to I attachh a the script? which data type do I need to set?

This may be helpful. It’s directly from the graphql website. Looks like it goes in the payload body

HTTP Methods, Headers, and Body#

Your GraphQL HTTP server should handle the HTTP GET and POST methods.

GET request

When receiving an HTTP GET request, the GraphQL query should be specified in the “query” query string. For example, if we wanted to execute the following GraphQL query:

{

me {

name

}

}

This request could be sent via an HTTP GET like so:

http://myapi/graphql?query={me{name}}

Query variables can be sent as a JSON-encoded string in an additional query parameter called variables. If the query contains several named operations, an operationName query parameter can be used to control which one should be executed.

POST request

A standard GraphQL POST request should use the application/jsoncontent type, and include a JSON-encoded body of the following form:

{

"query": "...",

"operationName": "...",

"variables": { "myVariable": "someValue", ... }

}

operationName and variables are optional fields. operationName is only required if multiple operations are present in the query.

In addition to the above, we recommend supporting two additional cases:

  • If the “query” query string parameter is present (as in the GET example above), it should be parsed and handled in the same way as the HTTP GET case.
  • If the “application/graphql” Content-Type header is present, treat the HTTP POST body contents as the GraphQL query string.

If you’re using express-graphql, you already get these behaviors for free.

Hi Jared, first of all thank for helping. i will check your solution. thanks again

Hi Jared,

i tried get approach, worked great. thanks a lot!

thanks a lot

Magnus

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.