Skip to content

Instantly share code, notes, and snippets.

@phoorichet
Last active February 19, 2020 16:52
Show Gist options
  • Save phoorichet/819612e3937d9d70c44cf6a997485a5f to your computer and use it in GitHub Desktop.
Save phoorichet/819612e3937d9d70c44cf6a997485a5f to your computer and use it in GitHub Desktop.

Weekly Order API

This document is assumed that you're already familiar with Graphql.

NOTE: This API is under heavy development. Please link to development GraphiQL Endpoint for full and upated schema details.

1. Signup

Type: Mutation

Request

authSignup(
    username: String
    password: String
    companyId: String
    email: String
): AuthResponse

Response

AuthResponse(
    accessToken: String
    cred: AuthCred
    expiresAt: Int
    refreshToken: String
    tokenType: String
)

AuthCred(
    meth: String
    resp: String
    val: String
)

If successful, other field except AuthCred should be null. And it should contain meth = "email" and val = "email@sample.com".

The validation code will be sent to your email.

2. Login

Type: Mutation

Request

authLogin(
    username: String
    password: String
    companyId: String
    cred: AuthCredInput
): AuthResponse

AuthCredInput(
    meth: String = ""
    val: String = ""
    resp: String = ""
)

AuthCredInput if the user has not been validated yet, this field should contain meth: "email" resp: "CONFIRMATION CODE". The other fields can be null.

Response

AuthResponse(
    accessToken: String
    cred: AuthCred
    expiresAt: Int
    refreshToken: String
    tokenType: String
)

In successful, accessToken and tokenType should be return. Current tokenType supported now is Bearer.

The client must set Authorization: Bearer 'token' in the request header before calling query or mutation transaction.

3. Create Company

If the user has no any associated company, he can create a new company calling to createCompany mutation.

Type: Mutation

createCompany(input: CreateCompanyInput): Company

4. Join Company

If there is aleady existing company, the user can call joinCompany to join the existing one.

Type: Mutation

joinCompany(companyId: String): Company

5. Send Join Company Invitation

The user can send invitation to others to join company he already is associated.

The email sent by the server contains the companyId so the client can grab it and call joinCompany.

Type: Mutation

sendJoinCompanyInvitation(emails: [String]): [InvitationResponse]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment