supabase / supabase

The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
https://supabase.com
Apache License 2.0
72.52k stars 6.98k forks source link

Getting an empty response from the GraphQL API over CURL, following documentation example #19826

Closed minifisk closed 9 months ago

minifisk commented 9 months ago

Bug report

Describe the bug

I'm trying to get a response from my database via the GraphQL interface. In the visual editor I run:

 {
  booksCollection {
    edges {
      node {
        id
        name
        author
      }
    }
  }
}

And I get the response:

{
  "data": {
    "booksCollection": {
      "edges": [
        {
          "node": {
            "id": "1",
            "name": "Harry Potter and the chamber of secrets",
            "author": "JK Rowling"
          }
        },
        {
          "node": {
            "id": "2",
            "name": "Grapes of wrath",
            "author": "John Steinbeck"
          }
        }
      ]
    }
  }
}

However, trying to do this via CURL (following this part of the documentation: https://supabase.github.io/pg_graphql/supabase/)

curl -X POST https://MYPROJECTID.supabase.co/graphql/v1 \
    -H 'apiKey: MYAPIKEY' \
    -H 'Content-Type: application/json' \
    --data-raw '{"query": "{ booksCollection { edges { node { id, name, author } } } }", "variables": {}}'

I get the empty response

{"data": {"booksCollection": {"edges": []}}}%

What am I doing wrong? I don't get it. I don't have any active RLS policy on my table.

GaryAustin1 commented 9 months ago

Going to close this as the OP had RLS enabled and is not providing the Authorization header. And issues open in both discussions and Discord.