Created
February 10, 2020 19:01
-
-
Save zth/44ef213f4817dec788667a44b7e7b26a to your computer and use it in GitHub Desktop.
Unions in Graphile?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User { | |
id: ID! | |
name: String! | |
} | |
type Group { | |
id: ID! | |
name: String! | |
school: School! | |
} | |
type School { | |
id: ID! | |
name: String! | |
organization: Organization! | |
} | |
type Organization { | |
id: ID! | |
name: String! | |
} | |
union Owner = User | Group | School | Organization | |
type BlogPost { | |
id: ID! | |
title: String | |
body: String | |
author: User! | |
owner: Owner | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is simplified and I've omitted smart comments etc that'd clean things up. Use your imagination ;) | |
*/ | |
create table user ( | |
id serial primary key, | |
name text not null | |
); | |
create table group ( | |
id serial primary key, | |
name text not null, | |
school integer not null references school(id) | |
); | |
create table school ( | |
id serial primary key, | |
name text not null, | |
organization integer not null references organization(id) | |
); | |
create table organization ( | |
id serial primary key, | |
name text not null | |
); | |
create table blog_post ( | |
id serial primary key, | |
title text, | |
body text, | |
author integer not null references user(id), | |
owning_user integer references user(id), | |
owning_group integer references group(id), | |
owning_school integer references school(id), | |
owning_organization integer references organization(id) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment