002: A Quick and Dirty Overview of GraphQL
There doesn’t seem to be a whole lot to the language, and maybe that’s what makes it so powerful.
GraphQL
GraphQL appears to be pretty straightforward. It’s a query language which, up until recently, I didn’t realize was its own thing. One of the many detours I took over this past year has been to look into CodeQL. It wasn’t until I started looking into GraphQL that I realized what the “QL” represents.
I know. Super sharp, right?
Anyway, the structure of GraphQL appears to be fairly simple. It’s strongly typed and provides three primary operations: query
, mutation
, and subscription
. Beyond that, there are fragments and directives and schema. Six base pieces that combine in different ways in an Object-Oriented format to provide incredible granular control for data acquisition. Understanding this, the next challenge is in the implementation, which is next in my curriculum.
I spent my coding time reading up on queries and the history of GraphQL. I also set up an Express project with GraphQL to begin playing with it. I managed to get a GraphQL server up and running, but have some work to do in understanding how to implement GraphQL properly. I thought I could create a separate router module with the /graphql endpoint that would deliver GraphiQL when summoned in the browser. However, while the endpoint loaded, GraphiQL did not. I’ll need to revisit my implementation and learn how to properly run GraphQL alongside, or in front of, Express.
Content I worked through, read and watched:
- Anatomy of a GraphQL Query
- An Introduction to GraphQL Queries
- Lessons from 4 Years of GraphQL (article & video)
- Thinking in Graphs
- Things You Should Never Do, Part I
- HowToGraphQL — Core Concepts (video)
- Mutations in GraphQL
- Running an Express GraphQL Server
Insomnia
As part of my 100 Days Of Code commitment to using Insomnia every day, I used Insomnia to test my endpoints on my attempt at an Express-GraphQL server. The homepage, which displays nothing, came back fine. The /graphql endpoint did not, but I knew as much before I plugged it in.
002/100