Skip to content

Commit b6272fe

Browse files
Fix order of has filter generation
1 parent aec648e commit b6272fe

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

graphql/schema/gqlschema.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,12 +1049,11 @@ func completeSchema(
10491049
}
10501050

10511051
// types and inputs needed for query and search
1052-
// Don't generate filter/orderable/hasFilter types for @extends types in Apollo service query
1052+
// Don't generate filter/orderable types for @extends types in Apollo service query
10531053
// to avoid conflicts when composing federated schemas
10541054
if !(apolloServiceQuery && hasExtends(defn)) {
10551055
addFilterType(sch, defn, providesTypeMap)
10561056
addTypeOrderable(sch, defn, providesTypeMap)
1057-
addTypeHasFilter(sch, defn, providesTypeMap)
10581057
}
10591058
addFieldFilters(sch, defn, providesTypeMap, apolloServiceQuery)
10601059
if !(apolloServiceQuery && hasExtends(defn)) {
@@ -1065,6 +1064,11 @@ func completeSchema(
10651064
if !(apolloServiceQuery && hasExtends(defn)) {
10661065
addQueries(sch, defn, providesTypeMap, params)
10671066
}
1067+
// addTypeHasFilter must come after addQueries so that fields added by queries (like vector_distance)
1068+
// are included in the HasFilter enum
1069+
if !(apolloServiceQuery && hasExtends(defn)) {
1070+
addTypeHasFilter(sch, defn, providesTypeMap)
1071+
}
10681072
// We need to call this at last as aggregateFields
10691073
// should not be part of HasFilter or UpdatePayloadType etc.
10701074
addAggregateFields(sch, defn, apolloServiceQuery)

graphql/schema/schemagen_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ func TestSchemaString(t *testing.T) {
8484
str2, err := os.ReadFile(outputFileName)
8585
require.NoError(t, err)
8686
if diff := cmp.Diff(string(str2), newSchemaStr); diff != "" {
87-
// fmt.Printf("Generated Schema (%s):\n%s\n", testFile.Name(), newSchemaStr)
8887
t.Errorf("schema mismatch - diff (-want +got):\n%s", diff)
8988
}
9089
})

0 commit comments

Comments
 (0)