mirror of
https://github.com/supabase/supabase.git
synced 2026-07-07 01:34:22 +08:00
* 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`
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import {
|
|
GraphQLEnumType,
|
|
GraphQLInt,
|
|
GraphQLNonNull,
|
|
GraphQLObjectType,
|
|
GraphQLString,
|
|
} from 'graphql'
|
|
import { SERVICES } from './errorModel'
|
|
|
|
export const GRAPHQL_FIELD_ERROR_GLOBAL = 'error' as const
|
|
|
|
export const GraphQLEnumTypeService = new GraphQLEnumType({
|
|
name: 'Service',
|
|
values: SERVICES,
|
|
})
|
|
|
|
export const GraphQLObjectTypeError = new GraphQLObjectType({
|
|
name: 'Error',
|
|
description: 'An error returned by a Supabase service',
|
|
fields: {
|
|
code: {
|
|
type: new GraphQLNonNull(GraphQLString),
|
|
description:
|
|
'The unique code identifying the error. The code is stable, and can be used for string matching during error handling.',
|
|
},
|
|
service: {
|
|
type: new GraphQLNonNull(GraphQLEnumTypeService),
|
|
description: 'The Supabase service that returns this error.',
|
|
},
|
|
httpStatusCode: {
|
|
type: GraphQLInt,
|
|
description: 'The HTTP status code returned with this error.',
|
|
},
|
|
message: {
|
|
type: GraphQLString,
|
|
description:
|
|
'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.',
|
|
},
|
|
},
|
|
})
|