GraphQL
Queries
for each service generated, it already available on the gql docs. The basic functionality are (for example we have post service):
Read
list of posts
Connection
list of posts with aggregate and pagination info
Detail
post detail
Querying
list query with params
more queries documentation, COMING SOON (for now refer to the autocomplete feature in playground)
Raw Query
list query with params with Raw Query. It means that you can use feathers mongo native query.
more queries are available on feathers docs (https://docs.feathersjs.com/api/databases/querying.html#limit)
Mutations
Create
create a post
Update
update a post
Delete
delete a post
One to Many
Create and Connect
create a Comment on a Post
Read with Relations
list of posts with comments. Post hasMany Comment, and Comment belongsTo Post.
Many to Many
Create and Create Many Relation
create a Post and create new multiple categories
Create and Connect Many Relation
create a Post and connect with multiple existing categories
Update and Create Many
update a Post and create new multiple categories (replace old data with new data)
Update and Replace Many
update a Post and connect+replace existing multiple categories
Remove Relation
remove an existing category on a post
Add Relation to Existing
add existing category on existing post
Authentication and Users GQL
because User services are generated by default, You also have ability to do basic functionality for this service, such as CRUDSS and Authentication:
Queries
lists: list of users
connection: list of users with aggregate and pagination info
detail: user detail
Mutations
login: authenticate a user, and return a token and user obj
register: register a user, and return a token and user obj
verifyEmail: send email to user, when they are registering as new user
forgetPassword: send email to user, when they are forgetting their password
resetPassword: resetting an user password, and sending them email
changeProfile: update a user (authenticated user, and its own data)
createUser: create a user (admin only)
updateUser: update a user (admin only)
deleteUser: delete a user (admin only)
Socket
Microgen is battery included, socket is one of them. To use it, simply use graphql subscription tag. There are 3 types of subscriptions (for example You have post service, it will generate):
postAdded: triggered when post added
postUpdated: triggered when post updated
postDeleted: triggered when post deleted
Role & Permissions
Microgen had already defined role & permissions for You. To change the default permissions, You can change on "outputs/services/users/permission.js". But as we knew before, change something on outputs folder is not the best practice. Instead, You can change the permission, inside "hooks/user.js" by rewriting the permissions object (more info: https://docs.mejik.id/mejik-microgen/hooks#usage-example-on-user-service-with-custom-permissions).
on the example above, it means that:
admin able to access everything
authenticated users, able to do everything on post-service (special case for update and delete only able to update and delete owned data)
public (unauthenticated users) only able to use post-service on find and get methods
Anyways if you remember that you had set enum Role with custom input, then you will have some permissions added.
Note: the first user registered on microgen, are registered as admin role
Add-ons
Microgen comes with a bunch of Add-ons functionality such as email, file storage, push notification, and social media auth. In order to use them, you must set the API KEY, API SECRET etc from third parties provider such as Google Auth, OneSignal, SendGrid, and AWS S3. If you don't want to setup them, you can use Microgen default setup (only available on PRO and Enterprise Pricing Plan).
OTP
You can using OTP verification in microgen, but first don't forget to set the configuration at the setting menu first, because we don't provide OTP SMS provider. Here is some queries that you can use:
loginWithPhone: to login using phone number and send SMS to a number, it will also check whether there is a user with same phone number or not
verifyLoginWithPhone: to verify the number that had been sent after using loginWithPhone mutation. This mutation response is a token that can be used to logged in your user.
requestOtp: to request an OTP in any flexible situation. For example completing user profile.
verifyOtp: to verify OTP that had been sent using requestOTP mutation. This will not check user table, and not sent back token
Email
Email functionality by default are attached to another service such as forgetPassword, register, etc. But if you want use it as standalone, you should loggedIn as "admin" role, then execute some of these mutation below:
mutation
sendEmail: Sending email to any email(s)
sendEmailToUsers: Sending email to all registered users
Files Storage
Upload file(s) to storage. (in this example, we use service called image)
note that createImage mutation is returning an url, this url String can be used to be saved on your related service as a file path.
Push Notification
Subscribe playerId (a device) to receive all push notification
Subscribe playerId (a device) to receive push notification on a segment
Send push notification to all
Send push notification to all players on a segment
Send push notification to specific userId (in all of his devices/playerIds). UserId here is the real id that registered on database, and not playerId.
Unsubscribe playerId (device) from all push notifications
Unsubscribe playerId (device) on receiving push notification from a segment
Social Media Auth
Login with Google Account (jwtToken are received when a dialog closed, search about google login third party at client side)
Login with Facebook Account (jwtToken are received when a dialog closed, search about facebook login third party at client side)
Last updated