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

Adds Validation Rules #135

Merged

Conversation

NeedleInAJayStack
Copy link
Member

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 in fix commits before the feature commit in which the rule was added. The MR may be easier to review commit-by-commit.

Comment on lines -177 to +183
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
Copy link
Member Author

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.

@NeedleInAJayStack
Copy link
Member Author

@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.

paulofaria
paulofaria previously approved these changes Nov 27, 2023
Copy link
Member

@paulofaria paulofaria left a 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
@NeedleInAJayStack
Copy link
Member Author

NeedleInAJayStack commented Nov 28, 2023

@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

@NeedleInAJayStack NeedleInAJayStack merged commit ca8b57f into GraphQLSwift:main Nov 28, 2023
7 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants