Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

238
Visualizações
How to restrict one type out of multiple types in graphql query?

Problem

I am implementing cursor-based pagination in graphql in AWS appsync schema. I want to restrict the type depending on query. For example, getBuildingsBySite should not allow any type other than Building. Currently, it allows all types in the Union. How can this be achieved?

    type Site {
      siteName: String
      address: String
      siteId: String!
      sitePicture: String
      siteImgUrl: String
    }

    type Floor {
      floorName: String
      accessPointsCount: Int
      unitsCount: Int
      wingName: String
      floorId: String!
    }

    type Building {
      buildingId: String!
      buildingName: String
      buildingAddress: String
      buildingImgUrl: String
      buildingImg: String
    }

    type PageInfo {
      hasNextPage: Boolean
      endCursor: Boolean
    }

    type Collection {
      edges: Edge
      pageInfo: PageInfo
    }

    type Edge {
      node: [Node]
      cursor: String
    }

    union Node = Site | Building | Floor

    type Query {
        getSites(first: Int, cursor: String): Collection
        getBuildingsBySite(first: Int, cursor: String, siteId: String!): Collection
        getFloorsByBuilding(first: Int, cursor: String, siteId: String!, buildingId: String!): Collection
    }

Query

 {
      getBuildingsBySite(first: 10, cursor: "xyz", siteId: "S1") {
        edges {
          node {
            ... on Site {
              siteName
              address
              address
            }

            ... on Building {
              buildingId
              buildingName
            }

            ... on Floor {
              floorId
              floorName
            }
          }
        }
      }
    }

If any better approach exists in AWS Appsync for pagination, please suggest it. Thanks

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda