getLaunches Query not working while following tutorial

Hi all, sorry this is so basic, I’m brand new to Apollo. I’m on part 4 of this tutorial:

and when I run the getLaunches Query during part 4 (in the Apollo sandbox), I get some errors.

I run this:

query GetLaunches {
  launches {
    id
    mission {
      name
    }
  }
}

and get this:

{
  "errors": [
    {
      "message": "Cannot query field \"id\" on type \"LaunchConnection\".",
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ],
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED",
        "exception": {
          "stacktrace": [
            "GraphQLError: Cannot query field \"id\" on type \"LaunchConnection\".",
            "    at Object.Field (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.js:48:31)",
            "    at Object.enter (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/language/visitor.js:323:29)",
            "    at Object.enter (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/utilities/TypeInfo.js:370:25)",
            "    at visit (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/language/visitor.js:243:26)",
            "    at Object.validate (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/validation/validate.js:69:24)",
            "    at validate (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/apollo-server-core/dist/requestPipeline.js:233:34)",
            "    at Object.<anonymous> (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/apollo-server-core/dist/requestPipeline.js:119:42)",
            "    at Generator.next (<anonymous>)",
            "    at fulfilled (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/apollo-server-core/dist/requestPipeline.js:5:58)",
            "    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
          ]
        }
      }
    },
    {
      "message": "Cannot query field \"mission\" on type \"LaunchConnection\".",
      "locations": [
        {
          "line": 4,
          "column": 5
        }
      ],
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED",
        "exception": {
          "stacktrace": [
            "GraphQLError: Cannot query field \"mission\" on type \"LaunchConnection\".",
            "    at Object.Field (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.js:48:31)",
            "    at Object.enter (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/language/visitor.js:323:29)",
            "    at Object.enter (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/utilities/TypeInfo.js:370:25)",
            "    at visit (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/language/visitor.js:243:26)",
            "    at Object.validate (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/graphql/validation/validate.js:69:24)",
            "    at validate (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/apollo-server-core/dist/requestPipeline.js:233:34)",
            "    at Object.<anonymous> (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/apollo-server-core/dist/requestPipeline.js:119:42)",
            "    at Generator.next (<anonymous>)",
            "    at fulfilled (/Users/Ikarie/Work/Programming/Projects/saved-places/fullstack-tutorial/start/server/node_modules/apollo-server-core/dist/requestPipeline.js:5:58)",
            "    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
          ]
        }
      }
    }
  ],
  "data": null
}

I have followed the tutorial exactly as far as I can tell. Can anyone offer a hint as to what might be the issue? I’m lost. Thanks.

I’m not familiar with this tutorial, but I can make a guess based on the error message.

It looks like you’ve implemented the pagination section of the tutorial, so your Query.launches field doesn’t directly [Launch], but instead an object type called LaunchConnection.

It should work if you change your query to:

query GetLaunches {
  launches {
    launches {
      id
      mission {
        name
      }
    }
    cursor
    hasMore
  }
}
2 Likes

Thank you, that absolutely is correct and it works now. :slight_smile:

1 Like

Solved.