https://github.com/tyktechnologies/graphql-translator
graphql-translator is a library that takes OpenAPI and AsyncAPI documents and translates them into GraphQL documents.
https://github.com/tyktechnologies/graphql-translator
asyncapi golang graphql oas oas3 openapi
Last synced: 26 days ago
JSON representation
graphql-translator is a library that takes OpenAPI and AsyncAPI documents and translates them into GraphQL documents.
- Host: GitHub
- URL: https://github.com/tyktechnologies/graphql-translator
- Owner: TykTechnologies
- License: mit
- Created: 2024-03-18T08:18:39.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-17T15:53:40.000Z (about 1 year ago)
- Last Synced: 2025-03-28T19:45:52.163Z (about 1 month ago)
- Topics: asyncapi, golang, graphql, oas, oas3, openapi
- Language: Go
- Homepage: https://tyk.io
- Size: 79.1 KB
- Stars: 2
- Watchers: 26
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graphql-translator
graphql-translator is a library that takes OpenAPI and AsyncAPI documents and translates them into GraphQL documents.
This library uses [graphql-go-tools](https://github.com/TykTechnologies/graphql-go-tools) library for GraphQL handling.
## OpenAPI
Supported OpenAPI versions:
* 3.0.0
### How to translate OpenAPI to GraphQL
```go
doc, report := ImportOpenAPIDocumentString(openapiDocument)
if report.HasErrors() {
return report
}// Now, we can pretty-print the resulting abstract syntax tree.
w := &bytes.Buffer{}
err = astprinter.PrintIndent(doc, nil, []byte(" "), w)
if err != nil {
return err
}// This will print the GraphQL document.
fmt.Println(w.String())
````openapi` package also provides `ImportOpenAPIDocumentByte`, `ParseOpenAPIDocument` and `ImportParsedOpenAPIv3Document`
methods. You can check the package documents to see how they work.## AsyncAPI
Supported AsyncAPI versions:
* 2.0.0
* 2.1.0
* 2.2.0
* 2.3.0
* 2.4.0### How to translate AsyncAPI to GraphQL
```go
doc, report := ImportAsyncAPIDocumentString(string(asyncapiDoc))
if report.HasErrors() {
return err
}// Now, we can pretty-print the resulting abstract syntax tree.
w := &bytes.Buffer{}
err = astprinter.PrintIndent(doc, nil, []byte(" "), w)
if err != nil {
return err
}// This will print the GraphQL document.
fmt.Println(w.String())
````asyncapi` package also provides `ImportAsyncAPIDocumentByte`, `ParseAsyncAPIDocument` and `ImportParsedAsyncAPIDocument`
methods. You can check the package documents to see how they work.## License
MIT License - see LICENSE for more details.
## Contributing
Feel free to file an issue in case of bugs. We're open to your ideas to enhance the repository.
You are open to contribute via PR's. Please open an issue to discuss your idea before implementing it,
so we can have a discussion. Make sure to comply with the linting rules. You must not add untested code.