REST API
Microgen also give You SuperrrrPower to use REST API in case You hate GraphQL (I hope not). To use REST API on Microgen is pretty easy, it actually reflect the GQL query, its not that different.
Setup
You don't necessarily setup anything to work with API, simply RUN your Microgen App, then instead use "/graphql", change it to "/api".
So, on above example, your API will be lived on https://dev-myproject5bjqg.microgen.id/api. In this documentation let say the url is "/api" to make it sort.
Authentication
Authentication is simply an POST method which is used on Register and Login.
Register
to Register using API, you can simply do this.
Login
to Logging in using API, you can simply do this.
GET
You can do various query here using REST API. You also have the power from Microgen GraphQL query here.
Read
for example We want to read data from posts with custom query
On above example, You can see that there is no much difference between Graphql Version and the REST API version.
Read with Multiple Filters
Here is simple example about how to use AND queries. Query all Post
nodes that are published
and whose title
is in a given list of strings:
Here is simple example about how to use OR + AND queries. Query all Post
nodes that are either published
and whose title
is in a list of given strings, or have the tags_in
we supply:
Detail
No need explanation Right? :D
POST
the Create mutation on Gql is equal with POST method on REST API, so You can do almost every Gql Create Mutation on REST API.
PATCH
the Update mutation on Gql is equal with PATCH method on REST API, so You can do almost every Gql Update Mutation on REST API.
DELETE
the Delete mutation on Gql is equal with DELETE method on REST API, so You can do almost every Gql Delete Mutation on REST API.
Last updated