Skip to content

Commit

Permalink
Merge pull request #118 from avalanche123/schema-hardening
Browse files Browse the repository at this point in the history
schema hardening
  • Loading branch information
tnthornton authored Jul 13, 2023
2 parents 2ff8300 + d9004b4 commit 91d0525
Show file tree
Hide file tree
Showing 47 changed files with 3,609 additions and 2,574 deletions.
1 change: 1 addition & 0 deletions .graphqlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
schema: schema/*.gql
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/upbound/xgql
go 1.20

require (
github.com/99designs/gqlgen v0.17.13
github.com/99designs/gqlgen v0.17.34
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.13.1
github.com/crossplane/crossplane v1.2.1
github.com/crossplane/crossplane-runtime v0.19.2
Expand All @@ -15,7 +15,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.15.0
github.com/vektah/gqlparser/v2 v2.4.7
github.com/vektah/gqlparser/v2 v2.5.4
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.40.0
go.opentelemetry.io/otel v1.14.0
Expand Down Expand Up @@ -67,13 +67,13 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.8.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand All @@ -84,22 +84,22 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/afero v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/urfave/cli/v2 v2.11.1 // indirect
github.com/urfave/cli/v2 v2.25.5 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.7.0 // indirect
golang.org/x/tools v0.9.3 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/api v0.118.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
65 changes: 24 additions & 41 deletions go.sum

Large diffs are not rendered by default.

35 changes: 34 additions & 1 deletion gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@ model:
filename: internal/graph/model/generated.go
package: model

# Use []Thing instead of []*Thing
# gqlgen by defaut generates getter methods for interfaces and types that
# implement it.
omit_getters: true

# The following three stanzas configure resolver and model code to use structs
# instead of struct pointers for all required fields. This enforces schema
# constraints at compile time, and makes for a better experience in editor
# tooling.

# Use []Thing instead of []*Thing.
omit_slice_element_pointers: true
# Use type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing }.
struct_fields_always_pointers: false
# Make generated resolvers return Thing instead of *Thing.
# Use type Resolver interface { Resolve(...) (ValueA, error) } instead of
# { Resolve(...) (*ValueA, error) }
resolvers_always_return_pointers: false

# 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.
Expand All @@ -40,3 +55,21 @@ models:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
# Below we define additional fields to be added to the generated models.
# These fields are not part of the GraphQL schema, but are used to resolve
# fields that are part of the schema.
ProviderRevisionStatus:
extraFields:
# Used to resolve ProviderRevisionStatus.objects field.
ObjectRefs:
type: "[]github.com/crossplane/crossplane-runtime/apis/common/v1.TypedReference"
ConfigurationRevisionStatus:
extraFields:
# Used to resolve ConfigurationRevisionStatus.objects field.
ObjectRefs:
type: "[]github.com/crossplane/crossplane-runtime/apis/common/v1.TypedReference"
Event:
extraFields:
# Used to resolve Event.involvedObject field.
InvolvedObjectRef:
type: "k8s.io/api/core/v1.ObjectReference"
Loading

0 comments on commit 91d0525

Please sign in to comment.