REST API
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
You don't necessarily setup anything to work with API, simply RUN your Microgen App, then instead use "/graphql", change it to "/api".
Authentication is simply an POST method which is used on Register and Login.
to Register using API, you can simply do this.
to Logging in using API, you can simply do this.
You can do various query here using REST API. You also have the power from Microgen GraphQL query here.
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.
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:
No need explanation Right? :D
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.
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.
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.
So, on above example, your API will be lived on . In this documentation let say the url is "/api" to make it sort.