gqlgen-relay

command module
v0.0.0-...-716890b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2019 License: MIT Imports: 8 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL