Issue in "Exploring our first query"

While trying to run the first tracksForHome query, I get the below error:

  "errors": [
      "message": "Cannot return null for non-nullable field Query.tracksForHome.",
      "locations": [
          "line": 2,
          "column": 3
      "path": [
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: Cannot return null for non-nullable field Query.tracksForHome.",
            "    at completeValue (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/graphql/execution/execute.js:559:13)",
            "    at resolveField (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/graphql/execution/execute.js:472:19)",
            "    at executeFields (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/graphql/execution/execute.js:292:18)",
            "    at executeOperation (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/graphql/execution/execute.js:236:122)",
            "    at executeImpl (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/graphql/execution/execute.js:116:14)",
            "    at Object.execute (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/graphql/execution/execute.js:60:35)",
            "    at execute (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/apollo-server-core/dist/requestPipeline.js:199:36)",
            "    at Object.processGraphQLRequest (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/apollo-server-core/dist/requestPipeline.js:139:34)",
            "    at processTicksAndRejections (internal/process/task_queues.js:95:5)",
            "    at async processHTTPRequest (/home/hemesh/Projects/odyssey-lift-off-part1/server/node_modules/apollo-server-core/dist/runHttpQuery.js:179:30)"
  "data": null

I suspect this is because we are returning a null array using the […new Array(6)] to the tracksForHome query which expects a non nullable list of non nullable Tracks object - [Tracks!]!

I’m surprised it even worked in the video. Now I cannot proceed in the course… please help.

Hi @hemesh-t !

Thanks for the info! The […new Array(6)] will indeed return an array of undefined objects, by itself. However in this same mocks object, we also included a property for Track that has more mock data. This data will override the undefined objects in the array.

That said, can you paste the contents of your index.js file as well as your schema? Or link to your Github repo if you have it. I’ll see if I can spot what’s happening!

Thanks @MichelleMabuyo for the quick response.

Below are the contents of my schema.js and index.js files:


const {gql} = require('apollo-server');

const typeDefs = gql`

type Query {
    "Get tracks array for homepage grid"
    tracksForHome: [Track!]!

"A track is a group of Modules that teaches about a specific topic"
type Track {
    id: ID!
    title: String!
    author: Author!
    thumbnail: String
    length: Int
    modulesCount: Int

"Author of a complete Track or a Module"
type Author {
    id: ID!
    name: String!
    photo: String
module.exports = typeDefs;


const {ApolloServer} = require ('apollo-server');
const typeDefs = require('./schema');

const mocks = {
    Query: () => ({
      tracksForHome: () => [ Array(6)]
    Track: () => ({
      id: () => 'track_01',
      title: () => 'Astro Kitty, Space Explorer',
      author: () => {
        return {
            id: 'author_01',
            name: 'Grumpy Cat',
      thumbnail: () =>
      length: () => 1210,
      modulesCount: () => 6

const server = new ApolloServer({
    mock: mocks

server.listen().then(() => {
      🚀  Server is running!
      🔉  Listening on port 4000
      📭  Query at

Thank you! So it looks like you have a typo in the ApolloServer constructor. It should be:

const server = new ApolloServer({
    mocks: mocks

Note the mocks with an s! You can also shorten it to simply mocks since the key has the same name as the value.

Give it a try and let me know how it goes!

Ah! Bummer! Thanks @MichelleMabuyo for replying so quick and helping me solve this issue!

It worked now.

Really appreciate it!

Typos are sneaky. Happy to hear it’s working now! :partying_face:

Lift-off III goes into a little more detail about the resolver chain we’re using here (ie why did the Track data “override” the tracksForHome data?) but feel free to let us know again if you have any other questions!

1 Like

This typo is present in the tutorial videos.

Hi @calabiyauman!

I double-checked the lesson and the 2:57 timestamp on the video shows it as mocks with an s. Can you clarify where you’re seeing the typo?