question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query result not delivered to component if array contains null values

See original GitHub issue

I have an issue where my query works in Graphiql in my browser, but wont work for me in my React Native app.

This is a condensed version of the query:

    team(_id: $teamId) {
      _id
      history {
        score
      }
    }

If I don’t request history it works for me in RN too. When I do request history I don’t get any data back from the server for team. The server is getting the request and sending back data from my server console logs.

And the definition of team (condensed) is:

type Team {
  _id: ID
  history: [FixtureHistory]
}

type FixtureHistory {
  lineup: [String]
  subs: [String]
  score: Int
  finalLineup: [String]
  finalSubs: [String]
  autoSubs: [AutoSub]
  players: [Player]
}

Any idea why this works fine in Graphiql but not with Apollo Client on React Native?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
helfercommented, May 5, 2017

@elie222 I found the bug and fixed it, just have to write a test for it. I’ll release it later today 🎉

1reaction
elie222commented, Apr 7, 2017

I finally found the source of the error based on your comments @jagare. Note, this is specific to Apollo, all works fine in graphiql and looks like it should work fine. Seems to be a bug with Apollo.

Apollo wasn’t happy with me sending null in the array.

This works fine:

const teamData = {
  _id: 1,
  history: [
    {},
    {lineup: ['a', 'b', 'c']},
    {lineup: ['a', 'b', 'c']},
  ]
}

This doesn’t work fine:

const teamData = {
  _id: 1,
  history: [
    null,
    {lineup: ['a', 'b', 'c']},
    {lineup: ['a', 'b', 'c']},
  ]
}

This is the schema we’re talking about btw (and in the error repo I posted above):

const FixtureHistoryType = new GraphQLObjectType({
  name: 'FixtureHistory',
  fields: {
    lineup: { type: new GraphQLList(GraphQLString) },
  },
});

const TeamType = new GraphQLObjectType({
  name: 'Team',
  fields: {
    _id: { type: GraphQLID },
    history: { type: new GraphQLList(FixtureHistoryType) },
  },
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to check if array element is null to avoid ... - Stack Overflow
The given code works for me. Notice that someArray[i] is always null since you have not initialized the second dimension of the array....
Read more >
Filter query where select component is null or ... - Retool Forum
I want to filter my query by the value of an input text component and the value of a dropdown component. I have...
Read more >
Work with arrays | BigQuery - Google Cloud
In Google Standard SQL for BigQuery, an array is an ordered list consisting of zero or more values of the same data type....
Read more >
Empty arrays and collections should be returned instead of null
Returning null instead of an actual array, collection or map forces callers of the method to explicitly test for nullity, making them more...
Read more >
where() Function - Appian 22.2
If a default value is not specified and none of the values in the input array are true, an empty list will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found