Skip to content

Commit

Permalink
use filter on list instead of type on graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Anchel123 committed Sep 24, 2024
1 parent 3fa94c5 commit 60e0170
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/api/graph/[graph]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ export async function GET(request: NextRequest, { params }: { params: { graph: s

if (!query) throw new Error("Missing parameter 'query'")
if (create === "false") {
const type = await (await client.connection).type(graphId)
const type = (await client.list()).filter((g) => g === graphId).length === 0 ? "none" : "exists"
if (type === "none") return NextResponse.json({}, { status: 200 })
}
const graph = client.selectGraph(graphId)

const result = await graph.query(query)

if (!result) throw new Error("something went wrong")
Expand Down

0 comments on commit 60e0170

Please sign in to comment.