This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Relay from 'react-relay'; | |
// Your Relay routes | |
// Define a root GraphQL query into which your | |
// containers' query fragments will be composed. | |
export default class extends Relay.Route { | |
static queries = { | |
latestPost: () => Relay.QL` | |
query { | |
latestPost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
... | |
"github.com/sogko/golang-relay-starter-kit/data" | |
) | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package data | |
import ( | |
"github.com/graphql-go/graphql" | |
"github.com/graphql-go/relay" | |
) | |
var postType *graphql.Object | |
var queryType *graphql.Object | |
var Schema graphql.Schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package data | |
// Data model structs | |
type Post struct { | |
Id string `json:"id"` | |
Text string `json:"text"` | |
} | |
// Mock data | |
var latestPost = &Post{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// In GraphQL's type system shorthand notation. | |
// (See: http://graphql.org/docs/typesystem) | |
// | |
type Post { | |
id: ID! | |
text: String | |
} | |
type Query { | |
latestPost: Post |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPOST http://localhost:8080/graphql \ | |
-H 'Content-Type: application/graphql' \ | |
-d 'query Root{ latestPost }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": { | |
"latestPost": "Hello World!" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"github.com/graphql-go/graphql" | |
"github.com/graphql-go/graphql-go-handler" | |
) | |
var queryType = graphql.NewObject(graphql.ObjectConfig{ | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/graphql-go/graphql" | |
) | |
var queryType = graphql.NewObject(graphql.ObjectConfig{ | |
Name: "Query", | |
Fields: graphql.Fields{ | |
"latestPost": &graphql.Field{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// In GraphQL's type system shorthand notation. | |
// (See: http://graphql.org/docs/typesystem) | |
// | |
type Query { | |
latestPost: String | |
} |