-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d61e198
commit a1e36bd
Showing
7 changed files
with
155 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,69 @@ | ||
# GraphQLParser | ||
|
||
*A Julia package to parse and validate GraphQL executable documents* | ||
|
||
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://mmiller-max.github.io/GraphQLParser.jl/dev) | ||
[![Build Status](https://github.com/mmiller-max/GraphQLParser.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/mmiller-max/GraphQLParser.jl/actions/workflows/CI.yml?query=branch%3Amain) | ||
[![Coverage](https://codecov.io/gh/mmiller-max/GraphQLParser.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/mmiller-max/GraphQLParser.jl) | ||
|
||
Parses a GraphQL query string into a nested struture of types. Follows the [2021 specification](https://spec.graphql.org/October2021). | ||
Parses a GraphQL executable document (that is, a query string) and partially validates it. Follows the [2021 specification](https://spec.graphql.org/October2021). | ||
|
||
Why only partial validation? Full validation (as per the GraphQL specification) requies knowledge of the schema, and GraphQLParser assumes no knowledge of the server and will therefore only perform some validation. | ||
|
||
For example, the validation provided by this package will fail if parsing fields, or if two variable definitions use the same name, but will not fail if a field is incorrectly named for a particularly query. | ||
For more information about what is covered, see the documentation. | ||
|
||
## 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-repl | ||
julia> using Pkg; Pkg.add("GraphQLParser") | ||
``` | ||
|
||
## Use | ||
|
||
This package can be used to check whether a document is valid | ||
|
||
```julia | ||
using GraphQLParser | ||
|
||
document = """ | ||
query myQuery{ | ||
findDog | ||
} | ||
""" | ||
|
||
is_valid_executable_document(document) | ||
# true | ||
``` | ||
|
||
Or return a list of validation errors | ||
|
||
```julia | ||
using GraphQLParser | ||
|
||
Does not perform any interaction with the server, so no input coercion or any checking, other than checking that the query string is valid. | ||
document = """ | ||
query myQuery{ | ||
findDog | ||
} | ||
Mostly just an attempt to see how easy this would be, but potentially has some uses in other GraphQL packages. | ||
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Private | ||
|
||
Package internals documentation. | ||
|
||
## Parsing | ||
|
||
Parsing is currently part of the private API as the output types are liable to change. Once this has stabilised, this will move to the public API. | ||
|
||
```@docs | ||
GraphQLParser.parse | ||
``` | ||
|
||
## Miscellaneous | ||
|
||
```@autodocs | ||
Modules = [GraphQLParser] | ||
Filter = t -> !in(t, (GraphQLParser.parse,)) | ||
Public = false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Public | ||
|
||
Documentation for GraphQLParser's public interface. | ||
|
||
```@autodocs | ||
Modules = [GraphQLParser] | ||
Public = true | ||
Private = false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a1e36bd
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.
@JuliaRegistrator register
a1e36bd
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.
Registration pull request created: JuliaRegistries/General/49908
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: