Setting a Search ID query always gives me first element

Hello, I am trying to run the following query:

query GetArticle($id: ID!){
    article(id: $id , publicationState:LIVE){
        id,
        published_at,
        description
    }
}

Where my query format in the schema is as follows:

type Query {
  article(id: ID!, publicationState: PublicationState): Article

However, any time I run this query, I always only get the Article where id is 1? I’ve tried to set the query with a hard variable too, as you can see below.

I’ve also tried not running it in Playground. In Apollo GraphQL on Android, the query I set up with any ID always returns the elements of the article where id is 1, nothing else.

What might be causing this? Thank you!

Hi :wave: Thanks for reaching out. A few sanity checks:

  • What version of Apollo Android are you using?
  • Are you using the normalized cache? If yes, did you customize the CacheKeyResolver?

Also, can you try running the query through a proxy like Charles to rule out anything wrong in the backend?

1 Like

Hello! Thank you for the quick reply.

I am running Apollo Android 2.5.9 as per the gradle.
To be quite honest, I’m quite new at this and am just trying to mostly follow the Apollo GraphQL on Android tutorial, but I don’t think I’m using any kind of cache yet? I haven’t modified anything that I know of, atleast.

I will try figuring out how to use Charles in a bit and report back

1 Like

Yup, doesn’t sound like you’re using the cache. It’s not enabled by default.

Also I just realized your playground screenshot also has the issue? The query is for id=2 but the response is with id=1. That would hint toward an issue in the backend that doesn’t honour the parameter?

1 Like

Yeah, this is an issue everywhere that I can’t seem to fix. The strangest thing is that if I just get all of the articles, it works perfectly (as you can see below):

I’d ask someone in your backend team if they have any idea what’s causing this. Since the behaviour is the same with both Playground and Apollo Android, it’s highly unlikely this is a client issue.

1 Like

Will do. I’m trying to get this open source CMS called Strapi to work, so I’ll try to ask on their github or something, thank you!

1 Like