-
Notifications
You must be signed in to change notification settings - Fork 73
Adds Validation Rules #135
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
Adds Validation Rules #135
Conversation
public init( | ||
name: String, | ||
description: String? = nil, | ||
serialize: @escaping (Any) throws -> Map | ||
) throws { | ||
try assertValid(name: name) | ||
self.name = name | ||
self.description = description | ||
self.serialize = serialize | ||
parseValue = nil | ||
parseLiteral = nil | ||
} | ||
let parseValue: (Map) throws -> Map | ||
let parseLiteral: (Value) throws -> Map | ||
|
||
public init( | ||
name: String, | ||
description: String? = nil, | ||
serialize: @escaping (Any) throws -> Map, | ||
parseValue: @escaping (Map) throws -> Map, | ||
parseLiteral: @escaping (Value) throws -> Map | ||
parseValue: ((Map) throws -> Map)? = nil, | ||
parseLiteral: ((Value) throws -> Map)? = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the combination of these two initializer changes is that the Scalar public API is preserved.
dc14896
to
55d41b8
Compare
These issues are caught by separate validation rules
55d41b8
to
33fa691
Compare
@paulofaria @d-exclaimation Hey guys, let me know if there's something I can do to make this easier to review. I realize that it's very big and I'd be willing to split it up into smaller PRs if that helps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I had already approved this! 😅
TypeInfo also matched to graphql-js
33fa691
to
a4063a1
Compare
@paulofaria Thanks! In applying it to my complex GraphQL schema, I found and fixed one small bug. Please re-approve if that looks okay! https://github.com/GraphQLSwift/GraphQL/compare/33fa691e106911893265995f1be99efd965d6e1b..a4063a10941592c45c3dd92f3f0c5f9d70043aca |
This adds 19 new validation rules from graphql-js as well as all associated tests. As bugs were exposed through this testing, relevant fixes were made. This should improve usability of GraphQL APIs built on this package, since APIs will now automatically return better error messages to clients.
Since this is such a large merge request, I've organized the commits so that each new rule is specified in a
feature
commit. Any required fixes or adjustments were made infix
commits before thefeature
commit in which the rule was added. The MR may be easier to review commit-by-commit.