Files
supabase/apps/docs/lib/supabase.ts
T
Charis aba0095bd7 feat(content api): add error endpoint (#35941)
* feat(content api): add error endpoint

Add an endpoint to return the details of a Supabase error, given the
error code and service.

Schema additions:

```graphql
type RootQueryType {
  "...previous root queries"

  """Get the details of an error code returned from a Supabase service"""
  error(code: String!, service: Service!): Error
}

"""An error returned by a Supabase service"""
type Error {
  """
  The unique code identifying the error. The code is stable, and can be used for string matching during error handling.
  """
  code: String!

  """The Supabase service that returns this error."""
  service: Service!

  """The HTTP status code returned with this error."""
  httpStatusCode: Int

  """
  A human-readable message describing the error. The message is not stable, and should not be used for string matching during error handling. Use the code instead.
  """
  message: String
}

enum Service {
  AUTH
  REALTIME
  STORAGE
}
```

* test(content api): add tests for top-level query `error`
2025-05-29 15:39:47 -04:00

47 lines
1.4 KiB
TypeScript

import { createClient, type SupabaseClient } from '@supabase/supabase-js'
import { type Database as DatabaseGenerated } from 'common'
type Database = {
content: DatabaseGenerated['content']
graphql_public: DatabaseGenerated['graphql_public']
public: {
Tables: DatabaseGenerated['public']['Tables']
Views: DatabaseGenerated['public']['Views']
Functions: Omit<DatabaseGenerated['public']['Functions'], 'search_content'> & {
search_content: {
Args: Omit<
DatabaseGenerated['public']['Functions']['search_content']['Args'],
'embedding'
> & { embedding: Array<number> }
Returns: Array<
Omit<
DatabaseGenerated['public']['Functions']['search_content']['Returns'][number],
'subsections' | 'metadata'
> & {
metadata: { language?: string; methodName?: string; platform?: string }
subsections: Array<{ title?: string; href?: string; content?: string }>
}
>
}
}
Enums: DatabaseGenerated['public']['Enums']
CompositeTypes: DatabaseGenerated['public']['CompositeTypes']
}
storage: DatabaseGenerated['storage']
}
let _supabase: SupabaseClient<Database>
export function supabase() {
if (!_supabase) {
_supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)
}
return _supabase
}
export type { Database as DatabaseCorrected }