Skip to content

Releases: edgedb/edgedb-js

@edgedb/generate v0.0.7

21 Apr 15:15
Compare
Choose a tag to compare
  • Fix ["*"] on scoped object in select
  • Fix filter_single with exclusive links and allow AtMostOne cardinality
  • Add comment with @edgedb/generate version to generated files
  • Fix for TypeScript 4.9 union type that is too complex to represent
  • Fix bug to allow params to be used as limit in select
  • Fix enum codegen when enum value is not a valid js identifier

edgedb v1.0.2

21 Apr 15:10
Compare
Choose a tag to compare
  • Restrict SET_GLOBAL capability
  • Relax QueryArg to support json being possibly unknown

@edgedb/generate v0.0.6

21 Apr 15:08
Compare
Choose a tag to compare
  • Allow select shapes to contain polymorphic elements for its own fields
  • Filter id field from polymorphic shapes
  • Correctly generate custom scalar types using their base type
  • Reflect explicit number types in generated EdgeQL

edgedb v1.0.1

21 Apr 14:53
Compare
Choose a tag to compare
  • Improve error messages to include information about the query.

v1.0.0

14 Oct 22:58
Compare
Choose a tag to compare

This is the v1.0 release for the edgedb-js client library. It is accompanied by the introduction of a new package @edgedb/generate which contains a set of code generation tools, including the EdgeQL query builder.

Try the beta

$ npm install edgedb@beta
$ npm install -D @edgedb/generate@beta
$ yarn add edgedb@beta
$ yarn add -D @edgedb/generate@beta

Breaking changes

New generation command

To generate the query builder, you should separately install @edgedb/generate.

$ npm install -D @edgedb/generate@beta
$ yarn add -D @edgedb/generate@beta

Then generate the query builder with the following command.

$ npx @edgedb/generate edgeql-js
# Deno users
$ deno run --allow-all --unstable https://deno.land/x/edgedb/generate.ts edgeql-js

The command still accepts the same set of flags.

Cardinality inference and filter_single

When selecting a single object, use the new filter_single key. This indicates to the query builder that a given query returns a single object.

  const query = e.select(e.Movie, (m)=>({
    title: true,
-   filter: e.op(m.id, '=', e.uuid('0e874596-b9b2-4ca1-a72e-4088fbee3b34'))
+   filter_single: e.op(m.id, '=', e.uuid('0e874596-b9b2-4ca1-a72e-4088fbee3b34'))
  }));

Previously, the query builder tried to infer whether or not a query was selecting a single item by inspecting the expressed passed to filter. Ultimately this was too verbose, caused performance issues, and didn't work in all cases (e.g. composite constraints like constraint exclusive on ((.title, .release_year))).

// OLD SYNTAX
const query = e.select(e.Movie, (m)=>({
  title: true,
  filter: e.op(m.id, '=', e.uuid('0e874596-b9b2-4ca1-a72e-4088fbee3b34'))
}));

await query.run(client);
// { title: string } | null 

Simplified filter_single syntax

The filter_single key also supports a simplified syntax that eliminates the need for e.op:

  const query = e.select(e.Movie, (m)=>({
    title: true,
-   filter: e.op(m.id, '=', e.uuid('0e874596-b9b2-4ca1-a72e-4088fbee3b34'))
+   filter_single: {id, '0e874596-b9b2-4ca1-a72e-4088fbee3b34'}
  }));
  
  await query.run(client);
  // {title: string} | null

This works for composite constraints as well.

const query = e.select(e.Movie, (m)=>({
  title: true,
  filter_single: {title: "The Avengers", release_year: 2012}
}));

This simplified "object filter" syntax only works on filter_single, not plain filter!

Interfaces are now their own generator

Previously the query builder would generate a set of interfaces representing your schema. This has now been split into its own generator. Run this generator with the following command.

$ npx @edgedb/generate interfaces

This will generate dbschema/interfaces.ts by default.

- import e, {Movie} from "./dbschema/edgeql-js"
+ import e from "./dbschema/edgeql-js"
+ import {Movie} from "./dbschema/interfaces"

Full documentation

Buffer -> UInt8Array

The client library no longer decodes bytes to the Node.js-specific Buffer class. Instead, we use the runtime-agnostic Uint8Array. This is part of a larger effort to make the client library run in non-Node.js evironments like Deno and Cloudflare workers.

New features

*.edgeql code generation

As an alternative to the query builder, it's now possible to write EdgeQL in *.edgeql files. Then run the queries code generator to produce typesafe functions corresponding to each file.

Given the following query in getMovie.edgeql...

select Movie { title } filter .title = <str>$title;

...running this command...

$ npx @edgedb/generate queries

...will generate this file as getMovie.edgeql.ts (roughly):

import type {Client} from "edgedb";

export async function getMovie(
  client: Client, 
  params: {title: string}
): Promise<{title: string} | null> {
  return client.querySingle(`select Movie { title } filter .title = <str>$title;`, params)
}

Pass the --file flag to generate a single file containing "query functions" for all detected *.edgeql files. By default this file will be written to dbschema/queries.ts.

$ npx @edgedb/generate queries --file

Full documentation

createHttpClient

A "vanilla" EdgeDB client created with createClient opens a raw TLS connection to EdgeDB over which it communicates using EdgeDB's binary protocol. However, if you need to execute EdgeQL directly from the browser or from an edge environment like Cloudflare Workers, this usually isn't possible.

It's now possible to create an EdgeDB Client that communicates entirely over HTTP for use in these constrained environments. The API for executing queries is identical.

import {createHttpClient} from "edgedb"

const client = createHttpClient();

await client.querySingle(`select 3.14`);

Since HTTP is stateless, these clients do not support transactions.

v0.22.8

27 Sep 03:42
aa65cfe
Compare
Choose a tag to compare

Commits:

v0.22.7

09 Sep 23:53
125e635
Compare
Choose a tag to compare

Commits:

v0.22.6

07 Sep 21:11
Compare
Choose a tag to compare

Commits:

v0.22.5

07 Sep 17:39
1e5ad72
Compare
Choose a tag to compare

Commits:

  • 1e5ad72 Add typing to withConfig, document config methods, add portable shapes (#441)

v0.22.4

06 Sep 22:34
eb5a985
Compare
Choose a tag to compare

Commits: