Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/everlastingbugstopper/awc
lib/cli/web wrappers for apollo-compiler (GraphQL)
https://github.com/everlastingbugstopper/awc
compiler graphql rust
Last synced: 27 days ago
JSON representation
lib/cli/web wrappers for apollo-compiler (GraphQL)
- Host: GitHub
- URL: https://github.com/everlastingbugstopper/awc
- Owner: EverlastingBugstopper
- License: other
- Created: 2022-07-16T06:59:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-15T03:11:06.000Z (over 1 year ago)
- Last Synced: 2024-05-01T15:44:44.940Z (6 months ago)
- Topics: compiler, graphql, rust
- Language: Rust
- Homepage: https://awc.fly.dev
- Size: 17.6 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# awc (apollo-web-compiler)
This project runs [`apollo-compiler`](https://github.com/apollographql/apollo-rs) on GraphQL schemas as a service.
## Usage
There are many ways to use `awc`. None of them are particularly stable.
### Run the CLI
1) Install [rustup](https://rustup.rs)
1) Get a [GraphQL Schema](./schemas/prod.graphql) and save it to `document.graphql`
1) Clone this repo.
1) Run the following:```console
$ 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.
### With `rover graph introspect`, `curl`, and `jq`
```console
$ 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!
`----
```### In the browser _(under development)_
Visit [awc.fly.dev](https://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.