outerbase / sdk

Typescript ORM and automated model generation direct from your database schema. Supports Outerbase features for saved queries & AI.
https://outerbase.com
MIT License
12 stars 5 forks source link

Outerbase Raw Endpoint Not Returning Errors For Cloudflare D1 #41

Open caleb-mabry opened 4 months ago

caleb-mabry commented 4 months ago

Describe the bug When trying to fix https://github.com/outerbase/sdk/issues/33 the Outerbase API does not return any errors. I'm specifically working with an API key that is attached to a Cloudflare D1 interface.

Outerbase API said {
  success: true,
  response: {
    query: 'update table egg where egg = "egg"',
    results: { schema: false, items: [], count: 0 }
  }
}

I do not have a table called egg and this query should have issues. It also seems to be confusing because there is a success:true but the status code 200 should already let us know that it was OK.

To Reproduce Steps to reproduce the behavior: Update outerbase.ts to console log the response from the query function. https://github.com/outerbase/sdk/blob/main/src/connections/outerbase.ts#L126-L128

        let json = await response.json()
        let error = null
        console.log('Outerbase API said', json)
import {OuterbaseConnection} from './src/connections/outerbase'
import {Outerbase} from './src/client'
const connection = new OuterbaseConnection({apiKey: 'YOUR-API-KEY-HERE'})
const outerbase = Outerbase(connection);

(async () => {
    const response = await outerbase.queryRaw('update table egg where egg = "egg"')
    console.log('Response from IIFE', response)
})()

Expected behavior I would expect Outerbase to let me know there is an error in my query but it silently fails.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): N/A

Smartphone (please complete the following information): N/A

Additional context Add any other context about the problem here.

erikkristoferanderson commented 4 months ago

I'm watching this one.

caleb-mabry commented 4 months ago

Should hopefully be working on this one here today.