https://supabase.com/ logo
Hi I am using graphql to interface with my Supabas...
# help
s
Hi I am using graphql to interface with my Supabase database. I've added RLS to my table and attached individual policies for SELECT, INSERT, UPDATE, and DELETE (attached image). I am able to SELECT without any issues, however my INSERT fails with:
Copy code
new row violates row-level security policy for table \"projects\"
I've been stuck for a while now and not sure what to do. This is my mutation query:
Copy code
mutation MyMutation {
  insertIntoprojectsCollection(objects: {assets: ["test01"], name: "test", scene: "testscene", sensors: [{name: "camera1"}], user_id: "ca3ca3b8-9146-48e3-9106-1d8e42f8f5b5"}) {
    affectedCount
  }
}
n
Hello @Sree! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
g
insert will use both insert and select policy. I don't know graphql so not sure what your query does, but based on your policies you will need to be signed in for insert.
s
I've attached both the apikey (ANON_KEY) and bearer token (user access token) as headers to the request
What's been puzzling me is how the SELECT is working without any issues but why the INSERT fails
Also, the
user_id
column on the
projects
table is a foreign key to
auth.users.id
g
Is your insert a "with check" policy
s
Yes
g
fk should not matter for RLS
If you set select policy to true does it work?
s
Actually, I think I was able to get past this issue. I think my token was expired
g
That might do it.
s
Thank You