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

280
Visualizações
Graphql Apollo Client query by ID

I'm new to GraphQL and I'm trying to build a work around project for training purposes.

For this project I'm using an external GraphQL API to get some movies. I'm making my requests through Apollo-Client the newest version and display them within a small react native app and the useQuery hook from the Apollo-Client library. No particular backend for this app.

I'm currently trying to display 2 different screens :

  • The main one with a list of all the movies. Got them with this query :
const GET_MOVIES = gql `
{
allMovies {
movies {
title 
id } 
  } 
} 
`

Everything is ok so far. But I'm stuck with the next part. I'm trying to use this id i got from a movie (map through movies) as a variable for my next request which i want to use to display my next screen. The movie screen.

I got the id but i don't know how to use it as a variable and pass it to my query to then get all the movie informations i need from this particular movie.

I found something like this :

const GET_THIS_MOVIE = gql `
{
movie (id : $movieID) {
title
.... 
.... 
  } 
} 
`

But i don't know how to use the id i got as this movieID variable. Knowing this id will change depending on the movie selected.

A precise answer with some code would be really appreciated as im new to GraphQL

Thanks for your help !

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