Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exports ApiError interface so can be used by third-party implementations #178

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

dthyresson
Copy link
Contributor

What kind of change does this PR introduce?

When upgrading to the latest supabase-js (and hence gotrue-js) sdks for RedwoodJS, ran into the case where:

image

Now the client returns GoTrueApi's ApiError can not just an Error.

But, it didn't see that ApiError was exported to allow a change in all the auth methods from, for example:

  login(options: {
    email?: string | undefined
    password?: string | undefined
    phone?: string | undefined
    provider?: Provider
    refreshToken?: string
    redirectTo?: string
    scopes?: string
  }): Promise<{
    session: Session | null
    user: User | null
    provider?: Provider
    url?: string | null
    error: Error | null
  }>

To use error: ApiError | null

To match:

  async signIn(
    { email, phone, password, refreshToken, provider }: UserCredentials,
    options: {
      redirectTo?: string
      scopes?: string
    } = {}
  ): Promise<{
    session: Session | null
    user: User | null
    provider?: Provider
    url?: string | null
    error: ApiError | null <-----------------
    data: Session | null // Deprecated
  }> {

What is the current behavior?

ApiError is not exported as a type.

What is the new behavior?

  • import types (for api and client)
  • ApiError interface moved into types

Additional context

Since both GoTrueClient and GoTrueApi need ApiError I figured it was ok to move that into types.

but if there is a better place for it, let me know.

I didn't want to export it from GoTrueApi and import that in GoTrueClient.

For the PR that introduced APiError, see: https://github.com/supabase/gotrue-js/pull/137/files

@kiwicopple kiwicopple merged commit db188d7 into master Nov 18, 2021
@github-actions
Copy link
Contributor

🎉 This PR is included in version 1.21.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@thorwebdev thorwebdev deleted the dt-export-api-error branch May 9, 2022 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants