Skip to content

larsnolden/bidmatik_user

Repository files navigation

User Microservice

Code Style:

Graphql

use input Object types for mutations

They make creating mutations on the client easier and more compact

*** Client: ***

mutation createPlanet($input: CreatePlanetInput!) {
  createPlanet(input: $input) {
    planet {
      id
      name
      age
      color
      size
    }
  }
}

*** Server: ***

input CreatePlanetInput {
  name: String!
  age: Int!
  color: Color!
  size: Int!
}

type MutationRootType {
  createPlanet(input: CreatePlanetInput!): Planet!
}
  1. We save on writing out the full set of arguments on the client in the mutation request:
(Bad Form)

mutation createPlanet(
  $name: String!,
  $age: Int!,
  $color: Color!,
  $size: Int!
  ) {
  createPlanet(
    name: $name,
    age: $age,
    color: $color,
    size: $size,
  ) {
    planet {
      id
      name
      age
      color
      size
    }
  }
}

  1. We do not have to change any GQL on the frontend if we decide to change (eg. add or delete) the arguments for the mutation

always return the affected type as a result of a mutation

This in combination with an ID on every type allows the client cache to merge the updated type automagically.


Extract as much logic as possible out of the resolver in testable functions


Create .graphql files for every type or very similar types


Use the db handler on the context to resolve data

TODO: insert example

About

Bidmatik user microservice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published