https://github.com/hookactions/gqlgen-relay
GraphQL Relay support for gqlgen. Moved to GitLab.
https://github.com/hookactions/gqlgen-relay
gqlgen graphql
Last synced: 10 months ago
JSON representation
GraphQL Relay support for gqlgen. Moved to GitLab.
- Host: GitHub
- URL: https://github.com/hookactions/gqlgen-relay
- Owner: hookactions
- License: mit
- Archived: true
- Created: 2019-08-03T08:35:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-17T16:09:26.000Z (over 6 years ago)
- Last Synced: 2024-11-14T13:37:18.685Z (over 1 year ago)
- Topics: gqlgen, graphql
- Language: Go
- Homepage: https://gitlab.com/hookactions/gqlgen-relay
- Size: 10.7 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - gqlgen-relay
README
# gqlgen-relay
GraphQL Relay support for gqlgen
## Usage
1. Add relay
```bash
go get -u github.com/hookactions/gqlgen-relay
```
2. Add to code
2a. Go code
```go
//go:generate sh -c "go run github.com/hookactions/gqlgen-relay -pkg model -name User -type *User -cursor > user_relay.go"
package model
type User struct {
FirstName string
LastName string
}
```
2b. schema.graphql
```graphql
interface Node {
id: ID!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
type User {
firstName: String!
lastName: String!
}
type UserEdge {
node: User
cursor: String
}
type UserConnection {
edges: [UserEdge]
pageInfo: PageInfo!
totalCount: Int
}
```
2c. gqlgen.yaml
```yaml
...
models:
# existing config
# ...
# New
PageInfo:
model: github.com/hookactions/gqlgen-relay/relay.PageInfo
Node:
model: github.com/hookactions/gqlgen-relay/relay.Node
User:
model: github.com/your/package/model.User
UserEdge:
model: github.com/your/package/model.UserEdge
UserConnection:
model: github.com/your/package/model.UserConnection
```