Skip to content

Instantly share code, notes, and snippets.

View sogko's full-sized avatar

Hafiz Ismail sogko

View GitHub Profile
@sogko
sogko / AppHomeRoute.js
Last active October 14, 2015 14:21
hello-world-relay-part-1 - RelayJS App
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
@sogko
sogko / file.go
Created October 14, 2015 13:56
hello-world-relay-part-1 - Update golang server
import (
...
"github.com/sogko/golang-relay-starter-kit/data"
)
...
@sogko
sogko / schema.go
Last active November 11, 2016 08:59
hello-world-relay-part-2 - Schema definition (golang)
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
@sogko
sogko / database.go
Created October 14, 2015 11:00
hello-world-relay-part-1 - In-memory database
package data
// Data model structs
type Post struct {
Id string `json:"id"`
Text string `json:"text"`
}
// Mock data
var latestPost = &Post{
@sogko
sogko / schema.graphql
Created October 14, 2015 10:18
hello-world-relay-part-1 - Schema definition (Shorthand notation)
//
// In GraphQL's type system shorthand notation.
// (See: http://graphql.org/docs/typesystem)
//
type Post {
id: ID!
text: String
}
type Query {
latestPost: Post
@sogko
sogko / curl.sh
Last active October 12, 2015 07:15
hello-world-graphql-part-1 - Curl command
curl -XPOST http://localhost:8080/graphql \
-H 'Content-Type: application/graphql' \
-d 'query Root{ latestPost }'
@sogko
sogko / response.json
Created October 7, 2015 11:16
hello-world-graphql-part-1 - Expected response
{
"data": {
"latestPost": "Hello World!"
}
}
@sogko
sogko / main.go
Last active August 3, 2016 07:39
hello-world-graphql-part-1 - Server
package main
import (
"net/http"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql-go-handler"
)
var queryType = graphql.NewObject(graphql.ObjectConfig{
// ...
@sogko
sogko / main.go
Last active August 3, 2016 07:37
hello-world-graphql-part-1 - Schema definition (golang)
package main
import (
"github.com/graphql-go/graphql"
)
var queryType = graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
"latestPost": &graphql.Field{
@sogko
sogko / schema.graphql
Last active October 7, 2015 10:12
hello-world-graphql-part-1 - Schema definition (Shorthand notation)
//
// In GraphQL's type system shorthand notation.
// (See: http://graphql.org/docs/typesystem)
//
type Query {
latestPost: String
}