`fetch` graphql api example?

I am working on a wrapper for the graphql endpoint for Deno, but all of my requests are receiving Bad Request 400 errors when using the fetch api. Here is how my fetch requests are setup:

fetch("https://graphql.fauna.com/graphql" {
  headers: {
    accept: "application/json",
    authorization: "Bearer <key>",
    method: "POST",
    "Content-Type": "application/json"
  body: 'query { \n allProducts { \n data { \n name \n quantity \n description \n } \n } \n }'

Is there anyone who can tell me what I am doing wrong, because I am clueless…

Edit: I am using the demo data preset that FaunaDB allowed me to use at the setup options page.

I am officially an idiot. The fetch method option goes in the root of the options object, not within the headers object :man_facepalming: :man_facepalming: :man_facepalming:

Hi, off topic.
Are you wrapping graphql into separate rest api endpoint?
May I know why to do that and what the benefit of it.

If doing so, doesn’t mean that you give up the simplicity of graphql and make it more complicated?

If we need to add backend in between, which way is the best.
Open rest endpoint from backend and let backend connect faunadb using graphql ?
Or implement graphql in backend and make it consistent?