Supabase query data returning null

For every supabase I've made in the code with the server client, the data field of the return is null. I'm providing an example directly from code:
const { data: application, error } = await supabase
.from("oauth_client_applications")
.update({
client_secret_hash: newClientSecretHash,
updated_at: new Date().toISOString(),
})
.eq("client_id", client_id)
.eq("created_by", user.id)
.select("id, name, client_id, created_at, updated_at, company_vat")
.single();
const { data: application, error } = await supabase
.from("oauth_client_applications")
.update({
client_secret_hash: newClientSecretHash,
updated_at: new Date().toISOString(),
})
.eq("client_id", client_id)
.eq("created_by", user.id)
.select("id, name, client_id, created_at, updated_at, company_vat")
.single();
I get an error -> Argument of type '{ client_secret_hash: string; updated_at: string; }' is not assignable to parameter of type 'never'. Also, the application return value is null.
3 Replies
Borislav Borisov
Borislav BorisovOP2mo ago
This is my supabase server implementation:
import { Database } from "@/types/database.types";
import { createServerClient } from "@supabase/ssr";
import { cookies, headers } from "next/headers";

export async function createClient() {
const cookieStore = await cookies();
const headerStore = await headers();
const authHeader = headerStore.get("authorization");
const token = authHeader?.replace("Bearer ", "");

return createServerClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options)
);
} catch {
// The `setAll` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
global: {
headers: {
...(token && { Authorization: `Bearer ${token}` }),
},
},
},
);
}
import { Database } from "@/types/database.types";
import { createServerClient } from "@supabase/ssr";
import { cookies, headers } from "next/headers";

export async function createClient() {
const cookieStore = await cookies();
const headerStore = await headers();
const authHeader = headerStore.get("authorization");
const token = authHeader?.replace("Bearer ", "");

return createServerClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options)
);
} catch {
// The `setAll` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
global: {
headers: {
...(token && { Authorization: `Bearer ${token}` }),
},
},
},
);
}
Borislav Borisov
Borislav BorisovOP2mo ago
yes, i fixed it

Did you find this page helpful?