DEV Community

Cover image for Your GraphQL Dictionary
Tomek Poniatowicz for GraphQL Editor

Posted on • Updated on • Originally published at blog.graphqleditor.com

Your GraphQL Dictionary

GraphQL is a modern query language for APIs. During your first encounter with the GraphQL, you might notice some unfamiliar terms. I hope this GraphQL Dictionary will be somehow useful at the beginning of your journey with GraphQL :)

Argument

An argument is a set of key-value attached to a field. The Arguments can have a form of literal values or variables.

Alias

Alias is an alternative name assigned to the result of a field to avoid conflicts during data fetching operations i.e. admin and regular.

{
 admin: users(role: admin) {
   id
   firstname
   lastname
 }
 regular: users(role: regular) {
   id
   firstname
   lastname
 }
}
Enter fullscreen mode Exit fullscreen mode

Directive

An explanation preceded by a @ that encloses the logic for query execution on client/server. GraphQL built-in directives are @skip and @include, and allow to define custom ones.

Field

A basic unit of data you request from your schema returned as a field in JSON response i.e. idand name.

type User {
 id: Int!
 name: String
}
Enter fullscreen mode Exit fullscreen mode

Fragment

A selection set that can be reused in multiple query operations. A GraphQL fragment is a shared piece of query logic.

GraphQL Editor

GraphQL Editor makes understanding GraphQL schema a lot easier. Plan your schema by linking visual blocks and GraphQL Editor will transform them into code.

Introspection

A method to provide precise information about the schema of a GraphQL API. Introspections are prefixed by "__".

Mutation

One of basic GraphQL operations allowing to manipulate data (create, modify, delete).

mutation DeleteTodo($type: String!) {
 deleteTodo(type: $type) {
   id
   type
 }
}
Enter fullscreen mode Exit fullscreen mode

Object Type

It's type in a GraphQL schema that contains fields. User is our Object Type here:

type User {
  name: String!,
}
Enter fullscreen mode Exit fullscreen mode

Operation

The single query, mutation or subscription, which could be interpreted by execution engine in GraphQL.

Operation Name

A name for above-mentioned elements. Name make a lot easier identifying, logging or debugging errors in a GraphQL server.

Query

It's a basic fetch operation to request data in GraphQL.

Query Colocation

One of GraphQL best practices, where you place a GraphQL query in the same location as the app component’s view logic.

Query whitelisting

A security practice involving defining a list of approved queries that are allowed in your app.

Resolver

A function connecting your GraphQL schema elements to backends. Resolvers turn operations into data; they can return strings, ints, null & other primitives.

Schema

A GraphQL schema is the central piece of every GraphQL server implementation. The GraphQL schema is responsible for the whole logic of your project and describes functionalities available to the client app.

Schema Definition Language (SDL)

A GraphQL Schema Definition is a way to define a GraphQL schema. The syntax is a are part of the official GraphQL specification. The main components of each schema are the types and their fields.

The GraphQL schema for a movie review site could be defined like this:

type Review {
 id: String!
 title: String!
 publishedAt: DateTime!
 stars: Int! @default(value: 0)
 feed: Feed @relation(name: "Reviews")
}

type Feed {
 id: String!
 name: String!
 description: String,
 reviews: [Review!]! @relation(name: "Review")
}
Enter fullscreen mode Exit fullscreen mode

Schema Stitching

Merging minor schemas into central GraphQL schema.

Subscription

Is a real-time operation in GraphQL that is defined in a schema.

type Subscription {
 reviewAdded(repoFullName: String!): Review
}
...
subscription onReviewAdded($repoFullName: String!){
 reviewAdded(repoFullName: $repoFullName){
   id
   content
 }
}
Enter fullscreen mode Exit fullscreen mode

Scalar Type

It's GraphQL type that validates the data that GraphQL field resolves. String, Int, Boolean, Float are all built-in scalars that you can do a lot with out of the box. Custom scalar types can be specified in GraphQL service implementation.

Type System

It's a set of rules that define the set of data that can be validated, queried & executed.

Variable

It's a value that can be passed to an operation, like userID in below example:

query GetUser($userId: ID!){
 user(id: $userId){
   name
 }
}
Enter fullscreen mode Exit fullscreen mode

PS:

The original article was posted on GraphQL Editor Blog - https://blog.graphqleditor.com/GraphQL-tutorial-dictionary/

Here is the link to GraphQL Editor app in case you want to try it out -
https://app.graphqleditor.com/showcase/fake-twitter/

If you're looking for best GraphQL tutorials check this post.

Top comments (6)

Collapse
 
arswaw profile image
Arswaw • Edited

My boss described GraphQL today without knowing it. He insisted that we don't need to return a 1.5 MB JSON document in order to retrieve all the project licenses that are associated with a user. An array of uuids is enough.

I told him about a system that allows to you to specify which fields you want to return, and receive exactly that.

I will be pleased if this leads to a separate GraphQL API for our flagship project.

Collapse
 
tomekponiat profile image
Tomek Poniatowicz

I keep my fingers crossed ;) GraphQL is really awesome!
PS: We have a tool making taking first steps with GraphQL easier (at least we hope so ;P).
It's GraphQL Editor (graphqleditor.com/) and it allows visualize your existing schema to get know with it better or create one from visual blocks. Maybe it will be helpful for you or your team if you will decide to jump into GraphQL train :)
Peace!

Collapse
 
enriquemorenotent profile image
Enrique Moreno Tent

Querry sounds like an operation to fetch Asian food.

I think you got a typo. ;)

Collapse
 
tomekponiat profile image
Tomek Poniatowicz

Thanks! :)

Collapse
 
tomekponiat profile image
Tomek Poniatowicz

<3

Collapse
 
ponyjackal profile image
ponyjackal

Thanks for your useful post.
I've experienced with GraphQL (Apollo client and server)
And I have a couple of questions.

  1. How does Subscription work?
  2. How can I define Type in resolve?