Troubleshoot Common Errors

Common Errors and How to Solve Them

This topic covers solutions to common errors you might encounter with using StepZen.

StepZen CLI Errors

GraphQL Errors

If StepZen's CLI displays GraphQL errors, it is helpful to check for a typo in your GraphQL schema. For example:

Starting...... !

Your local schema has the following GraphQL errors:

Error: Unknown type "continentFilterInput".
Did you mean "ContinentFilterInput" or "LanguageFilterInput"?

GraphQL is case-sensitive, and here you can see that the error indicates a type should be spelled with a capital 'C' to be referenced properly.

Another GraphQL error you might run into looks like:

Your local schema has the following GraphQL errors:

Error: Cannot find file graphql/ap_spacex_land.graphql

This means StepZen cannot find the file in the path specified in index.graphql. Correcting the typo (a missing i in graphql/ap_spacex_land.graphql) in the file resolves the problem:

schema @sdl(
  files: [
    "graphql/api_spacex_land.graphql"
  ]
) {
  query: Query
}

GraphiQL Errors

HTTP Error

If you see the error below, this usually means there's an issue with your URL when you make the request:

  "errors": [
    {
      "message": "Connector: HTTP Error: Bad Request",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],

Check if the URL is formatted correctly.

Failed to Fetch

If you press play and receive the response below, this often means that your endpoint is not currently working:

{
  "message": "Failed to fetch",
  "stack": "TypeError: Failed to fetch"
}

Double check that stepzen start is running.

Cannot Query Field on Type

Sometimes querying a field can fail, resulting in an error stating Cannot query field ... on type. For example, you might get the error when using the following query on the SpaceX API:

query MyQuery {
  capsules {
    id
    limit
    landings
    original_launch
    reuse_count
  }
}

Response:

{
  "data": null,
  "errors": [
    {
      "message": "Cannot query field \"limit\" on type \"Capsule\".",
      "locations": [
        {
          "line": 4,
          "column": 5
        }
      ]
    }
  ]
}

This error occurs because limit is not defined on the capsules type inside the schema file:

  capsules(
    find: CapsulesFind
<!--     limit should be here -->
    offset: Int
    order: String
    sort: String
  ): [Capsule]
    @graphql(
      endpoint: "https://api.spacex.land/graphql/"
    )

Adding the field to the capsules type resolves the problem.

In general, an error indicating that you can't query a field on a type, means you're referring to a field that's unavailable for one reason or another. For example, a typo, or perhaps an unrefreshed page.

A Helpful Query to Add to your Schema When Things Go Wrong

This schema uses httpbin.org to return information about your request:

type debug {
  args: JSON
  data: JSON
  files: JSON
  form: JSON
  headers: JSON
  json: JSON
  method: String
  url: String
}

type Query {
  debugger(id: String!): debug
    @rest(endpoint: "https://httpbin.org/anything/$id")
}

The endpoint https://httpbin.org/anything/$id returns back what it receives, and the web page shows the results visually. For example, the response could help you verify that the URL is being formatted as expected.

id is optional. If you've got an ID you want to check on, passing it via id provides a nice way to see what gets sent to the backend from StepZen.

Cannot POST to GraphQL endpoint

When you create a development environment on your local machine using stepzen start, it returns an endpoint for your GraphQL API that looks like this: https://biggs.stepzen.net/api/hello-world/__graphql. It also creates a local proxy for your endpoint that you can use to explore the API with GraphiQL.

You can only use this endpoint for GraphiQL in the browser. For network requests, you must use the actual GraphQL endpoint that was created. Since the local proxy is only used for development of your endpoint, it makes requests using the Admin key by default. If it were a true proxy, it could create a security vulnerability. To prevent that, the proxy only accepts requests coming from the stepzen start web app running in your browser.

Errors with Duplicate Types and Fields Caused by File Folder Choices

When creating StepZen projects in your local directory structure, it's best practice to make each project (that connects to a StepZen-hosted endpoint) exist in its own subdirectory.

StepZen looks for configuration files by traversing the directory hierarchy to the root folder, so files must exist in the directory from where you run the StepZen CLI. stepzen.config.json is one example of a StepZen-created file that must not be in your root directory. Placing it there can result in errors similar to the following:

"Error: There can be only one type named "Entities".
"Error: There can be only one type named "Public_metrics".
...

This site uses cookies: By using this website, you consent to our use of cookies in accordance with our Website Terms of Use and Cookie Policy.