Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinmichaelchen/go-gqlgen-schemaless-example
Example of using GQLGEN GraphQL server with an untyped object.
https://github.com/kevinmichaelchen/go-gqlgen-schemaless-example
Last synced: about 1 month ago
JSON representation
Example of using GQLGEN GraphQL server with an untyped object.
- Host: GitHub
- URL: https://github.com/kevinmichaelchen/go-gqlgen-schemaless-example
- Owner: kevinmichaelchen
- Created: 2023-03-24T20:39:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-03-27T17:03:36.000Z (over 1 year ago)
- Last Synced: 2024-03-26T04:06:25.212Z (9 months ago)
- Language: Go
- Homepage: http://localhost:8081/
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-gqlgen-schemaless-example
## Motivation
This example shows a GraphQL API (built in Go using the [gqlgen](https://github.com/99designs/gqlgen)
library), which uses a custom scalar to encode explicit fields that are
deliberately omitted from the GraphQL schema.See this [issue](https://github.com/99designs/gqlgen/issues/1758) for reference.
### Why would you want to do this?
Why would you ever do this? Isn't the whole point of GraphQL that types are
strong and explicit?Most of the time, they are. Sometimes, however, produce requirements aren't
clear, and you want to avoid having to accumulate either a messy API or having
to break your API to clean it up.## Getting started
### Start the server
Start the GraphQL server on port 8081:
```shell
make run
```### Hit the server
Visit [localhost:8081](http://localhost:8081/) and run the following mutation:
```graphql
mutation CreateFoo(
$attributes: Map!
) {
createFoo(
input: {
attributes: $attributes
}
) {
name
}
}
```with variables:
```json
{
"attributes": {"settings": {"toggle1": true}}
}
```