menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Amazon Web Services

Unofficial AWS community

Channels
Team

GraphQL AWS AMplify @connection not bringing in connected data

October 16, 2020 at 7:55pm

GraphQL AWS AMplify @connection not bringing in connected data

October 16, 2020 at 7:55pm
I would like to have in the League tables all of the seasons and divisions as you can see with data > seasons. I have set it up as I believe would work using .
So the question is, how would I have to change my division schema so that divisions are included in the League.

League Schema

type League @model
{
id: ID!
name: String!
faId: ID!
logo: String
seasons: [Season] @connection(keyName: "bySeason", fields: ["id"])
division: [Division] @connection(keyName: "byDivision", fields: ["id"])
}

Seasons Schama

type Season @model @key(name: "bySeason", fields: ["leagueID"])
{
id: ID!
name: String!
faId: ID!
yearStart: AWSDate
yearEnd: AWSDate
leagueID: ID!
league: League! @connection(fields: ["leagueID"])
division: [Division] @connection(keyName: "byDivision", fields: ["id"])
}

Division Schema

type Division @model @key(name: "byDivision", fields: ["seasonID", "leagueID", "name"])
{
id: ID!
name: String!
faId: ID!
leagueID: ID!
seasonID: ID!
league: League! @connection(fields: ["leagueID"])
season: Season! @connection(fields: ["seasonID"])
ageInput: String!
level: Int!
}

Queries

query getLeagues {
listLeagues {
items {
seasons {
items {
id
name
}
}
division {
items {
id
name
}
}
}
}
}

Data

{
"data": {
"listLeagues": {
"items": [
{
"seasons": {
"items": []
},
"division": {
"items": []
}
},
{
"seasons": {
"items": [
{
"id": "44d2392e-59a2-4f51-9387-7ba86e09238a",
"name": "2018-19"
},
{
"id": "90bff337-f801-4203-8cac-a1150a4c8246",
"name": "2013-14"
},
{
"id": "eb62b250-9b8a-438a-b170-992fd7609420",
"name": "2016-17"
},
{
"id": "c4b1ae7f-e8ac-48bd-b6f1-84ecfb3e9bda",
"name": "2020-21"
},
{
"id": "a12794a8-7aa9-4706-8962-deea0e1fc18d",
"name": "2017-18"
},
{
"id": "aecfb321-6ba4-4f35-b305-62551ce1ec8c",
"name": "2019-20"
},
{
"id": "80e250d6-b2eb-4651-9438-1eb8d5ee6213",
"name": "2015-16"
},
{
"id": "309a26ec-b034-41a4-8d47-ce315ea34104",
"name": "2014-15"
}
]
},
"division": {
"items": []
}
}
]
}
}
}
No messages yet