mugli/learning-graphql

ValidateStringType error

yormi opened this issue · 1 comments

yormi commented

Hi there,

This is more of a question than an issue but I thought you might have encounter the same problem at some point.

I took the code of the ValidateStringType to create a custom scalar type. Well, I tried just for having an id of 24 characters. And as soon as I use it in a query as an input, I get this:

[TypeError: Cannot read property 'test' of undefined]

I didn't manage to test anything but printing the IdType object. After that, it seems like nothing is executed, neither the query resolve function neither any of the parseValue, parseLiteral, serialize functions.

Any idea of what it could be ?

yormi commented

Ok big mistake with a refactor(that explained the fact that I couldn't get any console.log and made it seems like nothing was executed) and the fact that I didn't use any regex. I would suggest to replace the if (regex !== null) by if (!!regex) to make it easier for other dummies like me that just ignore the regex param :)