GraphQLParser

A Julia package to parse and validate GraphQL executable documents

Documentation for GraphQLParser.

Installation

The package can be installed with Julia's package manager, either by using the Pkg REPL mode (press ] to enter):

pkg> add GraphQLParser

or by using Pkg functions

julia> using Pkg; Pkg.add("GraphQLParser")

Use

This package can be used to check whether a document is valid

using GraphQLParser

document = """
query myQuery{
    findDog
}
"""

is_valid_executable_document(document)
# true

Or return a list of validation errors

using GraphQLParser

document = """
query myQuery{
    findDog
}

query myQuery{
    findCat
}
"""

errors = validate_executable_document(document)
errors[1]
# GQLError
#       message: There can only be one Operation named "myQuery".
#      location: Line 1 Column 1
errors[2]
# GQLError
#       message: There can only be one Operation named "myQuery".
#      location: Line 5 Column 1

Validation

validate_executable_document performs validation that does not require the schema and therefore does not fully validate the document as per the GraphQL specification. The validation performed includes: