gqlanalysis makes easy to develop static analysis tools for GraphQL in Go.

Overview

gqlanalysis

pkg.go.dev

gqlanalysis defines the interface between a modular static analysis for GraphQL in Go. gqlanalysis is inspired by go/analysis.

gqlanalysis makes easy to develop static analysis tools for GraphQL in Go.

How to use

Analyzer

The primary type in the API is Analyzer. An Analyzer statically describes an analysis function: its name, documentation, flags, relationship to other analyzers, and of course, its logic.

package lackid

var Analyzer = &analysis.Analyzer{
	Name: "lackid",
	Doc:  "lackid finds a selection for a type which has id field but the selection does not have id",
	Run:  run,
	...
}

func run(pass *analysis.Pass) (interface{}, error) {
	...
}

Driver

An analysis driver is a program that runs a set of analyses and prints the diagnostics that they report. The driver program must import the list of Analyzers it needs.

A typical driver can be created with multichecker package.

package main

import (
        "github.com/gqlgo/gqlanalysis/multichecker"
        "github.com/gqlgo/lackid"
        "github.com/gqlgo/myanalyzer"
)

func main() {
        multichecker.Main(
		lackid.Analyzer,
		myanalyzer.Analyzer,
	)
}

Pass

A Pass describes a single unit of work: the application of a particular Analyzer to given GraphQL's schema and query files. The Pass provides information to the Analyzer's Run function about schemas and queries being analyzed, and provides operations to the Run function for reporting diagnostics and other information back to the driver.

type Pass struct {
        Analyzer *Analyzer

        Schema   *ast.Schema
        Queries  []*ast.QueryDocument
        Comments []*Comment

        Report   func(*Diagnostic)
        ResultOf map[*Analyzer]interface{}
}

Diagnostic

A Diagnostic is a message associated with a source location. Pass can report a diagnostic via Report field or Reportf method.

type Diagnostic struct {
        Pos     *ast.Position
        Message string
}

Implementations of Analyzer

Author

Appify Technologies, Inc.

You might also like...
Go monolith with embedded microservices including GRPC,REST,GraphQL and The Clean Architecture.
Go monolith with embedded microservices including GRPC,REST,GraphQL and The Clean Architecture.

GoArcc - Go monolith with embedded microservices including GRPC,REST, graphQL and The Clean Architecture. Description When you start writing a Go proj

GraphQL implementation for click house in Go.
GraphQL implementation for click house in Go.

clickhouse-graphql-go GraphQL implementation for clickhouse in Go. This package stores real time streaming websocket data in clickhouse and uses Graph

GraphQL parser comparison in different languages

graphql-parser-bench Parsing a schema or document can be a critical part of the application, especially if you have to care about latency. This is the

A simple Go, GraphQL, and PostgreSQL starter template

Simple Go/GraphQL/PostgreSQL template Purpose Have a good starting point for any project that needs a graphql, go, and postgres backend. It's a very l

A GraphQL complete example using Golang And PostgreSQL

GraphQL with Golang A GraphQL complete example using Golang & PostgreSQL Installation Install the dependencies go get github.com/graphql-go/graphql go

This app is an attempt towards using go lang with graphql data fetch in react front end.

go_movies _A React js + GraphQL supported with backend in GoLang. This app is an attempt towards using go lang with graphql data fetch in react front

proof-of-concept minimal GraphQL service for LTV

LTV GraphQL Proof-of-Concept This is a barebones proof-of-concept of a possible GraphQL implementation that interacts with Core. It includes a few ver

Learn GraphQL with THE [email protected] SHINY COLORS.

faaaar Learn GraphQL with THE [email protected] SHINY COLORS. Getting Started The following is a simple example which get information about 20-year-old idols

A simple (yet effective) GraphQL to HTTP / REST router

ReGraphQL A simple (yet effective) GraphQL to REST / HTTP router. ReGraphQL helps you expose your GraphQL queries / mutations as REST / HTTP endpoints

Comments
  • Release for v0.3.5

    Release for v0.3.5

    This pull request is for the next release as v0.3.5 created by tagpr. Merging it will tag v0.3.5 to the merge commit and create a GitHub release.

    You can modify this branch "tagpr-from-v0.3.4" directly before merging if you want to change the next version number or other files for the release.

    How to change the next version as you like

    There are two ways to do it.

    • Version file
      • Edit and commit the version file specified in the .tagpr configuration file to describe the next version
      • If you want to use another version file, edit the configuration file.
    • Labels convention
      • Add labels to this pull request like "tagpr:minor" or "tagpr:major"
      • If no conventional labels are added, the patch version is incremented as is.

    What's Changed

    • Add a tagpr workflow of GitHub Actions by @tenntenn in https://github.com/gqlgo/gqlanalysis/pull/17
    • Fix dependencies handling by @tenntenn in https://github.com/gqlgo/gqlanalysis/pull/16

    Full Changelog: https://github.com/gqlgo/gqlanalysis/compare/v0.3.4...v0.3.5

    tagpr 
    opened by github-actions[bot] 0
  • Add CLI argument for introspection-header

    Add CLI argument for introspection-header

    Abstract

    認証を介さないと取得できないGraphQLスキーマが存在している。内部ではintrospection時にHTTP Headerを付与できるコードになっていたのでコマンドラインから引数で受け取れるようにする

    コマンドライン引数の形式は -introspeciton-header=key1:value1,key2:value2。最終的にはhttp.Header(=map[string][]string)として扱うが、introspectionでhttpを配列に渡したいことが思いつかないのでkey:valueは1:1にしてしまっている。理由は1:1じゃない場合のmapを引数で受け取る場合の適切なフォーマットが思い浮かばなかったのが大きな要因。PRに書いてあるような具合ならわかりやすいと思っている

    How

    flag パッケージの Value インタフェースに準拠すればデフォルト以外の型も扱えるのでその方式をとっている。"key1:value1"が引数れあれば実態は map[string][]string{ "key1": []string{"value1"} } になる

    opened by bannzai 0
Releases(v0.3.5)
Owner
GraphQL go library and tools
null
Tools to write high performance GraphQL applications using Go/Golang.

graphql-go-tools Sponsors WunderGraph Are you looking for a GraphQL e2e data fetching solution? Supports frameworks like NextJS, type safety with gene

Jens Neuse 427 Dec 27, 2022
A collection of Go packages for creating robust GraphQL APIs

api-fu api-fu (noun) (informal) Mastery of APIs. ?? Packages The top level apifu package is an opinionated library that aims to make it as easy as pos

Chris 45 Dec 28, 2022
graphql parser + utilities

graphql utilities for dealing with GraphQL queries in Go. This package focuses on actually creating GraphQL servers and expects you to describe your s

Travis Cline 58 Dec 20, 2022
GraphQL server with a focus on ease of use

graphql-go The goal of this project is to provide full support of the GraphQL draft specification with a set of idiomatic, easy to use Go packages. Wh

null 4.3k Dec 31, 2022
An implementation of GraphQL for Go / Golang

graphql An implementation of GraphQL in Go. Follows the official reference implementation graphql-js. Supports: queries, mutations & subscriptions. Do

null 9k Dec 26, 2022
Convert Golang Struct To GraphQL Object On The Fly

Straf Convert Golang Struct To GraphQL Object On The Fly Easily Create GraphQL Schemas Example Converting struct to GraphQL Object type UserExtra stru

Roshan Mehta 34 Oct 26, 2022
GraphQL server with a focus on ease of use

graphql-go The goal of this project is to provide full support of the GraphQL draft specification with a set of idiomatic, easy to use Go packages. Wh

null 4.3k Dec 25, 2022
GQLEngine is the best productive solution for implementing a GraphQL server 🚀

GQLEngine is the best productive solution for implementing a graphql server for highest formance examples starwars: https://github.com/gqlengine/starw

null 88 Apr 24, 2022
⚡️ A Go framework for rapidly building powerful graphql services

Thunder is a Go framework for rapidly building powerful graphql servers. Thunder has support for schemas automatically generated from Go types, live q

null 1.6k Dec 24, 2022
go generate based graphql server library

gqlgen What is gqlgen? gqlgen is a Go library for building GraphQL servers without any fuss. gqlgen is based on a Schema first approach — You get to D

99designs 8.5k Dec 31, 2022