This project runs apollo-compiler
on GraphQL schemas as a service.
There are many ways to use awc
. None of them are particularly stable.
- Install rustup
- Get a GraphQL Schema and save it to
document.graphql
- Clone this repo.
- Run the following:
$ cargo awc lint --schema ./schemas/cat.graphql --watch
Finished dev [unoptimized + debuginfo] target(s) in 0.12s
Running `target/debug/awc-cli lint --schema ./schemas/cat.graphql --watch`
๐ reading ./schemas/cat.graphql from disk
apollo-compiler validation error
ร cannot find type `Cat` in this document
โญโ[36:1]
36 โ
37 โ union Pet = Cat | Dog
ยท โโโฌโ
ยท โฐโโ not found in this scope
โฐโโโโ
apollo-compiler validation error
ร cannot find type `Dog` in this document
โญโ[36:1]
36 โ
37 โ union Pet = Cat | Dog
ยท โโฌโ
ยท โฐโโ not found in this scope
โฐโโโโ
apollo-compiler validation error
ร cannot find type `Result` in this document
โญโ[33:1]
33 โ type Subscription {
34 โ newMessage: Result
ยท โโโโฌโโ
ยท โฐโโ not found in this scope
35 โ }
โฐโโโโ
apollo-compiler validation error
ร expected identifier
โญโ[1:1]
1 โ โญโโถ query {
2 โ โ cat {
3 โ โ name
4 โ โ }
5 โ โ }
6 โ โโโถ
ยท โฐโโโโ provide a name for this definition
7 โ query getPet {
8 โ cat {
โฐโโโโ
help: GraphQL allows a short-hand form for defining query operations when only that one operation exists in the
document. There are 4 operations in this document.
apollo-compiler validation error
ร the operation `getPet` is defined multiple times in the document
โญโ[6:1]
6 โ
7 โ โญโโถ query getPet {
8 โ โ cat {
9 โ โ owner {
10 โ โ name
11 โ โ }
12 โ โ }
13 โ โ }
14 โ โโโถ
ยท โฐโโโโ previous definition of `getPet` here
15 โ โญโโถ query getPet {
16 โ โ cat {
17 โ โ treat
18 โ โ }
19 โ โ }
20 โ โโโถ
ยท โฐโโโโ `getPet` is redefined here
21 โ subscription sub {
22 โ newMessage {
โฐโโโโ
help: `getPet` must only be defined once in this document.
apollo-compiler validation error
ร Subscriptions operations can only have one root field
โญโ[20:1]
20 โ
21 โ โญโโถ subscription sub {
22 โ โ newMessage {
23 โ โ body
24 โ โ sender
25 โ โ }
26 โ โ disallowedSecondRootField
27 โ โ }
28 โ โโโถ
ยท โฐโโโโ subscription with 2 root fields
29 โ type Query {
30 โ cat: Pet
โฐโโโโ
help: There are 2 root fields: newMessage, disallowedSecondRootField. This is not allowed.
apollo-compiler validation error
ร Cannot query `disallowedSecondRootField` field
โญโ[25:1]
25 โ }
26 โ disallowedSecondRootField
ยท โโโโโโโโโโโโโโฌโโโโโโโโโโโโ
ยท โฐโโ `disallowedSecondRootField` field is not in scope
27 โ }
28 โ
โฐโโโโ
help: `disallowedSecondRootField` is not defined on `Subscription` type
โ Found 7 errors in 3 ms.
๐ Watching ./schemas/cat.graphql for changes
If you make a change to the schema on the file system, the CLI will detect the change and print the updated diagnostics to the terminal.
$ rover graph introspect https://countries.trevorblades.com | curl -X POST -sSL --data-binary @- https://awc.fly.dev | jq -r .pretty
apollo-compiler validation advice
> Custom scalars should provide a scalar specification URL via the @specifiedBy directive
,-[1:1]
1 | scalar _Any
: ^^^^^^|^^^^^
: `-- consider adding a @specifiedBy directive to this scalar definition
2 | type Country {
3 | code: ID!
`----
Visit awc.fly.dev, type GraphQL into the left panel and watch diagnostics appear on the right. Display for this is a bit buggy at the moment but it uses the same POST request to validate GraphQL.