Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser shallowing up errors #14

Open
du5rte opened this issue May 18, 2017 · 2 comments
Open

parser shallowing up errors #14

du5rte opened this issue May 18, 2017 · 2 comments

Comments

@du5rte
Copy link

du5rte commented May 18, 2017

Hi it seems error are being shallow somewhere when the value of GraphQLEmail doesn't conform, when using a string instead of a email I don't get a specific error message.

mutation {
  viewer { 
    # wrong email type ( missing @ )
    createUser(email: "asdasail.com" password: "123") {
      success
    }
  }
}

just this

{
  "message": "unexpected error"
}

And I get the error on my node terminal

2017-05-18T14:17:55.881Z : ERROR : REQ : POST /graphql? : 500 : Query error: Not a valid Email address : (58eba048307ce2316004bb2c) : [Object]: {
  "stack": "GraphQLError\n    at parser (...\\node_modules\\graphql-custom-types\\lib\\factory.js:37:17)\n    at parseLiteral (...\\node_modules\\graphql-custom-types\\lib\\types.js:38:16)\n    at GraphQLCustomScalarType.parseLiteral (...\\node_modules\\graphql\\type\\definition.js:215:21)\n    at isValidLiteralValue (...\\node_modules\\graphql\\utilities\\isValidLiteralValue.js:113:26)\n    at isValidLiteralValue (...\\node_modules\\graphql\\utilities\\isValidLiteralValue.js:51:12)\n    at Object.Argument (...\\node_modules\\graphql\\validation\\rules\\ArgumentsOfCorrectType.js:40:67)\n    at Object.enter (...\\node_modules\\graphql\\language\\visitor.js:297:29)\n    at Object.enter (...\\node_modules\\graphql\\language\\visitor.js:339:25)\n    at visit (...\\node_modules\\graphql\\language\\visitor.js:229:26)\n    at visitUsingRules (...\\node_modules\\graphql\\validation\\validate.js:77:22)\n    at Object.validate (...\\node_modules\\graphql\\validation\\validate.js:62:10)\n    at doRunQuery (...\\node_modules\\graphql-server-core\\src\\runQuery.ts:115:34)\n    at ...\\node_modules\\graphql-server-core\\src\\runQuery.ts:59:39\n    at process._tickDomainCallback (internal/process/next_tick.js:135:7)",
  "message": "Query error: Not a valid Email address",
  "locations": [
    {
      "line": 3,
      "column": 23
    }
  ],
  "nodes": [
    {
      "kind": "StringValue",
      "value": "asdasail.com",
      "loc": {
        "start": 44,
        "end": 58
      }
    }
  ],
  "source": {
    "body": "mutation {\n  viewer {\n    createUser(email: \"asdasail.com\" password: \"123\") {\n      success\n    }\n  }\n}",
    "name": "GraphQL"
  },
  "positions": [
    44
  ]
}

  GraphQLError
      at parser (...\node_modules\graphql-custom-types\lib\factory.js:37:17)
      at parseLiteral (...\node_modules\graphql-custom-types\lib\types.js:38:16)
      at GraphQLCustomScalarType.parseLiteral (...\node_modules\graphql\type\definition.js:215:21)
      at isValidLiteralValue (...\node_modules\graphql\utilities\isValidLiteralValue.js:113:26)
      at isValidLiteralValue (...\node_modules\graphql\utilities\isValidLiteralValue.js:51:12)
      at Object.Argument (...\node_modules\graphql\validation\rules\ArgumentsOfCorrectType.js:40:67)
      at Object.enter (...\node_modules\graphql\language\visitor.js:297:29)
      at Object.enter (...\node_modules\graphql\language\visitor.js:339:25)
      at visit (...\node_modules\graphql\language\visitor.js:229:26)
      at visitUsingRules (...\node_modules\graphql\validation\validate.js:77:22)
      at Object.validate (...\node_modules\graphql\validation\validate.js:62:10)
      at doRunQuery (...\node_modules\graphql-server-core\src\runQuery.ts:115:34)
      at ...\node_modules\graphql-server-core\src\runQuery.ts:59:39
      at process._tickDomainCallback (internal/process/next_tick.js:135:7)

When normally you use wrong types GraphQL gives you more information. Examples using Number instead of String in password argument.

mutation {
  viewer {
    createUser(email: "[email protected]" password: 123) {
      success
    }
  }
}
{
  "errors": [
    {
      "message": "Argument \"password\" has invalid value 123.\nExpected type \"String\", found 123.",
      "locations": [
        {
          "line": 3,
          "column": 51
        }
      ]
    }
  ]
}

All I use is a simple catch error throw

resolve() {
  try {
   //  ... code
  } catch(error) {
    throw error
  }
}
@stekycz
Copy link

stekycz commented Nov 15, 2017

This is solved in my fork including other internal improvements. I want to maintain it for public use including new types and better validations.

@stylesuxx
Copy link
Owner

OK, I would have been happy to accept a PR,...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants