Skip to content

Commit

Permalink
feat(backend): add generated Go client (#57)
Browse files Browse the repository at this point in the history
Signed-off-by: David van der Spek <[email protected]>
  • Loading branch information
davidspek authored Jun 26, 2023
1 parent 498d767 commit d5d9daf
Show file tree
Hide file tree
Showing 11 changed files with 14,290 additions and 53 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ run:
generate:
go run github.com/99designs/gqlgen generate

generate-client:
go run github.com/Yamashou/gqlgenc

generate-db:
go generate ./ent

Expand Down
13,191 changes: 13,191 additions & 0 deletions generated/client/client.go

Large diffs are not rendered by default.

470 changes: 470 additions & 0 deletions generated/client/models_gen.go

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ module github.com/pluralsh/trace-shield
go 1.19

require (
github.com/99designs/gqlgen v0.17.24
github.com/99designs/gqlgen v0.17.34
github.com/Yamashou/gqlgenc v0.14.0
github.com/go-chi/chi/v5 v5.0.8
github.com/go-logr/logr v1.2.3
github.com/ory/herodot v0.10.1
github.com/ory/keto/proto v0.11.1-alpha.0
github.com/ory/kratos-client-go v0.11.1
github.com/pluralsh/trace-shield-controller v0.0.0-20230404170210-f84361cc9dee
github.com/rs/cors v1.8.3
github.com/vektah/gqlparser/v2 v2.5.1
github.com/vektah/gqlparser/v2 v2.5.5
sigs.k8s.io/controller-runtime v0.14.4
)

Expand Down Expand Up @@ -56,6 +57,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.12.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -77,7 +79,7 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/goveralls v0.0.6 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
Expand Down Expand Up @@ -127,8 +129,8 @@ require (
go.opentelemetry.io/otel/trace v1.11.1 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
gocloud.dev v0.20.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.114.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
Expand Down Expand Up @@ -158,7 +160,6 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -179,19 +180,19 @@ require (
github.com/prometheus/procfs v0.9.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/urfave/cli/v2 v2.8.1 // indirect
github.com/urfave/cli/v2 v2.25.7 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/oauth2 v0.6.0
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/term v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.8.0 // indirect
golang.org/x/tools v0.10.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/grpc v1.54.0
Expand Down
71 changes: 31 additions & 40 deletions go.sum

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions gqlgenc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
generate:
clientV2: true # Generate a Client that provides a new signature
clientInterfaceName: "TraceShieldGraphQLClient" # Determine the name of the generated client interface
model:
package: gqlclient
filename: generated/client/models_gen.go # https://github.com/99designs/gqlgen/tree/master/plugin/modelgen
client:
package: gqlclient
filename: generated/client/client.go # Where should any generated client go?
models:
Int:
model: github.com/99designs/gqlgen/graphql.Int64
Date:
model: github.com/99designs/gqlgen/graphql.Time
ID:
model: github.com/99designs/gqlgen/graphql.ID
String:
model: github.com/99designs/gqlgen/graphql.String
Float:
model:
- github.com/99designs/gqlgen/graphql.Float
Duration:
model:
- github.com/pluralsh/trace-shield/graph/custom.Duration
FloatMap:
model:
- github.com/pluralsh/trace-shield/graph/custom.FloatMap
ForwardingRuleMap:
model:
- github.com/pluralsh/trace-shield/graph/custom.ForwardingRuleMap
schema:
- "graph/*.graphqls" # Where are all the schema files located?
query:
- "query/*.graphqls" # Where are all the query files located?
24 changes: 24 additions & 0 deletions query/group.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
query ListGroups { # TODO: we should also support getting a single group
listGroups {
...GroupFragment
}
}

mutation UpdateGroup($name: String!, $members: [String!]) { # TODO: for consistency we should probably split create and update mutations
group(name: $name, members: $members) {
...GroupFragment
}
}

mutation DeleteGroup($name: String!) {
deleteGroup(name: $name) {
name
}
}

fragment GroupFragment on Group {
name
members {
...UserFragmentNoGroups
}
}
227 changes: 227 additions & 0 deletions query/oauth2client.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
query ListOAuth2Clients() {
listOAuth2Clients {
...OAuth2ClientFragment
}
}

query GetOAuth2Client($clientId: ID!) {
getOAuth2Client(clientId: $clientId) {
...OAuth2ClientFragment
}
}

mutation DeleteOAuth2Client($clientId: String!) {
deleteOAuth2Client(clientId: $clientId) {
clientId
}
}

mutation UpdateOAuth2Client(
$allowedCorsOrigins: [String!]
$audience:[String!]
$authorizationCodeGrantAccessTokenLifespan: String
$authorizationCodeGrantIdTokenLifespan: String
$authorizationCodeGrantRefreshTokenLifespan: String
$backChannelLogoutSessionRequired: Boolean
$backChannelLogoutUri: String
$clientCredentialsGrantAccessTokenLifespan: String
$clientId: String!
$clientName: String
$clientSecret: String
$ClientSecretExpiresAt: Int
$clientUri: String
$contacts: [String!]
$frontchannelLogoutSessionRequired: Boolean
$frontchannelLogoutUri: String
$grantTypes: [String!]
$implicitGrantAccessTokenLifespan: String
$implicitGrantIdTokenLifespan: String
$jwks: Map
$jwksUri: String
$jwtBearerGrantAccessTokenLifespan: String
$logoUri: String
$metadata: Map
$policyUri: String
$postLogoutRedirectUris: [String!]
$redirectUris: [String!]
$responseTypes: [String!]
$scope: String
$sectorIdentifierUri: String
$subjectType: String
$tokenEndpointAuthMethod: String
$tokenEndpointAuthSigningAlgorithm: String
$tosUri: String
$userinfoSignedResponseAlgorithm: String
$loginBindings: LoginBindingsInput
) {
updateOAuth2Client(
allowedCorsOrigins: $allowedCorsOrigins
audience: $audience
authorizationCodeGrantAccessTokenLifespan: $authorizationCodeGrantAccessTokenLifespan
authorizationCodeGrantIdTokenLifespan: $authorizationCodeGrantIdTokenLifespan
authorizationCodeGrantRefreshTokenLifespan: $authorizationCodeGrantRefreshTokenLifespan
backChannelLogoutSessionRequired: $backChannelLogoutSessionRequired
backChannelLogoutUri: $backChannelLogoutUri
clientCredentialsGrantAccessTokenLifespan: $clientCredentialsGrantAccessTokenLifespan
clientId: $clientId
clientName: $clientName
clientSecret: $clientSecret
ClientSecretExpiresAt: $ClientSecretExpiresAt
clientUri: $clientUri
contacts: $contacts
frontchannelLogoutSessionRequired: $frontchannelLogoutSessionRequired
frontchannelLogoutUri: $frontchannelLogoutUri
grantTypes: $grantTypes
implicitGrantAccessTokenLifespan: $implicitGrantAccessTokenLifespan
implicitGrantIdTokenLifespan: $implicitGrantIdTokenLifespan
jwks: $jwks
jwksUri: $jwksUri
jwtBearerGrantAccessTokenLifespan: $jwtBearerGrantAccessTokenLifespan
logoUri: $logoUri
metadata: $metadata
policyUri: $policyUri
postLogoutRedirectUris: $postLogoutRedirectUris
redirectUris: $redirectUris
responseTypes: $responseTypes
scope: $scope
sectorIdentifierUri: $sectorIdentifierUri
subjectType: $subjectType
tokenEndpointAuthMethod: $tokenEndpointAuthMethod
tokenEndpointAuthSigningAlgorithm: $tokenEndpointAuthSigningAlgorithm
tosUri: $tosUri
userinfoSignedResponseAlgorithm: $userinfoSignedResponseAlgorithm
loginBindings: $loginBindings
) {
...OAuth2ClientFragment
}
}

mutation CreateOAuth2Client(
$allowedCorsOrigins: [String!]
$audience:[String!]
$authorizationCodeGrantAccessTokenLifespan: String
$authorizationCodeGrantIdTokenLifespan: String
$authorizationCodeGrantRefreshTokenLifespan: String
$backChannelLogoutSessionRequired: Boolean
$backChannelLogoutUri: String
$clientCredentialsGrantAccessTokenLifespan: String
$clientName: String
$clientSecret: String
$ClientSecretExpiresAt: Int
$clientUri: String
$contacts: [String!]
$frontchannelLogoutSessionRequired: Boolean
$frontchannelLogoutUri: String
$grantTypes: [String!]
$implicitGrantAccessTokenLifespan: String
$implicitGrantIdTokenLifespan: String
$jwks: Map
$jwksUri: String
$jwtBearerGrantAccessTokenLifespan: String
$logoUri: String
$metadata: Map
$policyUri: String
$postLogoutRedirectUris: [String!]
$redirectUris: [String!]
$responseTypes: [String!]
$scope: String
$sectorIdentifierUri: String
$subjectType: String
$tokenEndpointAuthMethod: String
$tokenEndpointAuthSigningAlgorithm: String
$tosUri: String
$userinfoSignedResponseAlgorithm: String
$loginBindings: LoginBindingsInput
) {
createOAuth2Client(
allowedCorsOrigins: $allowedCorsOrigins
audience: $audience
authorizationCodeGrantAccessTokenLifespan: $authorizationCodeGrantAccessTokenLifespan
authorizationCodeGrantIdTokenLifespan: $authorizationCodeGrantIdTokenLifespan
authorizationCodeGrantRefreshTokenLifespan: $authorizationCodeGrantRefreshTokenLifespan
backChannelLogoutSessionRequired: $backChannelLogoutSessionRequired
backChannelLogoutUri: $backChannelLogoutUri
clientCredentialsGrantAccessTokenLifespan: $clientCredentialsGrantAccessTokenLifespan
clientName: $clientName
clientSecret: $clientSecret
ClientSecretExpiresAt: $ClientSecretExpiresAt
clientUri: $clientUri
contacts: $contacts
frontchannelLogoutSessionRequired: $frontchannelLogoutSessionRequired
frontchannelLogoutUri: $frontchannelLogoutUri
grantTypes: $grantTypes
implicitGrantAccessTokenLifespan: $implicitGrantAccessTokenLifespan
implicitGrantIdTokenLifespan: $implicitGrantIdTokenLifespan
jwks: $jwks
jwksUri: $jwksUri
jwtBearerGrantAccessTokenLifespan: $jwtBearerGrantAccessTokenLifespan
logoUri: $logoUri
metadata: $metadata
policyUri: $policyUri
postLogoutRedirectUris: $postLogoutRedirectUris
redirectUris: $redirectUris
responseTypes: $responseTypes
scope: $scope
sectorIdentifierUri: $sectorIdentifierUri
subjectType: $subjectType
tokenEndpointAuthMethod: $tokenEndpointAuthMethod
tokenEndpointAuthSigningAlgorithm: $tokenEndpointAuthSigningAlgorithm
tosUri: $tosUri
userinfoSignedResponseAlgorithm: $userinfoSignedResponseAlgorithm
loginBindings: $loginBindings
) {
...OAuth2ClientFragment
}
}

fragment OAuth2ClientFragment on OAuth2Client {
allowedCorsOrigins
audience
authorizationCodeGrantAccessTokenLifespan
authorizationCodeGrantIdTokenLifespan
authorizationCodeGrantRefreshTokenLifespan
backChannelLogoutUri
clientCredentialsGrantAccessTokenLifespan
clientId
clientName
clientSecret
ClientSecretExpiresAt
clientUri
contacts
createdAt
frontchannelLogoutSessionRequired
frontchannelLogoutUri
grantTypes
implicitGrantAccessTokenLifespan
implicitGrantIdTokenLifespan
jwks
jwksUri
jwtBearerGrantAccessTokenLifespan
logoUri
metadata
owner
policyUri
postLogoutRedirectUris
redirectUris
responseTypes
scope
sectorIdentifierUri
subjectType
tokenEndpointAuthMethod
tokenEndpointAuthSigningAlgorithm
tosUri
updatedAt
userinfoSignedResponseAlgorithm
organization{
name
}
loginBindings{
users{
id
email
}
groups{
name
}
}
}
Loading

0 comments on commit d5d9daf

Please sign in to comment.