DEV Community

KateMLady
KateMLady

Posted on

New Possibilities with GraphQL

Nowadays, communities that support software run many blogs to explain the nuances of development. Here you go, GitHub GraphQL for beginners!

Image description

Some code inserts, examples and samples for installation will help at the beginning of the path. If there is a need for a question, you can always leave a comment under the post, I think the developers will not refuse to communicate.

Let's continue our exploration of GraphQL!

schema {
  query: MyQueryType
  mutation: MyMutationType
  subscription: MySubscriptionType
}
Enter fullscreen mode Exit fullscreen mode

The diagram allows you to assemble a graph from the previously listed objects and even indicate specific connection points.

enum Episode {
  NEWHOPE
  EMPIRE
}

input ReviewInput {
  stars: Int!
  commentary: String
}

type Mutation{
  createReview(episode: Episode, review: ReviewInput!): Review
}
Enter fullscreen mode Exit fullscreen mode

Adding/removing objects happens automatically without the need to understand graph theory (although I recommend it!). It looks like simple functions with a number of parameters.

function Query_person(obj, args, context) {
  return context.db.loadPersonByID(args.id).then(
    userData => new Person(userData)
  )
}
Enter fullscreen mode Exit fullscreen mode

Queries about objects are also implemented through functions. The simplest knowledge of the theory of OOP classes will help to form a correct query to the DB.

It looks quite demanding, but I think that's a good thing! Let's not forget about good coding style. I consider the high entry threshold into NoSQL GraphQL to be a plus, since knowledge of scripting constructs/APIs requires a certain developer status.

Top comments (0)