Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experiment: graphql #1329

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions feature/feature.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Package feature implements feature flags for all the packages in the clair
// module.
//
// Any features referenced here should be considered experimental: that is,
// there's no guarantee around APIs, configuration, usability, forward
// compatibility, backwards compatibility, stability, etc.
package feature

// Environment variables currently examined for feature flags.
//
// These are subject to removal, addition, or reinterpretation at any time.
const (
// GraphQLFlag being set in the environment toggles on registering a
// GraphQL endpoint at "/matcher/api/v1/graphql".
GraphQLFlag = `CLAIR_FEATURE_GRAPHQL`
)
10 changes: 10 additions & 0 deletions feature/graphql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package feature

import "os"

// GraphQL is true if the relevant feature flag was set in the environment.
var GraphQL bool

func init() {
_, GraphQL = os.LookupEnv(GraphQLFlag)
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/quay/clair/v4
go 1.15

require (
github.com/99designs/gqlgen v0.13.0
github.com/docker/docker v1.13.1 // indirect
github.com/go-stomp/stomp v2.0.6+incompatible
github.com/golang/mock v1.5.0 // indirect
Expand All @@ -24,6 +25,7 @@ require (
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80
github.com/ugorji/go/codec v1.2.4
github.com/urfave/cli/v2 v2.3.0
github.com/vektah/gqlparser/v2 v2.1.0
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.16.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.16.0
go.opentelemetry.io/otel v0.16.0
Expand Down
37 changes: 37 additions & 0 deletions go.sum

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions graphql/gqlgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema:
- graph/*.graphqls

# Where should the generated server code go?
exec:
filename: graph/generated/generated.go
package: generated

# Uncomment to enable federation
# federation:
# filename: graph/generated/federation.go
# package: generated

# Where should any generated models go?
model:
filename: graph/model/models_gen.go
package: model

# Where should the resolver implementations go?
resolver:
layout: follow-schema
dir: graph
package: graph

# Optional: turn on use `gqlgen:"fieldName"` tags in your models
# struct_tag: json

# Optional: turn on to use []Thing instead of []*Thing
omit_slice_element_pointers: true

# Optional: set to speed up generation time by not performing a final validation pass.
# skip_validation: true

# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
- "github.com/quay/clair/v4/graphql/graph/model"

# This section declares type mapping between the GraphQL and go type systems
#
# The first line in each type will be used as defaults for resolver arguments and
# modelgen, the others will be allowed when binding to fields. Configure them to
# your liking
models:
ID:
model:
- github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Int:
model:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Digest:
model: github.com/quay/clair/v4/graphql/graph/model.Digest
JSONObject:
model: github.com/quay/clair/v4/graphql/graph/model.JSONObject
Loading