FaunaDB's GraphQL endpoint always responds with 400 error

I’d like to use FaunaDB as my database with Appsmith. I’m getting an error “Execution failed with status 400 BAD_REQUEST” and it appears I haven’t set up my datasource correctly. It looks like FaunaDB only needs a header of the form Authorization: Bearer <FAUNA_SECRET>' [GraphQL endpoints | Fauna Documentation].

My request looks like:

{
"body":""
"headers":[
0:{
"Authorization":"Bearer my-key"
}
]
"httpMethod":"GET"
"url":"https://graphql.fauna.com/graphql"
}

Any suggestions?

1 Like

Hello @DanielKehoe, welcome to Appsmith community!

GraphQL APIs usually only respond to POST method requests. I believe that’s the problem that you are facing as well, since you are using the GET method to hit a GraphQL endpoint.

The FaunaDB documentation doesn’t appear to clarify this point unfortunately, so I couldn’t confirm. Please try changing the method to POST to see if it works?

Also, I think you also need a POST body containing the GraphQL query you want to execute. This query will depend on your schema and what data access or manipulation you intend for perform.

2 Likes

Thanks! Changing from GET to POST was what I needed. Now I get a database connection. I’m now getting “No usable value for query” so I’ll try sorting out the GraphQL query next.

Glad you have it working! Feel free to open a new topic if you need help with anything else. :smiley: