joshmadewell
07/05/2017, 2:44 AMjoshmadewell
07/05/2017, 2:44 AMphil
07/05/2017, 2:49 AMdavo
07/05/2017, 2:57 AMA one-to-many relationship is a relationship where a parent record can be linked to many children. For example, a user can be an author of many stories. In our SQL database it means the Story table will have an author column, storing an id of a User as a foreign key. The User table will not need to store any references to stories in the SQL schema.
However in the GraphQL schema, Story will have an author field of type User and User will have stories. This allows queries to follow relationships (connections) from both sides, regardless of the underlying SQL schema. The way the data is stored and represented in the database is an implementation detail.
davo
07/05/2017, 2:58 AMCar.wheels
that I may hit in my examplejoshmadewell
07/05/2017, 3:03 AMjoshmadewell
07/05/2017, 3:03 AMdavo
07/05/2017, 3:12 AM280,403 chars
so if new id adds 29 chars "id",
that’ll give around 9.6k records. If I did a player (one) to statEvent (many) relationship. Russell Westbrook would hit the size limit in 2seasons as I estimate he did 8.5k statEvents this season (e.g. Points, Assist, Steals, Blocks)auser
07/05/2017, 3:34 AMauser
07/05/2017, 4:35 AMhttp://d.pr/i/pnJUa3.png▾
auser
07/05/2017, 4:55 AMamithkr
07/05/2017, 8:47 AMamithkr
07/05/2017, 8:47 AMamithkr
07/05/2017, 8:48 AMajmakhl
07/05/2017, 11:34 AMSlackbot
07/05/2017, 3:47 PMmentallyretired
07/05/2017, 4:17 PMauser
07/05/2017, 4:38 PMauser
07/05/2017, 4:39 PMauser
07/05/2017, 4:48 PMagartha
07/05/2017, 5:20 PMpeterp
07/05/2017, 7:12 PMpeterp
07/05/2017, 7:12 PMpeterp
07/05/2017, 7:12 PMpeterp
07/05/2017, 7:12 PMjony
07/05/2017, 7:35 PMjony
07/05/2017, 7:36 PMjony
07/05/2017, 7:36 PMjony
07/05/2017, 7:36 PMmartin
07/05/2017, 7:38 PMquery
. How would one query Connections
for current user
where either user
has not blocked the connection
or vice versa? Here’s the simplified schema:
type User implements Node {
id: ID! @isUnique
blockTarget: [Blocks!]! @relation(name: "BlockTargetToUser")
blockSource: [Blocks!]! @relation(name: "BlockSourceToUser")
}
type Connections implements Node {
id: ID! @isUnique
source: User @relation(name: "ConnectionSourceToUser")
target: User @relation(name: "ConnectionTargetToUser")
}
type Blocks implements Node {
id: ID! @isUnique
source: User @relation(name: "BlockSourceToUser")
target: User @relation(name: "BlockTargetToUser")
}
Currently, the query
for finding connections for each user doesn’t consider which user blocked whom:
{
allConnectionses(filter: {
OR: [
{ source: { id: userId } },
{ target: { id: userId } }
]
}) {
id
source {
id
}
target {
id
}
}
}