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
// Greet -> build.gradle.kts | |
tasks.matching { it.name != "loadMamboMotoFile" }.all { | |
println("Executing task: ${this.name}") | |
this.dependsOn("loadMamboMotoFile") | |
} | |
tasks.register("loadMamboMotoFile") { | |
println("Executing task: ${this.name}") | |
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 ( | |
"fmt" | |
"github.com/graphql-go/graphql" | |
"github.com/graphql-go/handler" | |
"log" | |
"net/http" | |
"time" | |
) |
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
fields := graphql.Fields{ | |
"notes": &graphql.Field{ | |
Name: "Get all notes", | |
Type: graphql.NewList(noteType), | |
Description: "Get list of all notes", | |
Resolve: func(params graphql.ResolveParams) (interface{}, error) { | |
return notes, nil | |
}, | |
}, |
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
... | |
"note": &graphql.Field{ | |
Name: "Get note by ID", | |
Type: noteType, | |
Description: "Get note by ID", | |
Args: graphql.FieldConfigArgument{"id": &graphql.ArgumentConfig{Type: graphql.Int}}, | |
Resolve: func(params graphql.ResolveParams) (interface{}, error) { | |
id, isValid := params.Args["id"].(int) | |
if isValid { |
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 ( | |
"fmt" | |
"github.com/graphql-go/graphql" | |
"github.com/graphql-go/handler" | |
"log" | |
"net/http" | |
"time" | |
) |
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
go get github.com/graphql-go/graphql // GraphQL-Go | |
go get github.com/graphql-go/handler // GraphQL-Go-Handler |
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
... | |
var sandboxHTML = []byte(` | |
<!DOCTYPE html> | |
<html lang="en"> | |
<body style="margin: 0; overflow-x: hidden; overflow-y: hidden"> | |
<div id="sandbox" style="height:100vh; width:100vw;"></div> | |
<script src="https://embeddable-sandbox.cdn.apollographql.com/_latest/embeddable-sandbox.umd.production.min.js"></script> | |
<script> | |
new window.EmbeddedSandbox({ |
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
log.Fatal(http.ListenAndServe(":8080", nil)) |
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
handler := handler.New(&handler.Config{ | |
Schema: &schema, | |
Pretty: true, | |
GraphiQL: false, | |
}) | |
http.Handle("/graphql", handler) |
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
schemaConfig := graphql.SchemaConfig{Query: graphql.NewObject(rootQuery)} | |
schema, err := graphql.NewSchema(schemaConfig) | |
if err != nil { | |
log.Fatalf("Failed to create graphql schema: %v", err) | |
} |
NewerOlder