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

Polymorphic queries -> discriminated union types #1090

Merged
merged 19 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions integration-tests/lts/dbschema/default.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ module default {
property character_name -> str;
}

abstract type Person {
abstract type LivingThing {
age: int32;
}

abstract type Person extending LivingThing {
required property name -> str {
constraint exclusive;
};
Expand All @@ -40,7 +44,9 @@ module default {

type Hero extending Person {
property secret_identity -> str;
property number_of_movies -> int64;
required property number_of_movies -> int64 {
default := 0;
};
multi link villains := .<nemesis[IS Villain];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE MIGRATION m173ddshjvgy5ampp7rzi2g7cwwdkaljvlifemr5vugnkimtbpp6ca
ONTO m1wb2dgjeppqex272zwvqnsdfzdvvppub4iwa5vaxu3xxigyjlruka
{
CREATE ABSTRACT TYPE default::LivingThing {
CREATE PROPERTY age: std::int32;
};
ALTER TYPE default::Person EXTENDING default::LivingThing LAST;
};
10 changes: 10 additions & 0 deletions integration-tests/lts/dbschema/migrations/00028-m1cigpn.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE MIGRATION m1cigpnllpzucl3lckxtsfnozf6zbyagfakqal7ejkc3sd2ocj4efa
ONTO m173ddshjvgy5ampp7rzi2g7cwwdkaljvlifemr5vugnkimtbpp6ca
{
ALTER TYPE default::Hero {
ALTER PROPERTY number_of_movies {
SET default := 0;
SET REQUIRED USING (0);
};
};
};
1 change: 1 addition & 0 deletions integration-tests/lts/interfaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface BaseObject {
}
export interface test_Person extends BaseObject {
name: string;
age?: number | null;
height?: string | null;
isAdult?: boolean | null;
}
Expand Down
1 change: 1 addition & 0 deletions integration-tests/lts/objectTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ describe("object types", () => {
assert.deepEqual(hero["*"], {
id: true,
name: true,
age: true,
height: true,
isAdult: true,
secret_identity: true,
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/lts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "echo 'Integration tests, no build output...'",
"generate": "../../packages/generate/dist/cli.js",
"test": "yarn test:ts && yarn test:non_ts",
"test:ts": "pwd && yarn generate edgeql-js && yarn generate queries --file && yarn generate interfaces && NODE_OPTIONS=\"--experimental-vm-modules\" jest --detectOpenHandles --forceExit",
"test:ts": "pwd && yarn generate edgeql-js --future && yarn generate queries --file && yarn generate interfaces && NODE_OPTIONS=\"--experimental-vm-modules\" jest --testPathIgnorePatterns='(./select-current.test.ts|esm/.*|mts/.*|cjs/.*|deno/.*)' --detectOpenHandles --forceExit",
"test:ts_current": "pwd && yarn generate edgeql-js && NODE_OPTIONS=\"--experimental-vm-modules\" jest ./select-current.test.ts --detectOpenHandles --forceExit",
"test:non_ts": "yarn test:esm && yarn test:cjs && yarn test:mts && yarn test:deno",
"test:esm": "yarn generate queries --target esm --file esm/queries && yarn generate edgeql-js --target esm --output-dir esm/edgeql-js && cd esm && node test.js",
"test:cjs": "yarn generate queries --target cjs --file cjs/queries && yarn generate edgeql-js --target cjs --output-dir cjs/edgeql-js && cd cjs && node test.js",
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/lts/paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ describe("paths", () => {
);
assert.deepEqual(
AtLeastOneHero.number_of_movies.__cardinality__,
$.Cardinality.Many,
$.Cardinality.AtLeastOne,
);
tc.assert<
tc.IsExact<
AtLeastOneHero["number_of_movies"]["__cardinality__"],
$.Cardinality.Many
$.Cardinality.AtLeastOne
>
>(true);

Expand Down
Loading