Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

hookactions/gqlgen-relay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gqlgen-relay

GraphQL Relay support for gqlgen

Usage

  1. Add relay
go get -u github.com/hookactions/gqlgen-relay
  1. Add to code

2a. Go code

//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

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

...
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

Releases

No releases published

Packages

No packages published

Languages