Skip to content

JSONObject: Unexpected error if literal is not an object #2285

@tjenkinson

Description

@tjenkinson

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

Make sure to fork this template and run yarn generate in the terminal.

Please make sure the GraphQL Scalars package version under package.json matches yours.


Describe the bug
Currently if you provide a param that should be a JSONObject but it is not an object the error is not handled nicely.

To Reproduce
Add a JSONObject param and do something like

query {
   accounts(myArg: "Not an object") {
   }
}

Expected behavior
A nice error message

Actual behaviour

Expected value of type \"JSONObject\", found \"Not an object\"; Cannot read properties of undefined (reading 'forEach')

Environment:

  • OS: Mac
  • GraphQL Scalars Version: 1.22.5
  • NodeJS: Cloudflare worker

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions