1.0.0 ā€¢ Published 4 years ago

sanar-residencia-app-bff v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

sanar-residencia-app-bff

This project uses Slints GraphQL boilerplate. See more details at their repository on GitLab

Developer Guide

Setup and Run

1 - Installing Dependencies

$ npm install

2 - Run development server

$ npm run dev
šŸš€ Server ready at http://localhost:4000/graphql
šŸš€ Subscriptions ready at ws://localhost:4000/graphql

Creating Schema

To create a schema, follow the steps below:

1 - Go to src/schema/index.js and create the schema typeDef.

2 - Now it's time to create the Schema resolver. Create a resolver file in src/schema/resolvers.

Creating Mutations

To create a schema, follow the steps below:

1 - Go to src/mutations folder.

2 - Create a mutation file like below:

export default {
  name: 'myMutation',
  typeDef: `
    input MyMutationInput {
      email: String!
    }
    type MyMutationPayload {
      user: User
    }
  `,
  mutation: `
    myMutation(input: MyMutationInput): MyMutationPayload
  `,
  resolver: async (_, args, { user }) => {
    // Add mutation resolver here
  },
};

Mock & Playground

We have a mock data that follows the real use case of the project. All mock resolvers are located on folder: src/mocks

To enable mocks, just set the environment variable: MOCKS=true

Available Mocks

Queries (Root)
  • me: User
  • questions: QuestionList
  • question(id: ID!): Question
  • flashcards: FlashcardList
  • flashcard (id: ID!): Flashcard
  • flashcardDecks: FlashcardDeckList
  • flashcardDeck (id: ID!): FlashcardDeck
Mutations
  • DoLogin
  • DoFacebookLogin
  • ReportQuestion

Private Queries & Mutations (Auth required)

We can make queires and mutations as a user. See the mock user data below:

Login

Email: bruce.wayne@editorasanar.com

Password: batpassword

Auth Token

Token: iambatman

{
  "Authorization": "Bearer iambatman"
}

Tip: use the JSON above to test as user in GraphQL Playground.