Skip to content

Commit

Permalink
Update html file
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarYuen committed Jan 12, 2018
1 parent 3a20318 commit 7f522fc
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 45 deletions.
37 changes: 37 additions & 0 deletions graphiql.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.10.2/graphiql.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.1.0/fetch.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.5.4/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.5.4/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.10.2/graphiql.js"></script>
</head>
<body style="width: 100%; height: 100%; margin: 0; overflow: hidden;">
<div id="graphiql" style="height: 100vh;">Loading...</div>
<script>
function graphQLFetcher(graphQLParams) {
return fetch("/query", {
method: "post",
headers: {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkX2F0IjoiMjAxOC0wMS0wM1QxNToyNToyNloiLCJleHAiOjE1MTU1NzMwODAsImlkIjoiTXc9PSIsImlzcyI6ImdvLWdyYXBxbC1zdGFydGVyIn0.c1QYtflkF0ZxQIj05mOf_5BfniZ9ePDXajapKge-EQg',
},
body: JSON.stringify(graphQLParams),
credentials: "include",
}).then(function (response) {
return response.text();
}).then(function (responseBody) {
try {
return JSON.parse(responseBody);
} catch (error) {
return responseBody;
}
});
}
ReactDOM.render(
React.createElement(GraphiQL, {fetcher: graphQLFetcher}),
document.getElementById("graphiql")
);
</script>
</body>
</html>
File renamed without changes.
2 changes: 1 addition & 1 deletion resolver/user_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package resolver
import (
"../model"
"../service"
"github.com/neelance/graphql-go"
graphql "github.com/neelance/graphql-go"
"strconv"
"time"
)
Expand Down
48 changes: 4 additions & 44 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"log"
"net/http"

"github.com/neelance/graphql-go"
"github.com/neelance/graphql-go/relay"
graphql "github.com/neelance/graphql-go"
relay "github.com/neelance/graphql-go/relay"
"golang.org/x/net/context"
)

Expand All @@ -25,7 +25,7 @@ func serveHome(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Method not allowed", 405)
return
}
http.ServeFile(w, r, "home.html")
http.ServeFile(w, r, "notification.html")
}

func main() {
Expand All @@ -43,7 +43,7 @@ func main() {
graphqlSchema := graphql.MustParseSchema(schema.GetRootSchema(), &resolver.Resolver{})

http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write(page)
http.ServeFile(w, r, "graphiql.html")
}))

http.Handle("/login", handler.Login(ctx))
Expand All @@ -56,43 +56,3 @@ func main() {

log.Fatal(http.ListenAndServe(":3000", nil))
}

var page = []byte(`
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.10.2/graphiql.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.1.0/fetch.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.5.4/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.5.4/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/graphiql/0.10.2/graphiql.js"></script>
</head>
<body style="width: 100%; height: 100%; margin: 0; overflow: hidden;">
<div id="graphiql" style="height: 100vh;">Loading...</div>
<script>
function graphQLFetcher(graphQLParams) {
return fetch("/query", {
method: "post",
headers: {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkX2F0IjoiMjAxOC0wMS0wM1QxNToyNToyNloiLCJleHAiOjE1MTU1NzMwODAsImlkIjoiTXc9PSIsImlzcyI6ImdvLWdyYXBxbC1zdGFydGVyIn0.c1QYtflkF0ZxQIj05mOf_5BfniZ9ePDXajapKge-EQg',
},
body: JSON.stringify(graphQLParams),
credentials: "include",
}).then(function (response) {
return response.text();
}).then(function (responseBody) {
try {
return JSON.parse(responseBody);
} catch (error) {
return responseBody;
}
});
}
ReactDOM.render(
React.createElement(GraphiQL, {fetcher: graphQLFetcher}),
document.getElementById("graphiql")
);
</script>
</body>
</html>
`)

0 comments on commit 7f522fc

Please sign in to comment.