Appearance
Vasat + GraphQL
Vasat support for GraphQL allows for a very powerful way for clients to query your data. For comprehensive documetentation on using GraphQL visit the website graphql.org.
GraphQL Endpoint
This is specified by the application. Default recommendation is simply the route
POST /graphql
Authentication
The GraphQL endpoint must still have a valid access token. The token can be provided either
- Via the
Authroization: Bearer xxxxxxx
header. - Or via the query parameter
?access_token=xxxxxxxx
eg Using the client GraphiQL
js
const fetcher = GraphiQL.createFetcher({
url: 'http://localhost:9000/graphql',
headers: {
'Authorization': 'bearer XXXXXX'
},
});
Permissions
Users of the graphql api need either the Vasat permission /graphql[read]
or /admin/graphql[read]
Important
You must have a Vasat license with the graphql
module enabled.
Searching a Vasat Model
The Vasat implementation of GraphQL provides 2 methods for filtering
Simple filtering
For a simple key = value query (or multiple key=values that all need to be met) the filed=value can be used
graphql
query{
Article(category:"sports",name:"My Article"){
name
}
}
complex query filtering
For more control over the query including things like
- string containing value
- item in a list of many values
- greater than or less than
- control over and/or conjunctions
We have complex queires. These mirror the complex query notation used in the Restful API.
graphql
query{
Article(query:{
{and:[
{category:{in:["sports","arts"]}}
{name:{like:"star"}}
]}
}){
name
}
}