Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mununki/gqlmerge
A tool to merge & stitch the modularized GraphQL schema files into one schema
https://github.com/mununki/gqlmerge
go golang graphql merge stitch
Last synced: about 2 months ago
JSON representation
A tool to merge & stitch the modularized GraphQL schema files into one schema
- Host: GitHub
- URL: https://github.com/mununki/gqlmerge
- Owner: mununki
- License: mit
- Created: 2019-05-16T06:11:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-02T08:51:46.000Z (9 months ago)
- Last Synced: 2024-06-21T18:08:33.465Z (6 months ago)
- Topics: go, golang, graphql, merge, stitch
- Language: Go
- Homepage:
- Size: 193 KB
- Stars: 54
- Watchers: 2
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gqlmerge
A tool to merge and stitch modularized GraphQL files into one schema file
## Demo
![Demo](/demo/gqlmerge_demo.gif)
## Stack
- Built in Go
- No 3rd party dependency## Features
- Fast, blasing fast
- Find `*.graphql` and `*.gql` files in recursive way
- Merge and stitch schema from several directories
- CLI to use in shell or script## How to use
### Install to use in CLI
Homebrew
```shell
$ brew install mununki/tools/gqlmerge
```Using `go get`
```shell
$ go get -u github.com/mununki/gqlmerge
```Building with source code
```shell
$ git clone https://github.com/mununki/gqlmerge$ cd gqlmerge
$ go install
```### Use as a go module
Import gqlmerge module
```go
import gql "github.com/mununki/gqlmerge/lib"func main(){
// ...// " " is indent for the padding in generating schema
// in case of using as go module, just " " would be fine
//
// paths should be a relative path
schema := gql.Merge(" ", path1, path2, ...)
}
```## What for?
If you have a modularized GraphQL schema files, such as `*.graphql`, there might be a duplicated types among them. In this case, `gqlmerge` will help you to merge and stitch it into one schema.
_Before_
```graphql
# GetMyProfile.graphqltype Query {
getMyProfile: UserResponse!
}type UserResponse {
ok: Boolean!
error: String
user: User
}type User {
id: ID!
email: String!
fullName: String!
# ...
}# CheckIfExists.graphql
type Query {
checkIfExists(userId: ID!): CheckIfExistsResponse!
}type CheckIfExistsResponse {
ok: Boolean!
error: String
user: [User]!
}type User {
id: ID!
email: String!
fullName: String!
# ...
}
```_Merge & Stitch_
```shell
$ gqlmerge ./schema schema.graphql
```_After_
```graphql
type Query {
getMyProfile: UserResponse!
checkIfExists(userId: ID!): CheckIfExistsResponse!
}type UserResponse {
ok: Boolean!
error: String
user: User
}type CheckIfExistsResponse {
ok: Boolean!
error: String
user: [User]!
}type User {
id: ID!
email: String!
fullName: String!
# ...
}
```## How to use
```shell
$ gqlmerge --indent=2s [PATH ...] [OUTPUT]// PATH : directories with schema
// OUTPUT : output file name
```## Next to do
- [ ] additional error handling