Skip to content

Commit

Permalink
chore: Update graphql-go (#1422)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves #

## Description

This PR updates to the latest version of graphql-go. The update changed
the formatting of `object.Name()` which caused issued with our gql
parsing and filtering.

Thanks to @AndrewSisley for sorting our the gql issues.
  • Loading branch information
fredcarle committed May 4, 2023
1 parent 574a247 commit 18221b9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/go-errors/errors v1.4.2
github.com/gofrs/uuid/v5 v5.0.0
github.com/gogo/protobuf v1.3.2
github.com/graphql-go/graphql v0.8.0
github.com/graphql-go/graphql v0.8.1
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/iancoleman/strcase v0.2.0
github.com/ipfs/boxo v0.8.1
Expand Down Expand Up @@ -198,6 +198,6 @@ require (

// SourceNetwork fork og graphql-go
replace (
github.com/graphql-go/graphql => github.com/sourcenetwork/graphql-go v0.7.10-0.20221119101706-0f80a1725ab7
github.com/graphql-go/graphql => github.com/sourcenetwork/graphql-go v0.7.10-0.20230427183824-8343db738835
github.com/textileio/go-libp2p-pubsub-rpc => github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.0-20230209220544-e16d5e34c4fc
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,8 @@ github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:Udh
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.0-20230209220544-e16d5e34c4fc h1:ZrkklfmN27eENGFmzblEcs35PJ02hmlNgMHE8XJqFAo=
github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.0-20230209220544-e16d5e34c4fc/go.mod h1:3rOV6TxePSwADKpnwXBKpTjAA4QyjZBus13xc6VCtSw=
github.com/sourcenetwork/graphql-go v0.7.10-0.20221119101706-0f80a1725ab7 h1:9v7Ld9hS60HAcw/ID/yierzEjtAwkenr/5i6rGSmiXI=
github.com/sourcenetwork/graphql-go v0.7.10-0.20221119101706-0f80a1725ab7/go.mod h1:3Ty9EMes+aoxl8xS0CsuCGQZ4JEsOlC5yqQDLOKoBRw=
github.com/sourcenetwork/graphql-go v0.7.10-0.20230427183824-8343db738835 h1:P/FCdfRdvRWhNR6DPLlMVZBkOUaG7aVxr0e9CNeukW4=
github.com/sourcenetwork/graphql-go v0.7.10-0.20230427183824-8343db738835/go.mod h1:3Ty9EMes+aoxl8xS0CsuCGQZ4JEsOlC5yqQDLOKoBRw=
github.com/sourcenetwork/immutable v0.2.2 h1:Qjz1cCWhgjS6YkUTWb53R22wSYMEZhzBghhEzWaFi8c=
github.com/sourcenetwork/immutable v0.2.2/go.mod h1:4jpxObkIQw8pvlIRm4ndZqf3pH9ZjYEw/UYI6GZDJww=
github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0=
Expand Down
17 changes: 11 additions & 6 deletions request/graphql/schema/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,11 @@ func (g *Generator) genCountFieldConfig(obj *gql.Object) (gql.Field, error) {

for _, field := range obj.Fields() {
// Only lists can be counted
if _, isList := field.Type.(*gql.List); !isList {
listType, isList := field.Type.(*gql.List)
if !isList {
continue
}

inputObjectName := genObjectCountName(field.Type.Name())
inputObjectName := genObjectCountName(listType.OfType.Name())
countableObject, isSubTypeCountableCollection := g.manager.schema.TypeMap()[inputObjectName]
if !isSubTypeCountableCollection {
inputObjectName = genNumericInlineArrayCountName(obj.Name(), field.Name)
Expand Down Expand Up @@ -618,7 +618,7 @@ func (g *Generator) genSumFieldConfig(obj *gql.Object) (gql.Field, error) {
if isNumericArray(listType) {
inputObjectName = genNumericInlineArraySelectorName(obj.Name(), field.Name)
} else {
inputObjectName = genNumericObjectSelectorName(field.Type.Name())
inputObjectName = genNumericObjectSelectorName(listType.OfType.Name())
}

subSumType, isSubTypeSumable := g.manager.schema.TypeMap()[inputObjectName]
Expand Down Expand Up @@ -658,7 +658,7 @@ func (g *Generator) genAverageFieldConfig(obj *gql.Object) (gql.Field, error) {
if isNumericArray(listType) {
inputObjectName = genNumericInlineArraySelectorName(obj.Name(), field.Name)
} else {
inputObjectName = genNumericObjectSelectorName(field.Type.Name())
inputObjectName = genNumericObjectSelectorName(listType.OfType.Name())
}

subAverageType, isSubTypeAveragable := g.manager.schema.TypeMap()[inputObjectName]
Expand Down Expand Up @@ -1025,7 +1025,12 @@ func (g *Generator) genTypeFilterArgInput(obj *gql.Object) *gql.InputObject {
Type: operatorType,
}
} else { // objects (relations)
filterType, isFilterable := g.manager.schema.TypeMap()[genTypeName(field.Type, "FilterArg")]
fieldType := field.Type
if l, isList := field.Type.(*gql.List); isList {
// We want the FilterArg for the object, not the list of objects.
fieldType = l.OfType
}
filterType, isFilterable := g.manager.schema.TypeMap()[genTypeName(fieldType, "FilterArg")]
if !isFilterable {
filterType = &gql.InputObjectField{}
}
Expand Down

0 comments on commit 18221b9

Please sign in to comment.