Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
/build
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# graphql-schema-pruner
# graphql-schema-picker

A CLI for selectively pruning your GraphQL schemas.

Expand All @@ -14,19 +14,32 @@ attention to the few types I cared about.

## Example

```graphql
schema {
query: query_root
mutation: mutation_root
subscription: subscription_root
}
For a realistic example of what a Hasura GraphQL schema looks like, check out
our example [**SDL file**][sdl-file] (Schema Definition Language).

type query_root {
}
```
[sdl-file]: ./examples/hasura.sdl.graphqls

## Getting Started

### Installing

### Usage
Eventually, I may package this up in Tea and maybe even Homebrew (via
[Goreleaser][goreleaser-brew]).

For the time being, it should be installable with Go:

```shell
go install github.com/kevinmichaelchen/graphql-schema-picker@latest
```

[goreleaser-brew]: https://goreleaser.com/customization/homebrew/

### Usage

```shell
go run cmd/graphql-schema-picker/main.go \
--debug \
pick \
--sdl-file examples/hasura.sdl.graphqls \
--definitions Aircrafts
```
9 changes: 9 additions & 0 deletions cmd/graphql-schema-picker/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/kevinmichaelchen/graphql-schema-picker/internal/cli"
)

func main() {
cli.Main()
}
50 changes: 48 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ A small example to generate realistic Hasura schemas.

## Entity Relationship Diagram

![](./diagrams/erd.svg)
<img src="./diagrams/erd.svg" width="500" />

## Tasks

Expand All @@ -19,5 +19,51 @@ docker compose up --detach
Launch the Hasura Console UI

```shell
hasura console --project hasura
hasura --project hasura \
console
```

### migrate_format

Format migrations.

```shell
sleek -n \
--indent-spaces 2 \
--uppercase \
hasura/migrations/**/*.sql
```

### migrate_status

List migrations

```shell
hasura --project hasura \
migrate \
--database-name default \
status
```

### migrate_squash

Squash all migrations

```shell
hasura --project hasura \
migrate \
--database-name default \
squash --delete-source \
--from 1693763548205 \
--name init
```

### introspect

Introspect the Hasura schema — i.e., the Schema Definition Language (SDL) file.

```shell
npx graphqurl -- \
http://localhost:8080/v1/graphql \
--introspect > hasura.sdl.graphqls
```
Loading