Documentation
¶
Overview ¶
Package / library or rather wrapper for GraphQL queries execution in the painless way. Using it is as easy as copy / paste the query itself and set appropriate variables in.
Library supports basic error reporting on unsuccessful queries and setting appropriate headers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var GraphQLUrl string
Endpoint of your GraphQL server to query this variable can be overwritten by setting env variable, for example: GRAPHQL_ENDPOINT=http://hasura.local/v1/graphql
Functions ¶
func Query ¶
Query allows you to execute the GraphQL query. Query is a string ( copy paste from Hasura or any other query builder ) Variables and Headers are maps of strings ( see the example ) Function returns whatever specified query returns and/or error.
Example ¶
variables := map[string]interface{}{
"fileHash": "123deadc0w321",
}
var query = `query searchFileKnown($fileHash: String) {
tbl_file_scans(where: {file_hash: {_eq: $fileHash}}) {
porn
racy
violence
virus
}
}`
result, err := Query(query, variables, nil)
if err != nil {
fmt.Println("Query error", err)
return
}
fmt.Println(result)
Types ¶
This section is empty.