title: AWS AppSync Schema - Arrays of Connections Both Directions
body: <p>My issue is that I need to have a connection between two schema models where each links to an array of the other. The scenario here is I have multiple <code>Location</code>, each <code>Location</code> has multiple <code>Staff</code>. Each <code>Staff</code> can also have multiple <code>Location</code> that they are authorized at.</p>
  <p>I don't see a way to do this in the documentation. Originally I have each <code>Location</code> with multiple <code>Staff</code>, but this limits each <code>Staff</code> to 1 <code>Location</code>. I'm toying with the idea of <code>altLocationNames</code> as an array of strings with each <code>Staff</code>, but this would require me to perform an extra query of all <code>Staff</code> or all <code>Locations</code> if the <code>altLocationNames</code> is needed.</p>
  <p>Does anybody know a clever way to do this, or even just the best way for me to get all <code>Staff</code> at <code>Location</code> as well as all <code>Locations</code> for a specific <code>Staff</code>?</p>
  <p>Schemas:</p>
  <pre><code>type Staff
    @model
    @auth(rules: [{ allow: private, provider: iam }, { allow: private, provider: userPools }])
    @key(fields: [&quot;email&quot;])
    @key(name: &quot;byId&quot;, fields: [&quot;id&quot;], queryField: &quot;listStaffsById&quot;)
    @key(name: &quot;byLocation&quot;, fields: [&quot;locationName&quot;, &quot;recordedAt&quot;], queryField: &quot;listStaffsByLocation&quot;)
    @key(name: &quot;byRole&quot;, fields: [&quot;role&quot;, &quot;recordedAt&quot;], queryField: &quot;listStaffsByRole&quot;)
    @key(name: &quot;byStatus&quot;, fields: [&quot;status&quot;, &quot;recordedAt&quot;], queryField: &quot;listStaffsByStatus&quot;) {
    email: AWSEmail!
    altEmails: [AWSEmail]
    id: ID!
    locationName: String!
    location: Location @connection(fields: [&quot;locationName&quot;])
    altLocationNames: [String]
    firstName: String
    lastName: String
    role: StaffRole
    status: StaffStatus
    recordedAt: AWSDateTime!
    createdAt: AWSDateTime!
    updatedAt: AWSDateTime!
  }
  
  type Location
    @model
    @auth(rules: [{ allow: private, provider: iam }, { allow: private, provider: userPools }])
    @key(fields: [&quot;name&quot;]) {
    name: String!
    subdomain: String
    address: String
    phone: String
    email: AWSEmail
    staff: [Staff] @connection(keyName: &quot;byLocation&quot;, fields: [&quot;name&quot;])
    createdAt: AWSDateTime!
    updatedAt: AWSDateTime!
  }
  </code></pre>