Giter VIP home page Giter VIP logo

go-graphql-example's Introduction

go-graphql-tutorial

Just an example for Graph Query language.

GQL Stacks

  • gqlgen
  • gin

Federation?

  • The idea is distributed graphs
  • Building a new unified and single Graph API (by combining multiple graph schemas)
  • With GraphQL federation, you tell the gateway where it needs to look for the different objects and what URLs they live at. The subgraphs provide metadata that the gateway uses to automatically stitch everything together. This is a low-maintenance approach that gives your team a lot of flexibility.
  • Have a gateway layer
  • Split or decentralized yet interoperable among teams working in different locations
  • Schemas are split across multiple services, and as they grow or scale over time, federation via the “gateway” layer

Develop Guides

References

Getting Started

cmd/gql

GraphQL

  1. setup module
go mod init <your_module>
  1. Initialise gqlgen config and generate models
go run github.com/99designs/gqlgen init

The project skeleton will be created. you can read more about skeleton structure and file from [here](go run github.com/99designs/gqlgen init)

  1. Removed unnecessary code from generated file. Here you are going to leave gqlgen.yml on your project.
├── gqlgen.yml               - The gqlgen config file, knobs for controlling the generated code.
  1. Modify the schema which are includes schema, mutation and query.
  2. Run go run github.com/99designs/gqlgen generate to re-generate the schema
  3. Make sure all schema has been updated by git diff

cmd/gql-server

GraphlQL Server and Playground

go run main.go

Playground Queries

Mutation

mutation createTodo {
  createTodo(input: { text: "golf todo", userId: "1" }) {
    user {
      id
    }
    text
    done
  }
}

Query

query findTodos {
  todos {
    user {
      id
      name
    }
    text
  }
}

go-graphql-example's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.