$ git clone https://github.com/atul-github/loopback-graphql-ext-example.git
$ cd loopback-graphql-ext-example
$ npm install
$ node .
This is example project to demonstrate features of loopback-graphql-ext project. This project is forked from loopback-example-relation and has added dependency to loopback-graphql-ext project.
Before starting this tutorial, you must install:
- Node.js
- git client
- Refer to loopback-example-relation project to understand loopback models used in the project.
Open GraphiQL Editor at http://localhost:3000/graphiql
Customers{
find{
id
name
age
billingAddress{
id
street
city
state
zipCode
}
}
}
Customers{
find (filter:{where:{name : "Customer D"}}) {
id
name
age
}
}
Customers{
find (filter:{where:{ gte :{ age : 22 }}}) {
id
name
age
}
}
Customers{
find (filter:{where: { and : [{ gt :{ age : 22 }}, {name:"Customer C"}] } } ) {
id
name
age
}
}
Note: See the limitation. gt is used before property which is not similar to loopback.
Customers{
find (filter:{where: { and : [{ gt :{ age : 22 }}, {inq:{ name : ["Customer C", "Customer D"]}} ] } } ) {
id
name
age
}
}
Customers{
find (filter:{where: {or : [ { and : [{ gt :{ age : 22 }}, {inq:{ name : ["Customer C", "Customer D"]}} ] }, {id : 1} ] } } ) {
id
name
age
}
}
{
Customers{
find(filter:{ limit:2, where:{gt:{age:20}}}){
id
name
age
}
}
}
Customers{
find(filter:{where:{gt:{id:1 }}, skip : 1} ) {
id
name
age
}
}
Customers{
find(filter:{order : name}) {
id
name
age
}
}
Customers{
find(filter:{order : [name, age]}) {
id
name
age
}
}
Customers{
find(filter:{order : [name_DESC, age]}) {
id
name
age
}
}
Note: See the use of DESC (descending). Not able to make like loopback ( order : [name desc, age] )