kevlust
05/02/2023, 11:00 PMgilbert
05/02/2023, 11:40 PM/graphql/v1
using the same Authorization: Bearer x
token returns the error in title.
Here is what the request looks like in fetch form:
fetch("https://xxx.supabase.co/graphql/v1", {
"body": "{\"query\":\"\\nquery GetChatMessages($chat_id: BigIntFilter!) {xxx}\",\"variables\":{\"$chat_id\":1},\"operationName\":\"GetChatMessages\"}",
"cache": "default",
"credentials": "include",
"headers": {
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.9",
"Authorization": "Bearer xxx_token_xxx",
"Content-Type": "application/json",
"Priority": "u=3, i",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15"
},
"method": "POST",
"mode": "cors",
"redirect": "follow",
"referrer": "xxx",
"referrerPolicy": "strict-origin-when-cross-origin"
})
Should the Bearer token be different from the token being used to request /rest/v1
? Or is there some special config I need to toggle on Supabase's backend to enable graphql? (don't remember doing this locally). Thanks muchformigueiro
05/02/2023, 11:51 PMjs
import { createClient } from '@supabase/supabase-js'
const plugin = (context) => {
const config = useRuntimeConfig()
const supabase = createClient(
config.public.supabaseUrl,
config.public.supabaseKey,
{
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: false,
}
)
context.$supabase = supabase
}
export default defineNuxtPlugin(plugin)
inside my login page i have this method to log in js
const signInWithTwitch = async () => {
const { error, data } = await $supabase.auth.signInWithOAuth({
provider: 'twitch',
options: {
redirectTo: `${config.public.baseUrl}/dashboard`,
scopes: 'moderator:manage:chat_messages moderation:read channel:moderate chat:edit chat:read whispers:read user:edit:broadcast user:read:follows channel:edit:commercial channel:manage:broadcast user:read:broadcast user:read:email channel:manage:moderators'
}
})
}
but its not redirecting user to my page
https://cdn.discordapp.com/attachments/1103106525079285761/1103106525502914590/image.png▾
ven
05/02/2023, 11:56 PMhttps://cdn.discordapp.com/attachments/1103107844913516634/1103107845592989776/import_maps.png▾
mqp
05/03/2023, 1:51 AMmax_concurrent_users
) on the pro plan? https://github.com/supabase/realtime/blob/main/lib/realtime/api/tenant.ex#L19
The website documentation (https://supabase.com/docs/guides/realtime/rate-limits) only says this:
> Enterprise plan limits start at:
> 500 concurrent clients
> 1,000 messages per second
> 500 concurrent Channels
which is not very clear and it's also not clear what this might imply about the pro plan.KiwiHour
05/03/2023, 2:30 AMts
const { data: addUserData, error: addUserError } = await supabase.from("users").insert({ email, forename })
They confirm their email, and then once I try to access user information using the code below, it returns the data as an empty array
ts
private async getUserDetails() {
let { data, error } = await supabase.from("users").select("*").eq("email", this._email).single();
if (error) throw error
return data;
}
On the supabase website, the GUI shows the new information just fine. And once I restart my sveltekit server and try again, it can access the table just fine
Any reason why this is happening? And how I can get it to retrieve data from tables without restarting the server?Warlando
05/03/2023, 3:18 AM<Auth
supabaseClient={supabase}
view={VIEWS.UPDATE_PASSWORD}
redirectTo="http://localhost:3000/"
showLinks={false}
providers={[]}
appearance={{ theme: ThemeSupa }}
/>
After updating the password Auth UI presents the sign in view which is an expected behaviour when looking at the code repo: https://github.com/supabase/auth-ui/blob/a2aa401394506df196446691fd346eaebfe476ba/packages/react/src/components/Auth/Auth.tsx#L102
But then, after signing in, the redirectTo
does not get triggered. Anyone knows why?IvLa
05/03/2023, 4:36 AMno-1ne
05/03/2023, 5:12 AMhttps://cdn.discordapp.com/attachments/1103187358746153021/1103188860441214976/image.png▾
cohlar
05/03/2023, 5:53 AMsupabase link
, I get the following error message:
Error: Authorization failed for the access token and project ref pair: {"message":"Forbidden resource"}
I have generated a new access token, I have tried it both locally and on github actions, on two separate projects (staging and production) - nothing works.
Last time I successfully ran supabase link
on both projects was 12 hours ago for a deployment.
Any idea where that could be from?
Thanks!MusashiGarami
05/03/2023, 6:50 AMnicetomytyuk
05/03/2023, 9:00 AMhttps://cdn.discordapp.com/attachments/1103244743850336296/1103245026403811358/image.png▾
albert-lum
05/03/2023, 9:39 AMhttps://cdn.discordapp.com/attachments/1103254388044222485/1103254388614635570/image.png▾
louis030195
05/03/2023, 9:41 AMpgvector
extension which is used within a function:
sql
-- We are creating a function to run a similarity search on the documents table
create or replace function match_documents (
query_embedding vector(1536),
similarity_threshold float,
match_count int,
query_dataset_ids text[],
query_user_id text default null
)
returns table (
id text,
data text,
score float,
hash text,
embedding vector(1536),
metadata json
)
language plpgsql
as $$
begin
return query
select
documents.id,
documents.data,
(1 - (documents.embedding <=> query_embedding)) as similarity,
documents.hash,
documents.embedding,
documents.metadata
from documents
where 1 - (documents.embedding <=> query_embedding) > similarity_threshold
and documents.dataset_id = any(query_dataset_ids)
and (query_user_id is null or query_user_id = documents.user_id)
order by documents.embedding <=> query_embedding
limit match_count;
end;
$$;
I want my end users to be able to filter by metadata
Filtering metadata would supports the following operators:
$eq - equal to (string, int, float)
$ne - not equal to (string, int, float)
$gt - greater than (int, float)
$gte - greater than or equal to (int, float)
$lt - less than (int, float)
$lte - less than or equal to (int, float)
Using the $eq operator is equivalent to using the where filter.
{
"metadata_field": "search_string"
}
# is equivalent to
{
"metadata_field": {
"$eq": "search_string"
}
}
Do you have any idea how I could change my query to achieve this? Or can I run SQL directly using the sdk?Hugos
05/03/2023, 11:33 AMHugos
05/03/2023, 12:54 PMsql
CREATE OR REPLACE FUNCTION create_order(checkout_session jsonb)
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
order_id uuid;
cart_item json;
BEGIN
SELECT uuid_generate_v4() INTO order_id;
INSERT INTO orders (id, postal_code, address, city, status, customer_email)
VALUES (
order_id,
checkout_session->'shipping_details'->'address'->>'postal_code',
checkout_session->'shipping_details'->'address'->>'line1',
checkout_session->'shipping_details'->'address'->>'city',
'ORDERED',
checkout_session->>'customer_email'
);
FOREACH cart_item IN ARRAY (checkout_session->'metadata'->'cartItemsSimplified')
LOOP
DECLARE
product_id uuid := cart_item->>'product_id';
quantity int := (cart_item->>'quantity')::int;
product_row products%ROWTYPE;
BEGIN
SELECT * INTO product_row FROM products WHERE id = product_id LIMIT 1;
IF FOUND THEN
UPDATE products SET stock = product_row.stock - quantity WHERE id = product_id;
INSERT INTO order_products (order_id, product_id, quantity)
VALUES (order_id, product_id, quantity);
ELSE
RAISE EXCEPTION 'Product not found: %', product_id;
END IF;
END;
END LOOP;
END;
$$;
how im calling the function:
js
const { data, error } = await supabase_service_role.rpc('create_order', { checkout_session: JSON.stringify(checkoutSession) });
I get the error:
txt
{
code: '23502',
details: 'Failing row contains (2dd0ec8e-9351-4090-810c-054ec8fae6f6, ORDERED, null, null, null, null, 2023-05-03 12:35:07.852398+00).',
hint: null,
message: 'null value in column "city" of relation "orders" violates not-null constraint'
}
irock
05/03/2023, 1:05 PMhttps://cdn.discordapp.com/attachments/1103306268292169768/1103306268409602188/image.png▾
imabot
05/03/2023, 1:38 PMBoogersLLC
05/03/2023, 2:59 PMenv
). These keys are provided locally in .env
and on vercel. I have been using these keys like this for almost a year, I don't think the keys are missing or something like that.
javascript
const supabaseAdmin = createClient(
PUBLIC_SUPABASE_URL,
env['SUPABASE_SERVICE_ROLE'] ?? '',
)
// ...
// In my POST
const emails = await supabaseAdmin.rpc('get_user_emails', { input_id: notebook_id });
The response when calling my rpc function (which selects from auth.users
)
javascript
{
error: {
code: '42501',
details: null,
hint: null,
message: 'permission denied for table users'
},
data: null,
count: null,
status: 403,
statusText: 'Forbidden'
}
j3llybeans
05/03/2023, 3:21 PMJoshTheNerd
05/03/2023, 3:35 PMsupabase.storage
is working.
https://cdn.discordapp.com/attachments/1103344087702188032/1103344200545734707/image.png▾
bicxter
05/03/2023, 3:46 PMpsql -h host -p 5432 -d postgres -U postgres
and it says this
psql: error: connection to server at "host" (thing), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
ven
05/03/2023, 3:57 PMsupabase db diff > migrations/schema_test.sql
and tried supabase db push
i get Skipping migration schema_test.sql... (file name must match pattern "<timestamp>_name.sql")
how do i generate migration with a timestamp? or am i doing this wrong?Jon
05/03/2023, 3:58 PMHexi
05/03/2023, 5:17 PMhttps://cdn.discordapp.com/attachments/1103369757190799471/1103369758356799540/png.png▾
https://cdn.discordapp.com/attachments/1103369757190799471/1103369758671388823/Schermafbeelding_2023-05-03_191720.png▾
KiwiHour
05/03/2023, 5:44 PMawait supabase.auth.getUser(???)
after the user clicks on the confirm email link.
Unless there is a better way to do this?ven
05/03/2023, 6:43 PM// Create a Supabase client with the Auth context of the logged in user.
const supabaseClient = createClient(
// Supabase API URL - env var exported by default.
Deno.env.get('SUPABASE_URL') ?? '',
// Supabase API ANON KEY - env var exported by default.
Deno.env.get('SUPABASE_ANON_KEY') ?? '',
// Create client with Auth context of the user that called the function.
// This way your row-level-security (RLS) policies are applied.
{ global: { headers: { Authorization: req.headers.get('Authorization')! } } }
)
what if there are certain tables, for example "contact_us" table, that don't need an authenticated user? how would i make that function?adam21xc
05/03/2023, 7:13 PMtonyroma
05/03/2023, 7:42 PM