Skip to content

Instantly share code, notes, and snippets.

@dosco
Last active June 2, 2022 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dosco/2422006fe322bd81c00988570f50a59c to your computer and use it in GitHub Desktop.
Save dosco/2422006fe322bd81c00988570f50a59c to your computer and use it in GitHub Desktop.
Examples of using GraphJin
// Create GraphJin
sg, err := core.NewGraphJin(nil, db)
if err != nil {
log.Fatal(err)
}
// Your GraphQL query
query := `
query {
posts {
id
title
author {
id
name
}
comments {
id
body
}
comments_cursor
}
posts_cursor
}`
// Execute the Query
ctx := context.Background()
ctx = context.WithValue(ctx, core.UserIDKey, 1)
res, err := sg.GraphQL(ctx, query, nil, nil)
if err != nil {
log.Fatal(err)
}
// Result in res.Data
fmt.Println(string(res.Data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment