Code Monkey home page Code Monkey logo

go-mgql's Introduction

Go Mock Graphql (go-mgql)

Library to mock graphql requests.

Usage

Create a new mgql instance:

m := mgql.New()
m.Query("GetAccount", func(ctx mgql.Context) {
	ctx.Data(
		mgql.Map{
			"account": mgql.Map{
				"id": ctx.Variables["id"],
			},
		},
	)
})

Pass the HTTP handler to a test server:

testServer := httptest.NewServer(m.Handler())

Reset mgql registry before each test:

ginkgo.BeforeEach(func() {
	m.Reset()
})

Overwrite default resolvers at your test:

It("creates service appointment when onboarding", func() {
  // ...
	m.Query("GetAccount", func(ctx mgql.Context) {
    // ..
	})
  // ... 
})

API

  • func New() *MGQL
  • func (m *MGQL) Handler() http.HandlerFunc
  • func (m *MGQL) Mutation(operationName string, responseResolver ResponseResolver)
  • func (m *MGQL) Query(operationName string, responseResolver ResponseResolver)
  • func (m *MGQL) Reset()
  • func (m *MGQL) SpyMutation(operationName string, responseResolver ResponseResolver)
  • func (m *MGQL) SpyQuery(operationName string, responseResolver ResponseResolver)

go-mgql's People

Contributors

dependabot[bot] avatar josemarluedke avatar strobus avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-mgql's Issues

Reporting a vulnerability

Hello!

I hope you are doing well!

We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.

Can you enable it, so that we can report it?

Thanks in advance!

PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository

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.