Skip to content

Basic tutorial on graphql in go and apollo ... with gophers in space

Notifications You must be signed in to change notification settings

cat-turner/gophers-in-space

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

gophers-in-space

Basic tutorial on graphql in go ... with gophers in space.

What is it? Graphql is a query language for APIs developed by Facebook.

Why use it?

  • one call
  • define percisely the data you want

How a graphql server is used:

  • As a main server (ie CRUD)
  • As a microservice that exposes data. Business logic lives in other services written in many languages

To make requests

No apollo today :( ...

Instead we will make our queries and mutations with altair, a graphql client.

install with brew cask: $ brew cask install altair-graphql-client

Code Organization

./example_1

Implement using graphql-go/graphql

We create the graphql schema, types, and define the resolvers.

./example_2

Lib implements it for you 99designs/gqlgen

Pick a library that will manage splitting the schema and mutations in seperate files with autogenerated code. Some comparisons

Pre-requisites

This examples in this repo depend on:

Install them by running:

example_1

$ go get github.com/gorilla/mux

$ go get github.com/graphql-go

example_2

$ go get github.com/99designs/gqlgen

To run it

After installing the deps, you can start the application by browsing to the root folder.

example_1

$ go run main.go

example_2

implement notes in README.md

go run ./server/server.go

End Notes

For the learnings:

https://graphql.org/learn/

For the noice implementation:

https://developer.github.com/v4/

https://developer.github.com/v4/guides/forming-calls/

Glossary:

https://www.apollographql.com/docs/resources/graphql-glossary

How to graphql

  • Study examples, and think about how the front end views data
  • Make it obvious with names: Query vs Mutation
  • Focus on writing the schema, types, and the resolvers

Dev Tools

About

Basic tutorial on graphql in go and apollo ... with gophers in space

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages