diff --git a/graphql/bench/schema.graphql b/graphql/bench/schema.graphql index 91ddba4f481..62b03991d09 100644 --- a/graphql/bench/schema.graphql +++ b/graphql/bench/schema.graphql @@ -1,14 +1,14 @@ type Country { cid: ID! id: String! @id - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) cities: [City] } type City { cid: ID! id: String! @id - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) country: Country! @hasInverse(field: cities) restaurants: [RestaurantAddress] @hasInverse(field: city) } @@ -30,12 +30,12 @@ type RestaurantAddress implements Location { type Restaurant { id: ID! xid: String! @id - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) pic: String addr: RestaurantAddress rating: Float costFor2: Float - currency: String @search(by: [hash]) + currency: String @search(by: ["hash"]) cuisines: [Cuisine] dishes: [Dish] @hasInverse(field: servedBy) createdAt: DateTime @@ -47,14 +47,14 @@ type Cuisine { name: String! @id restaurants: [Restaurant] @hasInverse(field: cuisines) dishes: [Dish] @hasInverse(field: cuisine) - type: String! @search(by: [hash]) + type: String! @search(by: ["hash"]) public: Boolean @search } type Dish { id: ID! - name: String! @search(by: [term]) - type: String! @search(by: [hash]) + name: String! @search(by: ["term"]) + type: String! @search(by: ["hash"]) pic: String price: Float description: String @@ -65,8 +65,8 @@ type Dish { type Owner { username: String! @id - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) hasRestaurants: [Restaurant] @hasInverse(field: owner) } -# Dgraph.Authorization {"VerificationKey":"secretkey","Header":"X-Test-Auth","Namespace":"https://xyz.io/jwt/claims","Algo":"HS256","Audience":["aud1","63do0q16n6ebjgkumu05kkeian","aud5"]} \ No newline at end of file +# Dgraph.Authorization {"VerificationKey":"secretkey","Header":"X-Test-Auth","Namespace":"https://xyz.io/jwt/claims","Algo":"HS256","Audience":["aud1","63do0q16n6ebjgkumu05kkeian","aud5"]} diff --git a/graphql/bench/schema_auth.graphql b/graphql/bench/schema_auth.graphql index 245bbc5f7dd..0753cf28dbc 100644 --- a/graphql/bench/schema_auth.graphql +++ b/graphql/bench/schema_auth.graphql @@ -21,7 +21,7 @@ type Country @auth( """ }) { cid: ID! id: String! @id - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) cities: [City] } @@ -46,7 +46,7 @@ type City @auth( """ }) { cid: ID! id: String! @id - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) country: Country! @hasInverse(field: cities) restaurants: [RestaurantAddress] @hasInverse(field: city) } @@ -128,12 +128,12 @@ type Restaurant @auth( ) { id: ID! xid: String! @id - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) pic: String addr: RestaurantAddress rating: Float costFor2: Float - currency: String @search(by: [hash]) + currency: String @search(by: ["hash"]) cuisines: [Cuisine] dishes: [Dish] @hasInverse(field: servedBy) createdAt: DateTime @@ -197,7 +197,7 @@ type Cuisine @auth( name: String! @id restaurants: [Restaurant] @hasInverse(field: cuisines) dishes: [Dish] @hasInverse(field: cuisine) - type: String! @search(by: [hash]) + type: String! @search(by: ["hash"]) public: Boolean @search } @@ -225,8 +225,8 @@ type Dish @auth( update: { rule: "{$Role: { eq: \"ADMIN\" }}"}, ){ id: ID! - name: String! @search(by: [term]) - type: String! @search(by: [hash]) + name: String! @search(by: ["term"]) + type: String! @search(by: ["hash"]) pic: String price: Float description: String @@ -244,8 +244,8 @@ type Owner @auth( } }""" }) { username: String! @id - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) hasRestaurants: [Restaurant] @hasInverse(field: owner) } -# Dgraph.Authorization {"VerificationKey":"secretkey","Header":"X-Test-Auth","Namespace":"https://xyz.io/jwt/claims","Algo":"HS256","Audience":["aud1","63do0q16n6ebjgkumu05kkeian","aud5"]} \ No newline at end of file +# Dgraph.Authorization {"VerificationKey":"secretkey","Header":"X-Test-Auth","Namespace":"https://xyz.io/jwt/claims","Algo":"HS256","Audience":["aud1","63do0q16n6ebjgkumu05kkeian","aud5"]} diff --git a/graphql/e2e/auth/schema.graphql b/graphql/e2e/auth/schema.graphql index a9542def0a7..d734a36af9e 100644 --- a/graphql/e2e/auth/schema.graphql +++ b/graphql/e2e/auth/schema.graphql @@ -33,7 +33,7 @@ type Tweets @auth ( update: { rule: "{$USER: { eq: \"foo\" } }"} ){ id: String! @id - text: String! @search(by: [fulltext]) + text: String! @search(by: ["fulltext"]) user: User timestamp: DateTime! @search score: Int @search @@ -71,8 +71,8 @@ type UserSecret @auth( """} ){ id: ID! - aSecret: String @search(by: [term]) - ownedBy: String @search(by: [hash]) + aSecret: String @search(by: ["term"]) + ownedBy: String @search(by: ["hash"]) } type Region @auth( @@ -83,7 +83,7 @@ type Region @auth( """} ){ id: ID! - name: String @search(by: [hash]) + name: String @search(by: ["hash"]) global: Boolean @search users: [User] } @@ -207,7 +207,7 @@ type Movie @auth( ]} ) { id: ID! - content: String @search(by: [hash]) + content: String @search(by: ["hash"]) hidden: Boolean @search regionsAvailable: [Region] reviews: [Review] @@ -354,7 +354,7 @@ type Project @secret(field: "pwd") @auth( ]} ) { projID: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) roles: [Role] columns: [Column] @hasInverse(field: inProject) random: String @@ -478,7 +478,7 @@ type Column @auth( ) { colID: ID! inProject: Project! # @auth(update: { rule: "DENY" }) - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) tickets: [Ticket] @hasInverse(field: onColumn) random: String } @@ -543,7 +543,7 @@ type Ticket @auth( ){ id: ID! onColumn: Column! - title: String! @search(by: [term]) + title: String! @search(by: ["term"]) assignedTo: [User!] } @@ -561,14 +561,14 @@ query($USER: String!) { } """},{ rule: "{$ROLE: { eq: \"ADMIN\" }}"}]}) { id: ID! - email: String! @dgraph(pred: "IOw80vnV") @search(by: [hash]) + email: String! @dgraph(pred: "IOw80vnV") @search(by: ["hash"]) } type Contact @auth( query: { rule: "{$ContactRole: { eq: \"ADMINISTRATOR\"}}" } ) { id: ID! - nickName: String @search(by: [exact, term, fulltext, regexp]) + nickName: String @search(by: ["exact", "term", "fulltext", "regexp"]) adminTasks: [AdminTask] @hasInverse(field: forContact) tasks: [Task] @hasInverse(field: forContact) } @@ -577,14 +577,14 @@ type AdminTask @auth( query: { rule: "{$TaskRole: { eq: \"ADMINISTRATOR\"}}" } ) { id: ID! - name: String @search(by: [exact, term, fulltext, regexp]) + name: String @search(by: ["exact", "term", "fulltext", "regexp"]) occurrences: [TaskOccurrence] @hasInverse(field: adminTask) forContact: Contact @hasInverse(field: adminTasks) } type Task { id: ID! - name: String @search(by: [exact, term, fulltext, regexp]) + name: String @search(by: ["exact", "term", "fulltext", "regexp"]) occurrences: [TaskOccurrence] @hasInverse(field: task) forContact: Contact @hasInverse(field: tasks) } @@ -608,12 +608,12 @@ type TaskOccurrence @auth( task: Task @hasInverse(field: occurrences) adminTask: AdminTask @hasInverse(field: occurrences) isPublic: Boolean @search - role: String @search(by: [exact, term, fulltext, regexp]) + role: String @search(by: ["exact", "term", "fulltext", "regexp"]) } type Author { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) posts: [Post] @hasInverse(field: author) } @@ -653,7 +653,7 @@ interface Post @secret(field: "pwd") @auth( }""" } ){ id: ID! - text: String! @search(by: [exact]) + text: String! @search(by: ["exact"]) topic: String datePublished: DateTime @search author: Author! @@ -725,7 +725,7 @@ type Answer implements Post { interface A { id: ID! - fieldA: String @search(by: [exact]) + fieldA: String @search(by: ["exact"]) random: String } @@ -788,7 +788,7 @@ type Mission @key(fields: "id") @auth( ){ id: String! @id crew: [Astronaut] - supervisorName: String @search(by: [exact]) + supervisorName: String @search(by: ["exact"]) designation: String! startDate: String endDate: String @@ -812,7 +812,7 @@ interface Vehicle @auth( ] } ){ - owner: String! @search(by: [exact]) + owner: String! @search(by: ["exact"]) } type Car implements Vehicle { @@ -830,7 +830,7 @@ type Country @auth( """} ) { id: String! @id name: String! - ownedBy: String @search(by: [hash]) + ownedBy: String @search(by: ["hash"]) states: [State] @hasInverse(field: country) } @@ -844,7 +844,7 @@ type State @auth( """} ) { code: String! @id name: String! - ownedBy: String @search(by: [hash]) + ownedBy: String @search(by: ["hash"]) country: Country } diff --git a/graphql/e2e/common/query.go b/graphql/e2e/common/query.go index 5bb4c1136bc..4c26375132a 100644 --- a/graphql/e2e/common/query.go +++ b/graphql/e2e/common/query.go @@ -1285,7 +1285,7 @@ func stringExactFilters(t *testing.T) { func scalarListFilters(t *testing.T) { - // tags is a list of strings with @search(by: exact). So all the filters + // tags is a list of strings with @search(by: "exact"). So all the filters // lt, le, ... mean "is there something in the list that's lt 'Dgraph'", etc. cases := map[string]struct { diff --git a/graphql/e2e/custom_logic/custom_logic_test.go b/graphql/e2e/custom_logic/custom_logic_test.go index e0e4861c2b8..8601228c01a 100644 --- a/graphql/e2e/custom_logic/custom_logic_test.go +++ b/graphql/e2e/custom_logic/custom_logic_test.go @@ -1067,7 +1067,7 @@ func TestCustomFieldsShouldPassBody(t *testing.T) { schema := ` type User { - id: String! @id @search(by: [hash, regexp]) + id: String! @id @search(by: ["hash", "regexp"]) address:String name: String @custom( @@ -2573,7 +2573,7 @@ func TestCustomDQL(t *testing.T) { } type Tweets implements Node { id: ID! - text: String! @search(by: [fulltext, exact]) + text: String! @search(by: ["fulltext", "exact"]) user: User timestamp: DateTime! @search } @@ -2864,7 +2864,7 @@ func TestCustomFieldsWithRestError(t *testing.T) { } type User { - id: String! @id @search(by: [hash, regexp]) + id: String! @id @search(by: ["hash", "regexp"]) name: String @custom( http: { diff --git a/graphql/e2e/directives/schema.graphql b/graphql/e2e/directives/schema.graphql index f7e6718608b..7c732eb9213 100644 --- a/graphql/e2e/directives/schema.graphql +++ b/graphql/e2e/directives/schema.graphql @@ -3,7 +3,7 @@ type Hotel { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) location: Point @search area: Polygon @search branches: MultiPolygon @search @@ -197,7 +197,7 @@ type Comment1 { } type post1{ id: ID - title: String! @id @search(by: [regexp]) + title: String! @id @search(by: ["regexp"]) numLikes: Int64 @search commentsByMonth: [Int] likesByMonth: [Int64] @@ -213,13 +213,13 @@ type Person1 { type Person { id: ID! - name: String! @search(by: [hash]) - nameHi: String @dgraph(pred:"Person.name@hi") @search(by: [hash]) - nameZh: String @dgraph(pred:"Person.name@zh") @search(by: [hash]) + name: String! @search(by: ["hash"]) + nameHi: String @dgraph(pred:"Person.name@hi") @search(by: ["hash"]) + nameZh: String @dgraph(pred:"Person.name@zh") @search(by: ["hash"]) nameHiZh: String @dgraph(pred:"Person.name@hi:zh") nameZhHi: String @dgraph(pred:"Person.name@zh:hi") nameHi_Zh_Untag: String @dgraph(pred:"Person.name@hi:zh:.") - name_Untag_AnyLang: String @dgraph(pred:"Person.name@.") @search(by: [hash]) + name_Untag_AnyLang: String @dgraph(pred:"Person.name@.") @search(by: ["hash"]) professionEn: String @dgraph(pred:"Person.profession@en") } @@ -363,7 +363,7 @@ type Owner { type Project { id: String! @id owner: Owner! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) datasets: [Dataset!] @hasInverse(field: project) } @@ -371,11 +371,11 @@ type Dataset { id: String! @id owner: Owner! project: Project! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) } type author1{ - name:String! @id @search(by: [regexp]) + name:String! @id @search(by: ["regexp"]) posts:[post1] @hasInverse(field: author) } # multiple fields with @id directive @@ -423,4 +423,4 @@ type CricketTeam implements Team { type LibraryManager { name: String! @id manages: [LibraryMember] -} \ No newline at end of file +} diff --git a/graphql/e2e/normal/schema.graphql b/graphql/e2e/normal/schema.graphql index 396dea4318b..1f8a2d2956e 100644 --- a/graphql/e2e/normal/schema.graphql +++ b/graphql/e2e/normal/schema.graphql @@ -422,4 +422,4 @@ type CricketTeam implements Team { type LibraryManager { name: String! @id manages: [LibraryMember] -} \ No newline at end of file +} diff --git a/graphql/e2e/schema/apollo_service_response.graphql b/graphql/e2e/schema/apollo_service_response.graphql index 6a35c223770..bba4c35d600 100644 --- a/graphql/e2e/schema/apollo_service_response.graphql +++ b/graphql/e2e/schema/apollo_service_response.graphql @@ -83,6 +83,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -196,7 +197,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/e2e/schema/generatedSchema.graphql b/graphql/e2e/schema/generatedSchema.graphql index 9cdc8e0c8fd..70230c50d99 100644 --- a/graphql/e2e/schema/generatedSchema.graphql +++ b/graphql/e2e/schema/generatedSchema.graphql @@ -64,6 +64,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -177,7 +178,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/e2e/schema/schema_test.go b/graphql/e2e/schema/schema_test.go index 0b37f440264..f02ae2374c6 100644 --- a/graphql/e2e/schema/schema_test.go +++ b/graphql/e2e/schema/schema_test.go @@ -197,7 +197,7 @@ func TestConcurrentSchemaUpdates(t *testing.T) { { graphQLSchema: ` type A { - b: String! @search(by: [term]) + b: String! @search(by: ["term"]) }`, dgraphSchema: `{ "predicate": "A.b", @@ -212,7 +212,7 @@ func TestConcurrentSchemaUpdates(t *testing.T) { { graphQLSchema: ` type A { - b: String! @search(by: [exact]) + b: String! @search(by: ["exact"]) }`, dgraphSchema: `{ "predicate": "A.b", @@ -564,7 +564,7 @@ func TestLargeSchemaUpdate(t *testing.T) { schema := "type LargeSchema {" for i := 1; i <= numFields; i++ { - schema = schema + "\n" + fmt.Sprintf("field%d: String! @search(by: [regexp])", i) + schema = schema + "\n" + fmt.Sprintf("field%d: String! @search(by: [\"regexp\"])", i) } schema = schema + "\n}" diff --git a/graphql/e2e/subscription/subscription_test.go b/graphql/e2e/subscription/subscription_test.go index 3dda3c231c9..b60fcdbf35b 100644 --- a/graphql/e2e/subscription/subscription_test.go +++ b/graphql/e2e/subscription/subscription_test.go @@ -41,12 +41,12 @@ const ( sch = ` type Product @withSubscription { productID: ID! - name: String @search(by: [term]) + name: String @search(by: ["term"]) reviews: [Review] @hasInverse(field: about) } type Customer { - username: String! @id @search(by: [hash, regexp]) + username: String! @id @search(by: ["hash", "regexp"]) reviews: [Review] @hasInverse(field: by) } @@ -54,7 +54,7 @@ const ( id: ID! about: Product! by: Customer! - comment: String @search(by: [fulltext]) + comment: String @search(by: ["fulltext"]) rating: Int @search } ` @@ -69,15 +69,15 @@ const ( } ){ id: ID! - text: String! @search(by: [term]) - owner: String! @search(by: [hash]) + text: String! @search(by: ["term"]) + owner: String! @search(by: ["hash"]) } # Dgraph.Authorization {"VerificationKey":"secret","Header":"Authorization","Namespace":"https://dgraph.io","Algo":"HS256"} ` schCustomDQL = ` type Tweets { id: ID! - text: String! @search(by: [fulltext]) + text: String! @search(by: ["fulltext"]) author: User timestamp: DateTime @search } diff --git a/graphql/resolve/resolver_error_test.go b/graphql/resolve/resolver_error_test.go index 6238a537e1f..56d3df22e82 100644 --- a/graphql/resolve/resolver_error_test.go +++ b/graphql/resolve/resolver_error_test.go @@ -88,7 +88,7 @@ type Product { description: String title: String imageUrl: String - productVector: [Float] @hm_embedding + productVector: [Float!] @hm_embedding } type Post { diff --git a/graphql/resolve/schema.graphql b/graphql/resolve/schema.graphql index 66d0e87d3a8..78b00b1938f 100644 --- a/graphql/resolve/schema.graphql +++ b/graphql/resolve/schema.graphql @@ -11,7 +11,7 @@ type Hotel { type Country { id: ID! - name: String! @search(by: [trigram, exact]) + name: String! @search(by: ["trigram", "exact"]) states: [State] @hasInverse(field: country) } @@ -24,7 +24,7 @@ type State { type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) dob: DateTime @search reputation: Float @search country: Country @@ -34,14 +34,14 @@ type Author { type Editor { id: ID! code: String! @id - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) } type Post { postID: ID! - title: String! @search(by: [term]) - text: String @search(by: [fulltext]) - tags: [String] @search(by: [exact]) + title: String! @search(by: ["term"]) + text: String @search(by: ["fulltext"]) + tags: [String] @search(by: ["exact"]) numLikes: Int @search isPublished: Boolean @search postType: [PostType] @search @@ -89,8 +89,8 @@ type Human implements Character & Employee { # just for testing filters on enum types type Verification { - name: String @search(by: [exact]) - status: [Status!]! @search(by: [exact]) + name: String @search(by: ["exact"]) + status: [Status!]! @search(by: ["exact"]) prevStatus: Status! @search } @@ -259,7 +259,7 @@ type Y implements X @auth( } """ } ){ - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } type Post1 { @@ -310,12 +310,12 @@ type ThingTwo implements Thing { type Person { id: ID! - name: String @search(by: [hash]) - nameHi: String @dgraph(pred:"Person.name@hi") @search(by: [hash]) - nameZh: String @dgraph(pred:"Person.name@zh") @search(by: [hash]) + name: String @search(by: ["hash"]) + nameHi: String @dgraph(pred:"Person.name@hi") @search(by: ["hash"]) + nameZh: String @dgraph(pred:"Person.name@zh") @search(by: ["hash"]) nameHiZh: String @dgraph(pred:"Person.name@hi:zh") nameHi_Zh_Untag: String @dgraph(pred:"Person.name@hi:zh:.") - name_Untag_AnyLang: String @dgraph(pred:"Person.name@.") @search(by: [hash]) + name_Untag_AnyLang: String @dgraph(pred:"Person.name@.") @search(by: ["hash"]) friends: [Person] @hasInverse(field: friends) } @@ -506,5 +506,5 @@ type Product { description: String title: String imageUrl: String - productVector: [Float] @hm_embedding + productVector: [Float!] @hm_embedding } diff --git a/graphql/schema/auth_schemas_test.yaml b/graphql/schema/auth_schemas_test.yaml index 1a7195938e2..57f53898b02 100644 --- a/graphql/schema/auth_schemas_test.yaml +++ b/graphql/schema/auth_schemas_test.yaml @@ -6,7 +6,7 @@ invalid_schemas: query: { rule: "query { " } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ {"message": "Type X: @auth: failed to parse GraphQL rule @@ -19,7 +19,7 @@ invalid_schemas: query: {rule: "query { queryX(filter: { userRle: { eq: \"ADMIN\" } }) { __typename } }"} ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ {"message": "Type X: @auth: failed to validate GraphQL rule @@ -33,7 +33,7 @@ invalid_schemas: query: { rule: "{$USER: { in: \"xyz@dgraph.io\" } }"} ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ { "message": "Type X: @auth: `in` operator has invalid value `xyz@dgraph.io`. @@ -46,7 +46,7 @@ invalid_schemas: query: { rule: "{$USER: { in: true } }"} ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ { "message": "Type X: @auth: `in` operator has invalid value `true`. @@ -59,7 +59,7 @@ invalid_schemas: query: { rule: "{$USER: { eq: nil } }"} ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ { "message": "Type X: @auth: `$USER` is not a valid GraphQL variable." } @@ -71,7 +71,7 @@ invalid_schemas: query: { rule: "{$USER: { eq: null } }"} ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ { "message": "Type X: @auth: `eq` operator has invalid value. null values aren't supported." } @@ -83,7 +83,7 @@ invalid_schemas: query: { rule: "{$USER: { regexp: 12345 } }"} ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ { "message": "Type X: @auth: `regexp` operator has invalid value `12345`. @@ -97,7 +97,7 @@ invalid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [{"message": "Type X: @auth: `X_MyApp_Role` is not a valid GraphQL variable."}] @@ -108,7 +108,7 @@ invalid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [{"message": "Type X: @auth: `xyz` operator is not supported."}] @@ -119,7 +119,7 @@ invalid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [{"message": "Type X: @auth: `{ \"ADMIN\" }` is not a valid rule."}] @@ -130,7 +130,7 @@ invalid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ {"message": "Type X: @auth: a rule should be exactly one query, @@ -144,7 +144,7 @@ invalid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ {"message": "Type X: @auth: there should be only one of \"and\", \"or\", @@ -165,7 +165,7 @@ invalid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [{"message": "Type X: @auth: 'OR' should contain at least two rules"}] @@ -202,7 +202,7 @@ invalid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ {"message": "Type X: @auth: there should be only one of \"and\", \"or\", @@ -242,7 +242,7 @@ invalid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ {"message": "Type X: @auth: there should be only one of \"and\", \"or\", @@ -255,7 +255,7 @@ invalid_schemas: query: { and: [ null, null ] } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ {"message": "Type X: @auth: no arguments - there should be only one of \"and\", \"or\", @@ -278,7 +278,7 @@ valid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } - name: "GraphQL auth RBAC rule" @@ -288,7 +288,7 @@ valid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } - name: "GraphQL With Variable Should Parse" @@ -303,7 +303,7 @@ valid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } - name: "Complex GraphQL Should Parse" @@ -351,7 +351,7 @@ valid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } - name: "Rule using logical `and` operation" @@ -374,7 +374,7 @@ valid_schemas: } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } - name: "Rule using logical `not` operation" @@ -389,5 +389,5 @@ valid_schemas: } } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } diff --git a/graphql/schema/dgraph_schemagen_test.yml b/graphql/schema/dgraph_schemagen_test.yml index 32bb64b3b58..f81ab3b5395 100644 --- a/graphql/schema/dgraph_schemagen_test.yml +++ b/graphql/schema/dgraph_schemagen_test.yml @@ -127,34 +127,38 @@ schemas: input: | type X { i1: Int @search - i2: Int @search(by: [int]) + i2: Int @search(by: ["int"]) i64_1: Int64 @search - i64_2: Int64 @search(by: [int64]) + i64_2: Int64 @search(by: ["int64"]) f1: Float @search - f2: Float @search(by: [float]) + f2: Float @search(by: ["float"]) b1: Boolean @search - b2: Boolean @search(by: [bool]) + b2: Boolean @search(by: ["bool"]) s1: String @search - s2: String @search(by: [hash]) - s3: String @search(by: [exact]) - s4: String @search(by: [term]) - s5: String @search(by: [fulltext]) - s6: String @search(by: [trigram]) - s7: String @search(by: [regexp]) - s8: String @search(by: [exact, fulltext, term, trigram]) + s2: String @search(by: ["hash"]) + s3: String @search(by: ["exact"]) + s4: String @search(by: ["term"]) + s5: String @search(by: ["fulltext"]) + s6: String @search(by: ["trigram"]) + s7: String @search(by: ["regexp"]) + s8: String @search(by: ["exact", "fulltext", "term", "trigram"]) dt1: DateTime @search - dt2: DateTime @search(by: [year]) - dt3: DateTime @search(by: [month]) - dt4: DateTime @search(by: [day]) - dt5: DateTime @search(by: [hour]) + dt2: DateTime @search(by: ["year"]) + dt3: DateTime @search(by: ["month"]) + dt4: DateTime @search(by: ["day"]) + dt5: DateTime @search(by: ["hour"]) + vf1: [Float!] @hm_embedding @search(by: ["hnsw"]) + vf2: [Float!] @hm_embedding @search(by: ["hnsw(exponent: 4, metric: euclidian)"]) + vf3: [Float!] @hm_embedding @search(by: ["hnsw(metric: cosine)"]) + vf4: [Float!] @hm_embedding @search(by: ["hnsw(metric: dotproduct, exponent: 4)"]) e: E @search - e1: E @search(by: [hash]) - e2: E @search(by: [exact]) - e3: E @search(by: [trigram]) - e4: E @search(by: [regexp]) - e5: E @search(by: [hash, regexp]) - e6: E @search(by: [hash, trigram]) - e7: E @search(by: [exact, regexp]) + e1: E @search(by: ["hash"]) + e2: E @search(by: ["exact"]) + e3: E @search(by: ["trigram"]) + e4: E @search(by: ["regexp"]) + e5: E @search(by: ["hash", "regexp"]) + e6: E @search(by: ["hash", "trigram"]) + e7: E @search(by: ["exact", "regexp"]) } enum E { A } output: | @@ -180,6 +184,10 @@ schemas: X.dt3 X.dt4 X.dt5 + X.vf1 + X.vf2 + X.vf3 + X.vf4 X.e X.e1 X.e2 @@ -210,6 +218,10 @@ schemas: X.dt3: dateTime @index(month) . X.dt4: dateTime @index(day) . X.dt5: dateTime @index(hour) . + X.vf1: vfloat @index(hnsw) . + X.vf2: vfloat @index(hnsw(exponent: "4", metric: "euclidian")) . + X.vf3: vfloat @index(hnsw(metric: "cosine")) . + X.vf4: vfloat @index(hnsw(exponent: "4", metric: "dotproduct")) . X.e: string @index(hash) . X.e1: string @index(hash) . X.e2: string @index(exact) . @@ -223,7 +235,7 @@ schemas: input: | interface A { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) } type B implements A { correct: Boolean @search @@ -353,7 +365,7 @@ schemas: interface B @dgraph(type: "dgraph.interface.B") { id: ID! - name: String! @search(by: [exact]) @dgraph(pred: "dgraph.abc.name") + name: String! @search(by: ["exact"]) @dgraph(pred: "dgraph.abc.name") age: Int } @@ -434,12 +446,12 @@ schemas: f2: String @dgraph(pred: "T.f@no") f3: String @dgraph(pred: "f3@en") name: String! @id - nameHi: String @dgraph(pred: "Person.name@hi") @search(by: [term, exact]) - nameEn: String @dgraph(pred: "Person.name@en") @search(by: [regexp]) + nameHi: String @dgraph(pred: "Person.name@hi") @search(by: ["term", "exact"]) + nameEn: String @dgraph(pred: "Person.name@en") @search(by: ["regexp"]) nameHiEn: String @dgraph(pred: "Person.name@hi:en") nameHi_En_Untag: String @dgraph(pred: "Person.name@hi:en:.") name_Untag_AnyLang: String @dgraph(pred: "Person.name@.") - address: String @search(by: [fulltext]) + address: String @search(by: ["fulltext"]) addressHi: String @dgraph(pred: "Person.address@hi") professionEn: String @dgraph(pred: "Person.profession@en") } @@ -484,7 +496,7 @@ schemas: - name: "Field with @id directive gets hash index." input: | interface A { - id: String! @id @search(by: [trigram]) + id: String! @id @search(by: ["trigram"]) } type B implements A { correct: Boolean @search @@ -503,7 +515,7 @@ schemas: - name: "Field with @id directive and a hash arg in search directive generates correct schema." input: | interface A { - id: String! @id @search(by: [hash, term]) + id: String! @id @search(by: ["hash", "term"]) } type B implements A { correct: Boolean @search @@ -522,7 +534,7 @@ schemas: - name: "Field with @id directive and a exact arg in search directive generates correct schema." input: | interface A { - id: String! @id @search(by: [exact]) + id: String! @id @search(by: ["exact"]) } type B implements A { correct: Boolean @search @@ -641,13 +653,13 @@ schemas: combined" input: | type A { - p: String @dgraph(pred: "name") @search(by: [exact, term]) + p: String @dgraph(pred: "name") @search(by: ["exact", "term"]) } type B { - q: String @dgraph(pred: "name") @search(by: [trigram]) + q: String @dgraph(pred: "name") @search(by: ["trigram"]) } type C { - q: String @dgraph(pred: "name") @search(by: [exact, term]) + q: String @dgraph(pred: "name") @search(by: ["exact", "term"]) } output: | type A { @@ -664,8 +676,8 @@ schemas: - name: "fields with @dgraph(pred: ...) contain different language." input: | type A { - content: String! @dgraph(pred: "post") @search(by: [exact, term]) - author: String @dgraph(pred: "<公司>") @search(by: [exact, term]) + content: String! @dgraph(pred: "post") @search(by: ["exact", "term"]) + author: String @dgraph(pred: "<公司>") @search(by: ["exact", "term"]) } output: | type A { @@ -720,13 +732,13 @@ schemas: name: String! location: Point @search landmark: Point - office: Point @search(by: [point]) + office: Point @search(by: ["point"]) area1: Polygon @search area2: Polygon - area3: Polygon @search(by: [polygon]) + area3: Polygon @search(by: ["polygon"]) branches1: MultiPolygon @search branches2: MultiPolygon - branches3: MultiPolygon @search(by: [multiPolygon]) + branches3: MultiPolygon @search(by: ["multiPolygon"]) } output: | type Hotel { diff --git a/graphql/schema/gqlschema.go b/graphql/schema/gqlschema.go index f8d7ef56de8..244a8b274ef 100644 --- a/graphql/schema/gqlschema.go +++ b/graphql/schema/gqlschema.go @@ -162,6 +162,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -276,7 +277,7 @@ input GenerateMutationParams { ` directiveDefs = ` directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION @@ -308,7 +309,7 @@ directive @generate( // So, such directives have to be missed too. apolloSupportedDirectiveDefs = ` directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION @@ -461,6 +462,7 @@ var supportedSearches = map[string]searchTypeIndex{ "point": {"Point", "geo"}, "polygon": {"Polygon", "geo"}, "multiPolygon": {"MultiPolygon", "geo"}, + "hnsw": {"Float", "hnsw"}, } // GraphQL scalar/object type -> default search arg @@ -535,6 +537,7 @@ var builtInFilters = map[string]string{ "point": "PointGeoFilter", "polygon": "PolygonGeoFilter", "multiPolygon": "PolygonGeoFilter", + "hnsw": "HNSWSearchFilter", } // GraphQL in-built type -> Dgraph scalar @@ -1314,7 +1317,7 @@ func addPatchType(schema *ast.Schema, defn *ast.Definition, providesTypeMap map[ // addFieldFilters adds field arguments that allow filtering to all fields of // defn that can be searched. For example, if there's another type -// `type R { ... f: String @search(by: [term]) ... }` +// `type R { ... f: String @search(by: ["term"]) ... }` // and defn has a field of type R, e.g. if defn is like // `type T { ... g: R ... }` // then a query should be able to filter on g by term search on f, like @@ -1473,6 +1476,7 @@ func getFilterTypes(schema *ast.Schema, fld *ast.FieldDefinition, filterName str filterNames := make([]string, len(searchArgs)) for i, search := range searchArgs { + search = parseSearchType(search) filterNames[i] = builtInFilters[search] // For enum type, if the index is "hash" or "exact", we construct filter named diff --git a/graphql/schema/gqlschema_test.yml b/graphql/schema/gqlschema_test.yml index eb69c0ba608..155157ac7a4 100644 --- a/graphql/schema/gqlschema_test.yml +++ b/graphql/schema/gqlschema_test.yml @@ -17,7 +17,7 @@ invalid_schemas: type Hotel { id: ID! name: String! - location: Point @search(by: [int]) + location: Point @search(by: ["int"]) } errlist: [ {"message":"Type Hotel; Field location: has the @search directive but the argument int doesn't apply to field type Point. Search by int applies to fields of type Int. Fields of type Point are searchable by just @search.", "locations":[ { "line": 4, "column":20}]}, @@ -77,7 +77,7 @@ invalid_schemas: name: "Enum indexes clash trigram and regexp" input: | type T { - f: E @search(by: [trigram, regexp]) + f: E @search(by: ["trigram", "regexp"]) } enum E { A @@ -91,7 +91,7 @@ invalid_schemas: name: "Enum indexes clash hash and exact" input: | type T { - f: E @search(by: [hash, exact]) + f: E @search(by: ["hash", "exact"]) } enum E { A @@ -100,6 +100,17 @@ invalid_schemas: {"message": "Type T; Field f: the arguments 'hash' and 'exact' can't be used together as arguments to @search.", "locations": [{"line": 2, "column": 9}]} ] + - + name: "HNSW index options malformed" + input: | + type T { + f: [Float!] @hm_embedding @search(by: ["hnsw(metric:dotproduct)"]) + } + errlist: [ + {"message": "Type T; Field f: has the @search directive but the argument 'hnsw(metric:dotproduct)' with search options is malformed. Search options are comma-separated key-value pairs in YAML format => ", + "locations": [{"line": 2, "column": 30}]} + ] + - name: "Reference type that is not in input schema" input: | @@ -379,7 +390,7 @@ invalid_schemas: name: String } type Y { - id: ID! @search(by: [term]) + id: ID! @search(by: ["term"]) name: String } errlist: [ @@ -411,7 +422,7 @@ invalid_schemas: name: "Search (with arg) will error that can't have the @search" input: | type X { - y: Y @search(by: [term]) + y: Y @search(by: ["term"]) } type Y { y: String @@ -427,7 +438,7 @@ invalid_schemas: name: "Search with wrong arg with error on default search type" input: | type X { - y: Int @search(by: [term]) + y: Int @search(by: ["term"]) } errlist: [ {"message": "Type X; Field y: has the @search directive but the argument term doesn't @@ -440,7 +451,7 @@ invalid_schemas: name: "Search with wrong arg (int) with error on default search type (Int64)" input: | type X { - y: Int64 @search(by: [int]) + y: Int64 @search(by: ["int"]) } errlist: [ {"message": "Type X; Field y: has the @search directive but the argument int doesn't @@ -453,7 +464,7 @@ invalid_schemas: name: "Search with wrong arg with error on search type" input: | type X { - y: String @search(by: [day]) + y: String @search(by: ["day"]) } errlist: [ {"message": "Type X; Field y: has the @search directive but the argument day doesn't @@ -466,7 +477,7 @@ invalid_schemas: name: "Search with wrong arg for the index" input: | type X { - y: String @search(by: [hash, hour]) + y: String @search(by: ["hash", "hour"]) } errlist: [ {"message": "Type X; Field y: has the @search directive but the argument hour doesn't @@ -479,11 +490,11 @@ invalid_schemas: name: "Search without []" input: | type X { - y: String @search(by: hash) + y: String @search(by: "hash") } errlist: [ {"message": "Type X; Field y: the @search directive requires a list argument, - like @search(by: [hash])", + like @search(by: [\"hash\"])", "locations":[{"line":2, "column":14}]} ] @@ -491,7 +502,7 @@ invalid_schemas: name: "Search doesn't allow hash and exact together" input: | type X { - y: String @search(by: [hash, exact]) + y: String @search(by: ["hash", "exact"]) } errlist: [ {"message": "Type X; Field y: the arguments 'hash' and 'exact' can't be @@ -503,7 +514,7 @@ invalid_schemas: name: "Search with multiple datetime index" input: | type X { - y: DateTime @search(by: [hour, month]) + y: DateTime @search(by: ["hour", "month"]) } errlist: [ {"message": "Type X; Field y: has the search directive on DateTime. DateTime @@ -515,7 +526,7 @@ invalid_schemas: name: "Search doesn't allow trigram and regexp together" input: | type X { - y: String @search(by: [trigram, regexp]) + y: String @search(by: ["trigram", "regexp"]) } errlist: [ {"message": "Type X; Field y: the argument to @search 'trigram' is the same as @@ -527,7 +538,7 @@ invalid_schemas: name: "Search doesn't accept bogus args" input: | type X { - y: String @search(by: [bogus]) + y: String @search(by: ["bogus"]) } errlist: [ {"message": "Type X; Field y: the argument to @search bogus isn't valid.Fields of type @@ -2240,7 +2251,7 @@ invalid_schemas: input: | type X { username: String! @id @auth(query: {rule: "{ X_MyApp_Role : { eq : \"ADMIN\"}}" }) - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } errlist: [ {"message": "Directive auth is not applicable on FIELD_DEFINITION.", @@ -2732,7 +2743,7 @@ invalid_schemas: review: String! } errlist: [ - {"message": "Type Product; @remote directive cannot be defined with @key directive", "locations": [ { "line": 175, "column": 12} ] }, + {"message": "Type Product; @remote directive cannot be defined with @key directive", "locations": [ { "line": 176, "column": 12} ] }, ] - name: "directives defined on @external fields that are not @key." @@ -2760,7 +2771,7 @@ invalid_schemas: productVector: String @hm_embedding } errlist: [ - {"message": "Type Product; Field productVector: The field with @hm_embedding directive is of type String, but @hm_embedding directive only applies to fields of type [Float].", "locations": [ { "line": 5, "column": 3} ] }, + {"message": "Type Product; Field productVector: The field with @hm_embedding directive is of type String, but @hm_embedding directive only applies to fields of type [Float!].", "locations": [ { "line": 5, "column": 3} ] }, ] - name: "@hm_embedding directive on a field with [Int] type" @@ -2771,7 +2782,7 @@ invalid_schemas: userVector: [Int] @hm_embedding } errlist: [ - {"message": "Type User; Field userVector: The field with @hm_embedding directive is of type [Int], but @hm_embedding directive only applies to fields of type [Float].", "locations": [ { "line": 4, "column": 3} ] }, + {"message": "Type User; Field userVector: The field with @hm_embedding directive is of type [Int], but @hm_embedding directive only applies to fields of type [Float!].", "locations": [ { "line": 4, "column": 3} ] }, ] - name: "@requires directive defined on type definitions" @@ -2938,7 +2949,7 @@ invalid_schemas: input: | type Person { name: String! - nameHiEn: String! @dgraph(pred:"Person.name@hi:en") @search(by: [exact]) + nameHiEn: String! @dgraph(pred:"Person.name@hi:en") @search(by: ["exact"]) } errlist: [ { "message": "Type Person; Field nameHiEn: @search directive not applicable on language tag @@ -2979,7 +2990,7 @@ valid_schemas: - name: "field with @id directive can have exact index" input: | type X { - f1: String! @id @search(by:[exact]) + f1: String! @id @search(by:["exact"]) } - name: "Type implements from two interfaces where both have ID" @@ -3042,7 +3053,7 @@ valid_schemas: } """ } ){ - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } - @@ -3103,35 +3114,35 @@ valid_schemas: input: | type X { int1: Int @search - int2: Int @search(by: [int]) + int2: Int @search(by: ["int"]) int3: Int @search(by: []) int64_1: Int64 @search - int64_2: Int64 @search(by: [int64]) + int64_2: Int64 @search(by: ["int64"]) int64_3: Int64 @search(by: []) float1: Float @search - float2: Float @search(by: [float]) + float2: Float @search(by: ["float"]) float3: Float @search(by: []) bool1: Boolean @search - bool2: Boolean @search(by: [bool]) + bool2: Boolean @search(by: ["bool"]) bool3: Boolean @search(by: []) str: String @search str2: String @search(by: []) - strHash: String @search(by: [hash]) - strExact: String @search(by: [exact]) - strTerm: String @search(by: [term]) - strFulltext: String @search(by: [fulltext]) - strTrigram: String @search(by: [trigram]) - strRegexp: String @search(by: [regexp]) - strRegexpFulltext: String @search(by: [regexp, fulltext]) - strMultipleIndex: String @search(by: [trigram, hash, term, fulltext]) + strHash: String @search(by: ["hash"]) + strExact: String @search(by: ["exact"]) + strTerm: String @search(by: ["term"]) + strFulltext: String @search(by: ["fulltext"]) + strTrigram: String @search(by: ["trigram"]) + strRegexp: String @search(by: ["regexp"]) + strRegexpFulltext: String @search(by: ["regexp", "fulltext"]) + strMultipleIndex: String @search(by: ["trigram", "hash", "term", "fulltext"]) dt: DateTime @search dt2: DateTime @search(by: []) - dtYear: DateTime @search(by: [year]) - dtMonth: DateTime @search(by: [month]) - dtDay: DateTime @search(by: [day]) - dtHour: DateTime @search(by: [hour]) + dtYear: DateTime @search(by: ["year"]) + dtMonth: DateTime @search(by: ["month"]) + dtDay: DateTime @search(by: ["day"]) + dtHour: DateTime @search(by: ["hour"]) enumFld: E @search - req: String! @search(by: [term]) + req: String! @search(by: ["term"]) list: [Int] @search reqList: [DateTime!]! @search } @@ -3273,7 +3284,7 @@ valid_schemas: input: | type Tweets { id: ID! - text: String! @search(by: [fulltext]) + text: String! @search(by: ["fulltext"]) user: User timestamp: DateTime! @search } @@ -3469,12 +3480,12 @@ valid_schemas: f2: String @dgraph(pred: "T.f@no") name: String! @id f3: String @dgraph(pred: "f3@en") - nameHi: String @dgraph(pred: "Person.name@hi") @search(by: [term, exact]) - nameEn: String @dgraph(pred: "Person.name@en") @search(by: [regexp]) + nameHi: String @dgraph(pred: "Person.name@hi") @search(by: ["term", "exact"]) + nameEn: String @dgraph(pred: "Person.name@en") @search(by: ["regexp"]) nameHiEn: String @dgraph(pred: "Person.name@hi:en") nameHi_En_Untag: String @dgraph(pred: "Person.name@hi:en:.") name_Untag_AnyLang: String @dgraph(pred: "Person.name@.") - address: String @search(by: [fulltext]) + address: String @search(by: ["fulltext"]) addressHi: String @dgraph(pred: "Person.address@hi") professionEn: String @dgraph(pred: "Person.profession@en") } diff --git a/graphql/schema/rules.go b/graphql/schema/rules.go index a28660e1965..5c19b81d093 100644 --- a/graphql/schema/rules.go +++ b/graphql/schema/rules.go @@ -29,6 +29,7 @@ import ( "github.com/dgraph-io/gqlparser/v2/gqlerror" "github.com/dgraph-io/gqlparser/v2/parser" "github.com/dgraph-io/gqlparser/v2/validator" + "gopkg.in/yaml.v2" ) const ( @@ -839,17 +840,18 @@ func embeddingValidation(sch *ast.Schema, typ *ast.Definition, field.Position, "Type %s; Field %s: The field with @hm_embedding directive is of type %s,"+ " but @hm_embedding directive only applies"+ - " to fields of type [Float].", typ.Name, field.Name, field.Type.Name())) + " to fields of type [Float!].", typ.Name, field.Name, field.Type.Name())) return errs } - if !strings.EqualFold(field.Type.Elem.NamedType, "Float") { + if !strings.EqualFold(field.Type.Elem.NamedType, "Float") || + !field.Type.Elem.NonNull { errs = append(errs, gqlerror.ErrorPosf( field.Position, "Type %s; Field %s: The field with @hm_embedding directive is of type [%s], "+ "but @hm_embedding directive only applies"+ - " to fields of type [Float].", typ.Name, field.Name, field.Type.Name())) + " to fields of type [Float!].", typ.Name, field.Name, field.Type.Name())) } return errs @@ -997,7 +999,8 @@ func validateSearchArg(searchArg string, dir *ast.Directive) *gqlerror.Error { isEnum := sch.Types[field.Type.Name()].Kind == ast.Enum - search, ok := supportedSearches[searchArg] + searchType := parseSearchType(searchArg) + search, ok := supportedSearches[searchType] switch { case !ok: // This check can be removed once gqlparser bug @@ -1024,6 +1027,24 @@ func validateSearchArg(searchArg string, "doesn't apply to field type %s which is an Enum. Enum only supports "+ "hash, exact, regexp and trigram", typ.Name, field.Name, searchArg, field.Type.Name()) + + case search.dgIndex == "hnsw": + if !hasEmbeddingDirective(field) { + return gqlerror.ErrorPosf( + dir.Position, + "Type %s; Field %s: has the @search directive but the argument %s "+ + "requires the field also has @%s directive.", + typ.Name, field.Name, searchArg, embeddingDirective) + } + _, valid := parseSearchOptions(searchArg) + if !valid { + return gqlerror.ErrorPosf( + dir.Position, + "Type %s; Field %s: has the @search directive but the argument '%s' "+ + "with search options is malformed. Search options are comma-separated "+ + "key-value pairs in YAML format => ", + typ.Name, field.Name, searchArg) + } } return nil @@ -1067,7 +1088,7 @@ func searchValidation( if arg.Value.Kind != ast.ListValue { errs = append(errs, gqlerror.ErrorPosf( dir.Position, - "Type %s; Field %s: the @search directive requires a list argument, like @search(by: [hash])", + "Type %s; Field %s: the @search directive requires a list argument, like @search(by: [\"hash\"])", typ.Name, field.Name)) return errs } @@ -1082,7 +1103,16 @@ func searchValidation( // Checks that the filter indexes aren't repeated and they // don't clash with each other. - searchIndex := builtInFilters[searchArg] + searchType := parseSearchType(searchArg) + searchIndex := builtInFilters[searchType] + if len(searchIndex) == 0 { + errs = append(errs, gqlerror.ErrorPosf( + dir.Position, + "Type %s; Field %s: the argument to @search '%s' is not among "+ + "supported search types.", + typ.Name, field.Name, searchArg)) + return errs + } if val, ok := searchIndexes[searchIndex]; ok { if field.Type.Name() == "String" || sch.Types[field.Type.Name()].Kind == ast.Enum { errs = append(errs, gqlerror.ErrorPosf( @@ -1113,12 +1143,94 @@ func searchValidation( } } - searchIndexes[searchIndex] = searchArg + searchIndexes[searchIndex] = searchType } return errs } +// parseSearchType(searchArg) parses the searchType from searchArg +// searchArg is specified with the following syntax +// +// := [ ] +// +// hnsw(metric: euclidian, exponent: 6) +// hnsw +// hnsw(exponent: 3) +func parseSearchType(searchArg string) string { + searchType := searchArg + if strings.IndexByte(searchArg, '(') >= 0 { + searchType = searchArg[:strings.IndexByte(searchArg, '(')] + searchType = strings.TrimSpace(searchType) + } + return searchType +} + +// parseSearchOptions(searchArg) parses searchOptions from searchArg +// searchArg is specified with the following syntax +// +// := [ ] +// +// searchOptions := * +// Examples: +// +// hnsw(metric: euclidian, exponent: 6) +// hnsw +// hnsw(exponent: 3) +func parseSearchOptions(searchArg string) (string, bool) { + res := "" + searchArg = strings.TrimSpace(searchArg) + openParen := strings.Index(searchArg, "(") + + if openParen < 0 && searchArg[len(searchArg)-1] != ')' { + // no search options and supported searchType found + return "", true // valid = true, no search options + } + + if openParen+1 == len(searchArg)-1 { + // found () with no index options between + // '(' & ')' + return "", true + } + + if openParen < 0 || searchArg[len(searchArg)-1] != ')' { + // does not have open/close parenthesis + return "", false // valid = false + } + + indexOptions := "{" + searchArg[openParen+1:len(searchArg)-1] + "}" + var kvMap map[string]string + err := yaml.Unmarshal([]byte(indexOptions), &kvMap) + if err != nil { + return "", false + } + + keys := make([]string, 0, len(kvMap)) + for k := range kvMap { + keys = append(keys, k) + } + + sort.Strings(keys) + + res += "(" + i := 0 + for _, key := range keys { + if len(kvMap[key]) == 0 { + // If the value is null, then return invalid + return "", false + } + res += strings.TrimSpace(key) + ": \"" + + strings.TrimSpace(kvMap[key]) + "\"" + if i < len(keys)-1 { + res += ", " + } + i++ + } + res += ")" + + return res, true // parsed valid options +} + func dgraphDirectiveValidation(sch *ast.Schema, typ *ast.Definition, field *ast.FieldDefinition, dir *ast.Directive, secrets map[string]x.Sensitive) gqlerror.List { var errs []*gqlerror.Error diff --git a/graphql/schema/schemagen.go b/graphql/schema/schemagen.go index 0f6249cd088..25c65a59382 100644 --- a/graphql/schema/schemagen.go +++ b/graphql/schema/schemagen.go @@ -472,10 +472,14 @@ func getAllowedHeaders(sch *ast.Schema, definitions []string, authHeader string) } func getAllSearchIndexes(val *ast.Value) []string { + // all searchArgs were validated before getting here. res := make([]string, len(val.Children)) for i, child := range val.Children { - res[i] = supportedSearches[child.Value.Raw].dgIndex + searchType := parseSearchType(child.Value.Raw) + res[i] = supportedSearches[searchType].dgIndex + searchOptions, _ := parseSearchOptions(child.Value.Raw) + res[i] += searchOptions } return res @@ -674,8 +678,6 @@ func genDgSchema(gqlSch *ast.Schema, definitions []string, // embeddingValidation ensured GQL type is [Float] // set typStr to vfloat typStr = "vfloat" - // Appropriate index will be created through embedding services - // indexes = append(indexes, "hnsw-euclidian") } if parentInt == nil { diff --git a/graphql/schema/schemagen_test.go b/graphql/schema/schemagen_test.go index 6c852eb400b..d9298598e11 100644 --- a/graphql/schema/schemagen_test.go +++ b/graphql/schema/schemagen_test.go @@ -224,111 +224,111 @@ func TestOnlyCorrectSearchArgsWork(t *testing.T) { }{ "String searches don't apply to Int": {schema: ` type X { - str1: Int @search(by: [hash]) - str2: Int @search(by: [exact]) - str3: Int @search(by: [term]) - str4: Int @search(by: [fulltext]) - str5: Int @search(by: [trigram]) - str6: Int @search(by: [regexp]) + str1: Int @search(by: ["hash"]) + str2: Int @search(by: ["exact"]) + str3: Int @search(by: ["term"]) + str4: Int @search(by: ["fulltext"]) + str5: Int @search(by: ["trigram"]) + str6: Int @search(by: ["regexp"]) }`, expectedErrors: 6}, "String searches don't apply to Float": {schema: ` type X { - str1: Float @search(by: [hash]) - str2: Float @search(by: [exact]) - str3: Float @search(by: [term]) - str4: Float @search(by: [fulltext]) - str5: Float @search(by: [trigram]) - str6: Float @search(by: [regexp]) + str1: Float @search(by: ["hash"]) + str2: Float @search(by: ["exact"]) + str3: Float @search(by: ["term"]) + str4: Float @search(by: ["fulltext"]) + str5: Float @search(by: ["trigram"]) + str6: Float @search(by: ["regexp"]) }`, expectedErrors: 6}, "String searches don't apply to Boolean": {schema: ` type X { - str1: Boolean @search(by: [hash]) - str2: Boolean @search(by: [exact]) - str3: Boolean @search(by: [term]) - str4: Boolean @search(by: [fulltext]) - str5: Boolean @search(by: [trigram]) - str6: Boolean @search(by: [regexp]) + str1: Boolean @search(by: ["hash"]) + str2: Boolean @search(by: ["exact"]) + str3: Boolean @search(by: ["term"]) + str4: Boolean @search(by: ["fulltext"]) + str5: Boolean @search(by: ["trigram"]) + str6: Boolean @search(by: ["regexp"]) }`, expectedErrors: 6}, "String searches don't apply to DateTime": {schema: ` type X { - str1: DateTime @search(by: [hash]) - str2: DateTime @search(by: [exact]) - str3: DateTime @search(by: [term]) - str4: DateTime @search(by: [fulltext]) - str5: DateTime @search(by: [trigram]) - str6: DateTime @search(by: [regexp]) + str1: DateTime @search(by: ["hash"]) + str2: DateTime @search(by: ["exact"]) + str3: DateTime @search(by: ["term"]) + str4: DateTime @search(by: ["fulltext"]) + str5: DateTime @search(by: ["trigram"]) + str6: DateTime @search(by: ["regexp"]) }`, expectedErrors: 6}, "DateTime searches don't apply to Int": {schema: ` type X { - dt1: Int @search(by: [year]) - dt2: Int @search(by: [month]) - dt3: Int @search(by: [day]) - dt4: Int @search(by: [hour]) + dt1: Int @search(by: ["year"]) + dt2: Int @search(by: ["month"]) + dt3: Int @search(by: ["day"]) + dt4: Int @search(by: ["hour"]) }`, expectedErrors: 4}, "DateTime searches don't apply to Float": {schema: ` type X { - dt1: Float @search(by: [year]) - dt2: Float @search(by: [month]) - dt3: Float @search(by: [day]) - dt4: Float @search(by: [hour]) + dt1: Float @search(by: ["year"]) + dt2: Float @search(by: ["month"]) + dt3: Float @search(by: ["day"]) + dt4: Float @search(by: ["hour"]) }`, expectedErrors: 4}, "DateTime searches don't apply to Boolean": {schema: ` type X { - dt1: Boolean @search(by: [year]) - dt2: Boolean @search(by: [month]) - dt3: Boolean @search(by: [day]) - dt4: Boolean @search(by: [hour]) + dt1: Boolean @search(by: ["year"]) + dt2: Boolean @search(by: ["month"]) + dt3: Boolean @search(by: ["day"]) + dt4: Boolean @search(by: ["hour"]) }`, expectedErrors: 4}, "DateTime searches don't apply to String": {schema: ` type X { - dt1: String @search(by: [year]) - dt2: String @search(by: [month]) - dt3: String @search(by: [day]) - dt4: String @search(by: [hour]) + dt1: String @search(by: ["year"]) + dt2: String @search(by: ["month"]) + dt3: String @search(by: ["day"]) + dt4: String @search(by: ["hour"]) }`, expectedErrors: 4}, "Int searches only appy to Int": {schema: ` type X { - i1: Float @search(by: [int]) - i2: Boolean @search(by: [int]) - i3: String @search(by: [int]) - i4: DateTime @search(by: [int]) + i1: Float @search(by: ["int"]) + i2: Boolean @search(by: ["int"]) + i3: String @search(by: ["int"]) + i4: DateTime @search(by: ["int"]) }`, expectedErrors: 4}, "Float searches only appy to Float": {schema: ` type X { - f1: Int @search(by: [float]) - f2: Boolean @search(by: [float]) - f3: String @search(by: [float]) - f4: DateTime @search(by: [float]) + f1: Int @search(by: ["float"]) + f2: Boolean @search(by: ["float"]) + f3: String @search(by: ["float"]) + f4: DateTime @search(by: ["float"]) }`, expectedErrors: 4}, "Boolean searches only appy to Boolean": {schema: ` type X { - b1: Int @search(by: [bool]) - b2: Float @search(by: [bool]) - b3: String @search(by: [bool]) - b4: DateTime @search(by: [bool]) + b1: Int @search(by: ["bool"]) + b2: Float @search(by: ["bool"]) + b3: String @search(by: ["bool"]) + b4: DateTime @search(by: ["bool"]) }`, expectedErrors: 4}, "Enums can only have hash, exact, regexp and trigram": {schema: ` type X { - e1: E @search(by: [int]) - e2: E @search(by: [float]) - e3: E @search(by: [bool]) - e4: E @search(by: [year]) - e5: E @search(by: [month]) - e6: E @search(by: [day]) - e7: E @search(by: [hour]) - e9: E @search(by: [term]) - e10: E @search(by: [fulltext]) + e1: E @search(by: ["int"]) + e2: E @search(by: ["float"]) + e3: E @search(by: ["bool"]) + e4: E @search(by: ["year"]) + e5: E @search(by: ["month"]) + e6: E @search(by: ["day"]) + e7: E @search(by: ["hour"]) + e9: E @search(by: ["term"]) + e10: E @search(by: ["fulltext"]) } enum E { A diff --git a/graphql/schema/testdata/apolloservice/input/generate-directive.graphql b/graphql/schema/testdata/apolloservice/input/generate-directive.graphql index 0621754ede9..31c0921e842 100644 --- a/graphql/schema/testdata/apolloservice/input/generate-directive.graphql +++ b/graphql/schema/testdata/apolloservice/input/generate-directive.graphql @@ -6,7 +6,7 @@ interface Character @secret(field: "password") @generate( subscription: false ) { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends: [Character] } @@ -34,4 +34,4 @@ type Person @withSubscription @generate( ) { id: ID! name: String! -} \ No newline at end of file +} diff --git a/graphql/schema/testdata/apolloservice/output/auth-directive.graphql b/graphql/schema/testdata/apolloservice/output/auth-directive.graphql index 21d52d8d9b6..cdeadb65781 100644 --- a/graphql/schema/testdata/apolloservice/output/auth-directive.graphql +++ b/graphql/schema/testdata/apolloservice/output/auth-directive.graphql @@ -77,6 +77,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -190,7 +191,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/apolloservice/output/custom-directive.graphql b/graphql/schema/testdata/apolloservice/output/custom-directive.graphql index faee5eaf61d..f364c36eb7c 100644 --- a/graphql/schema/testdata/apolloservice/output/custom-directive.graphql +++ b/graphql/schema/testdata/apolloservice/output/custom-directive.graphql @@ -69,6 +69,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -182,7 +183,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/apolloservice/output/extended-types.graphql b/graphql/schema/testdata/apolloservice/output/extended-types.graphql index b7a32569364..36e0570cf56 100644 --- a/graphql/schema/testdata/apolloservice/output/extended-types.graphql +++ b/graphql/schema/testdata/apolloservice/output/extended-types.graphql @@ -83,6 +83,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -196,7 +197,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/apolloservice/output/generate-directive.graphql b/graphql/schema/testdata/apolloservice/output/generate-directive.graphql index 6079d174dd3..8d6de91139a 100644 --- a/graphql/schema/testdata/apolloservice/output/generate-directive.graphql +++ b/graphql/schema/testdata/apolloservice/output/generate-directive.graphql @@ -4,14 +4,14 @@ interface Character @secret(field: "password") { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] friendsAggregate(filter: CharacterFilter): CharacterAggregateResult } type Human @secret(field: "password") { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] totalCredits: Int friendsAggregate(filter: CharacterFilter): CharacterAggregateResult @@ -79,6 +79,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -192,7 +193,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/apolloservice/output/single-extended-type.graphql b/graphql/schema/testdata/apolloservice/output/single-extended-type.graphql index d89b66ba2cd..4ee68beb65a 100644 --- a/graphql/schema/testdata/apolloservice/output/single-extended-type.graphql +++ b/graphql/schema/testdata/apolloservice/output/single-extended-type.graphql @@ -64,6 +64,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -177,7 +178,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/input/auth-on-interfaces.graphql b/graphql/schema/testdata/schemagen/input/auth-on-interfaces.graphql index 2a50a0f32bf..520f3f03de1 100644 --- a/graphql/schema/testdata/schemagen/input/auth-on-interfaces.graphql +++ b/graphql/schema/testdata/schemagen/input/auth-on-interfaces.graphql @@ -1,6 +1,6 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) posts: [Post] @hasInverse(field: author) } @@ -14,7 +14,7 @@ interface Post @secret(field: "pwd") @auth( }""" } ){ id: ID! - text: String @search(by: [exact]) + text: String @search(by: ["exact"]) datePublished: DateTime @search author: Author! } @@ -28,4 +28,4 @@ type Question implements Post @auth( }""" } ){ answered: Boolean @search -} \ No newline at end of file +} diff --git a/graphql/schema/testdata/schemagen/input/custom-dql-query-with-subscription.graphql b/graphql/schema/testdata/schemagen/input/custom-dql-query-with-subscription.graphql index 9e780434213..ecfb4a8d614 100644 --- a/graphql/schema/testdata/schemagen/input/custom-dql-query-with-subscription.graphql +++ b/graphql/schema/testdata/schemagen/input/custom-dql-query-with-subscription.graphql @@ -1,6 +1,6 @@ type Tweets { id: ID! - text: String! @search(by: [fulltext]) + text: String! @search(by: ["fulltext"]) author: User timestamp: DateTime! @search } diff --git a/graphql/schema/testdata/schemagen/input/embedding-directive-with-similar-queries.graphql b/graphql/schema/testdata/schemagen/input/embedding-directive-with-similar-queries.graphql index 8a267fe6dd7..7115399f67f 100644 --- a/graphql/schema/testdata/schemagen/input/embedding-directive-with-similar-queries.graphql +++ b/graphql/schema/testdata/schemagen/input/embedding-directive-with-similar-queries.graphql @@ -5,17 +5,17 @@ type Product { description: String title: String imageUrl: String - product_vector: [Float] @hm_embedding + product_vector: [Float!] @hm_embedding } type Purchase @lambdaOnMutate(add: true){ user: User @hasInverse(field: "purchase_history") product: Product - date: DateTime @search(by: [day]) + date: DateTime @search(by: ["day"]) } type User { email: String! @id purchase_history: [Purchase] - user_vector: [Float] @hm_embedding + user_vector: [Float!] @hm_embedding } diff --git a/graphql/schema/testdata/schemagen/input/field-with-id-directive.graphql b/graphql/schema/testdata/schemagen/input/field-with-id-directive.graphql index 19676b1d59e..f9cbb36528b 100644 --- a/graphql/schema/testdata/schemagen/input/field-with-id-directive.graphql +++ b/graphql/schema/testdata/schemagen/input/field-with-id-directive.graphql @@ -7,12 +7,12 @@ type Post { type Author { id: ID - name: String! @id @search(by: [regexp]) + name: String! @id @search(by: ["regexp"]) pen_name: String posts: [Post] } type Genre { # This will add exact index on name field, overwriting the default "hash" index for field of type "String! @id". - name: String! @id @search(by: [exact]) + name: String! @id @search(by: ["exact"]) } diff --git a/graphql/schema/testdata/schemagen/input/field-with-multiple-@id-fields.graphql b/graphql/schema/testdata/schemagen/input/field-with-multiple-@id-fields.graphql index 8aafec5cb50..fec558c654e 100644 --- a/graphql/schema/testdata/schemagen/input/field-with-multiple-@id-fields.graphql +++ b/graphql/schema/testdata/schemagen/input/field-with-multiple-@id-fields.graphql @@ -7,7 +7,7 @@ type Post { type Author { id: ID - name: String! @id @search(by: [regexp]) + name: String! @id @search(by: ["regexp"]) pen_name: String! @id posts: [Post] } diff --git a/graphql/schema/testdata/schemagen/input/generate-directive.graphql b/graphql/schema/testdata/schemagen/input/generate-directive.graphql index d45f95ace3e..31c0921e842 100644 --- a/graphql/schema/testdata/schemagen/input/generate-directive.graphql +++ b/graphql/schema/testdata/schemagen/input/generate-directive.graphql @@ -6,7 +6,7 @@ interface Character @secret(field: "password") @generate( subscription: false ) { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends: [Character] } diff --git a/graphql/schema/testdata/schemagen/input/hasInverse-with-interface-having-directive.graphql b/graphql/schema/testdata/schemagen/input/hasInverse-with-interface-having-directive.graphql index 3f2c1edc3ae..c4d7a55dfaf 100644 --- a/graphql/schema/testdata/schemagen/input/hasInverse-with-interface-having-directive.graphql +++ b/graphql/schema/testdata/schemagen/input/hasInverse-with-interface-having-directive.graphql @@ -1,12 +1,12 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) posts: [Post] } interface Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author: Author! @hasInverse(field: posts) } diff --git a/graphql/schema/testdata/schemagen/input/hasInverse-with-interface.graphql b/graphql/schema/testdata/schemagen/input/hasInverse-with-interface.graphql index 3c45c211b5c..632f70ab8c2 100644 --- a/graphql/schema/testdata/schemagen/input/hasInverse-with-interface.graphql +++ b/graphql/schema/testdata/schemagen/input/hasInverse-with-interface.graphql @@ -1,13 +1,13 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) questions: [Question] @hasInverse(field: author) answers: [Answer] @hasInverse(field: author) } interface Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author: Author! } diff --git a/graphql/schema/testdata/schemagen/input/hasInverse-with-type-having-directive.graphql b/graphql/schema/testdata/schemagen/input/hasInverse-with-type-having-directive.graphql index bf149c03498..aa72ef8e547 100644 --- a/graphql/schema/testdata/schemagen/input/hasInverse-with-type-having-directive.graphql +++ b/graphql/schema/testdata/schemagen/input/hasInverse-with-type-having-directive.graphql @@ -1,12 +1,12 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) posts: [Post] @hasInverse(field: author) } interface Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author: Author! } diff --git a/graphql/schema/testdata/schemagen/input/interfaces-with-types-and-password.graphql b/graphql/schema/testdata/schemagen/input/interfaces-with-types-and-password.graphql index 24a041d50bd..38a4343a35d 100644 --- a/graphql/schema/testdata/schemagen/input/interfaces-with-types-and-password.graphql +++ b/graphql/schema/testdata/schemagen/input/interfaces-with-types-and-password.graphql @@ -1,6 +1,6 @@ interface Character @secret(field: "password") { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends: [Character] appearsIn: [Episode!]! @search } @@ -22,6 +22,6 @@ enum Episode { type Starship { id: ID! - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) length: Float } diff --git a/graphql/schema/testdata/schemagen/input/interfaces-with-types.graphql b/graphql/schema/testdata/schemagen/input/interfaces-with-types.graphql index 75d2ae6cd4e..8ad64b93249 100644 --- a/graphql/schema/testdata/schemagen/input/interfaces-with-types.graphql +++ b/graphql/schema/testdata/schemagen/input/interfaces-with-types.graphql @@ -1,6 +1,6 @@ interface Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends: [Character] appearsIn: [Episode!]! @search } @@ -22,6 +22,6 @@ enum Episode { type Starship { id: ID! - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) length: Float } diff --git a/graphql/schema/testdata/schemagen/input/language-tags.graphql b/graphql/schema/testdata/schemagen/input/language-tags.graphql index 97257697b46..ee7ae7e869e 100644 --- a/graphql/schema/testdata/schemagen/input/language-tags.graphql +++ b/graphql/schema/testdata/schemagen/input/language-tags.graphql @@ -12,14 +12,14 @@ type Person implements Node { f3: String @dgraph(pred: "f3@en") name: String! @id # We can have exact index on language tagged field while having hash index on language untagged field - nameHi: String @dgraph(pred: "Person.name@hi") @search(by: [term, exact]) - nameEn: String @dgraph(pred: "Person.name@en") @search(by: [regexp]) + nameHi: String @dgraph(pred: "Person.name@hi") @search(by: ["term", "exact"]) + nameEn: String @dgraph(pred: "Person.name@en") @search(by: ["regexp"]) # Below Fields nameHiEn,nameHi_En_Untag won't be added to update/add mutation/ref type # and also to filters, order as they corresponds to multiple language tags nameHiEn: String @dgraph(pred: "Person.name@hi:en") nameHi_En_Untag: String @dgraph(pred: "Person.name@hi:en:.") name_Untag_AnyLang: String @dgraph(pred: "Person.name@.") - address: String @search(by: [fulltext]) + address: String @search(by: ["fulltext"]) addressHi: String @dgraph(pred: "Person.address@hi") # We can have language tag field without corresponding language untagged field # We will generate the correct DQL schema diff --git a/graphql/schema/testdata/schemagen/input/searchables-references.graphql b/graphql/schema/testdata/schemagen/input/searchables-references.graphql index fbac2b2cfee..06ab87fba2e 100644 --- a/graphql/schema/testdata/schemagen/input/searchables-references.graphql +++ b/graphql/schema/testdata/schemagen/input/searchables-references.graphql @@ -1,13 +1,13 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) dob: DateTime # Have something not search posts: [Post] # This should have arguments added for a filter on Post } type Post { postID: ID! - title: String! @search(by: [term, fulltext]) - text: String @search(by: [fulltext, term]) + title: String! @search(by: ["term", "fulltext"]) + text: String @search(by: ["fulltext", "term"]) datePublished: DateTime # Have something not search } diff --git a/graphql/schema/testdata/schemagen/input/searchables.graphql b/graphql/schema/testdata/schemagen/input/searchables.graphql index bc704585127..8a12b1ae628 100644 --- a/graphql/schema/testdata/schemagen/input/searchables.graphql +++ b/graphql/schema/testdata/schemagen/input/searchables.graphql @@ -1,20 +1,20 @@ type Post { postID: ID! - title: String! @search(by: [term]) - titleByEverything: String! @search(by: [term, fulltext, trigram, hash]) - text: String @search(by: [fulltext]) + title: String! @search(by: ["term"]) + titleByEverything: String! @search(by: ["term", "fulltext", "trigram", "hash"]) + text: String @search(by: ["fulltext"]) - tags: [String] @search(by: [trigram]) - tagsHash: [String] @search(by: [hash]) - tagsExact: [String] @search(by: [exact]) + tags: [String] @search(by: ["trigram"]) + tagsHash: [String] @search(by: ["hash"]) + tagsExact: [String] @search(by: ["exact"]) - publishByYear: DateTime @search(by: [year]) - publishByMonth: DateTime @search(by: [month]) - publishByDay: DateTime @search(by: [day]) - publishByHour: DateTime @search(by: [hour]) + publishByYear: DateTime @search(by: ["year"]) + publishByMonth: DateTime @search(by: ["month"]) + publishByDay: DateTime @search(by: ["day"]) + publishByHour: DateTime @search(by: ["hour"]) publishTimestamp: Int64 @search - numViewers: Int64 @search(by: [int64]) + numViewers: Int64 @search(by: ["int64"]) numLikes: Int @search score: Float @search isPublished: Boolean @search @@ -22,12 +22,12 @@ type Post { postType: PostType @search postTypeNonNull: PostType! @search postTypeList: [PostType] @search - postTypeTrigram: PostType @search(by: [trigram]) - postTypeRegexp: PostType @search(by: [regexp]) - postTypeExact: [PostType] @search(by: [exact]) - postTypeHash: PostType @search(by: [hash]) - postTypeRegexpExact: PostType @search(by: [exact, regexp]) - postTypeHashRegexp: PostType @search(by: [hash, regexp]) + postTypeTrigram: PostType @search(by: ["trigram"]) + postTypeRegexp: PostType @search(by: ["regexp"]) + postTypeExact: [PostType] @search(by: ["exact"]) + postTypeHash: PostType @search(by: ["hash"]) + postTypeRegexpExact: PostType @search(by: ["exact", "regexp"]) + postTypeHashRegexp: PostType @search(by: ["hash", "regexp"]) postTypeNone: PostType @search(by: []) } diff --git a/graphql/schema/testdata/schemagen/input/type-implements-multiple-interfaces.graphql b/graphql/schema/testdata/schemagen/input/type-implements-multiple-interfaces.graphql index 91cd15ad088..0b14ea88fd1 100644 --- a/graphql/schema/testdata/schemagen/input/type-implements-multiple-interfaces.graphql +++ b/graphql/schema/testdata/schemagen/input/type-implements-multiple-interfaces.graphql @@ -1,6 +1,6 @@ interface Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends: [Character] } diff --git a/graphql/schema/testdata/schemagen/input/union.graphql b/graphql/schema/testdata/schemagen/input/union.graphql index ee36d9f3cc7..880db8fe792 100644 --- a/graphql/schema/testdata/schemagen/input/union.graphql +++ b/graphql/schema/testdata/schemagen/input/union.graphql @@ -1,6 +1,6 @@ interface Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends: [Character] enemyOf: Resident appearsIn: [Episode!]! @search @@ -23,7 +23,7 @@ enum Episode { type Starship { id: ID! - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) length: Float } @@ -38,4 +38,4 @@ type Planet { url: "http://mock:8888/tool/$id" method: "GET" }) -} \ No newline at end of file +} diff --git a/graphql/schema/testdata/schemagen/output/apollo-federation.graphql b/graphql/schema/testdata/schemagen/output/apollo-federation.graphql index d9cfdb3a3d6..5e1d58a5b21 100644 --- a/graphql/schema/testdata/schemagen/output/apollo-federation.graphql +++ b/graphql/schema/testdata/schemagen/output/apollo-federation.graphql @@ -99,6 +99,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -212,7 +213,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/auth-on-interfaces.graphql b/graphql/schema/testdata/schemagen/output/auth-on-interfaces.graphql index 0d04be6138d..8621adc4870 100644 --- a/graphql/schema/testdata/schemagen/output/auth-on-interfaces.graphql +++ b/graphql/schema/testdata/schemagen/output/auth-on-interfaces.graphql @@ -4,21 +4,21 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) posts(filter: PostFilter, order: PostOrder, first: Int, offset: Int): [Post] @hasInverse(field: author) postsAggregate(filter: PostFilter): PostAggregateResult } interface Post @secret(field: "pwd") @auth(password: {rule:"{$ROLE: { eq: \"Admin\" } }"}, query: {rule:"query($TEXT: String!) { \n queryPost(filter: { text : {eq: $TEXT } } ) { \n id \n } \n}"}) { id: ID! - text: String @search(by: [exact]) + text: String @search(by: ["exact"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: posts) } type Question implements Post @auth(query: {rule:"query($ANS: Boolean!) { \n queryQuestion(filter: { answered: $ANS } ) { \n id \n } \n}"}) @secret(field: "pwd") { id: ID! - text: String @search(by: [exact]) + text: String @search(by: ["exact"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: posts) answered: Boolean @search @@ -81,6 +81,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -194,7 +195,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/authorization.graphql b/graphql/schema/testdata/schemagen/output/authorization.graphql index 2d8fc5fdd5f..7e43fe39b88 100644 --- a/graphql/schema/testdata/schemagen/output/authorization.graphql +++ b/graphql/schema/testdata/schemagen/output/authorization.graphql @@ -77,6 +77,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -190,7 +191,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/comments-and-descriptions.graphql b/graphql/schema/testdata/schemagen/output/comments-and-descriptions.graphql old mode 100755 new mode 100644 index 0ca61e96780..6f4403b2f48 --- a/graphql/schema/testdata/schemagen/output/comments-and-descriptions.graphql +++ b/graphql/schema/testdata/schemagen/output/comments-and-descriptions.graphql @@ -90,6 +90,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -203,7 +204,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/custom-dql-query-with-subscription.graphql b/graphql/schema/testdata/schemagen/output/custom-dql-query-with-subscription.graphql old mode 100755 new mode 100644 index 1a62284955d..9560aea2fb1 --- a/graphql/schema/testdata/schemagen/output/custom-dql-query-with-subscription.graphql +++ b/graphql/schema/testdata/schemagen/output/custom-dql-query-with-subscription.graphql @@ -4,7 +4,7 @@ type Tweets { id: ID! - text: String! @search(by: [fulltext]) + text: String! @search(by: ["fulltext"]) author(filter: UserFilter): User @hasInverse(field: tweets) timestamp: DateTime! @search } @@ -78,6 +78,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -191,7 +192,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/custom-mutation.graphql b/graphql/schema/testdata/schemagen/output/custom-mutation.graphql index 06d28ca678d..6705de890be 100644 --- a/graphql/schema/testdata/schemagen/output/custom-mutation.graphql +++ b/graphql/schema/testdata/schemagen/output/custom-mutation.graphql @@ -68,6 +68,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -181,7 +182,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/custom-nested-types.graphql b/graphql/schema/testdata/schemagen/output/custom-nested-types.graphql old mode 100755 new mode 100644 index b90a2968f9b..8f46b8aee23 --- a/graphql/schema/testdata/schemagen/output/custom-nested-types.graphql +++ b/graphql/schema/testdata/schemagen/output/custom-nested-types.graphql @@ -85,6 +85,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -198,7 +199,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/custom-query-mixed-types.graphql b/graphql/schema/testdata/schemagen/output/custom-query-mixed-types.graphql index 2be0c1029a5..914af21638f 100644 --- a/graphql/schema/testdata/schemagen/output/custom-query-mixed-types.graphql +++ b/graphql/schema/testdata/schemagen/output/custom-query-mixed-types.graphql @@ -69,6 +69,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -182,7 +183,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/custom-query-not-dgraph-type.graphql b/graphql/schema/testdata/schemagen/output/custom-query-not-dgraph-type.graphql old mode 100755 new mode 100644 index 2bc65e9c153..09cb47032f1 --- a/graphql/schema/testdata/schemagen/output/custom-query-not-dgraph-type.graphql +++ b/graphql/schema/testdata/schemagen/output/custom-query-not-dgraph-type.graphql @@ -68,6 +68,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -181,7 +182,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/custom-query-with-dgraph-type.graphql b/graphql/schema/testdata/schemagen/output/custom-query-with-dgraph-type.graphql old mode 100755 new mode 100644 index d9d610b6610..d4ce1e6265c --- a/graphql/schema/testdata/schemagen/output/custom-query-with-dgraph-type.graphql +++ b/graphql/schema/testdata/schemagen/output/custom-query-with-dgraph-type.graphql @@ -64,6 +64,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -177,7 +178,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/deprecated.graphql b/graphql/schema/testdata/schemagen/output/deprecated.graphql old mode 100755 new mode 100644 index 7c8d6f31e92..5aece8aa338 --- a/graphql/schema/testdata/schemagen/output/deprecated.graphql +++ b/graphql/schema/testdata/schemagen/output/deprecated.graphql @@ -64,6 +64,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -177,7 +178,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/dgraph-reverse-directive-on-concrete-type-with-interfaces.graphql b/graphql/schema/testdata/schemagen/output/dgraph-reverse-directive-on-concrete-type-with-interfaces.graphql old mode 100755 new mode 100644 index 954aee7c876..064de56fe5c --- a/graphql/schema/testdata/schemagen/output/dgraph-reverse-directive-on-concrete-type-with-interfaces.graphql +++ b/graphql/schema/testdata/schemagen/output/dgraph-reverse-directive-on-concrete-type-with-interfaces.graphql @@ -81,6 +81,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -194,7 +195,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/dgraph-reverse-directive-with-interfaces.graphql b/graphql/schema/testdata/schemagen/output/dgraph-reverse-directive-with-interfaces.graphql old mode 100755 new mode 100644 index 1c001e3ba2b..fd45bb1ddc6 --- a/graphql/schema/testdata/schemagen/output/dgraph-reverse-directive-with-interfaces.graphql +++ b/graphql/schema/testdata/schemagen/output/dgraph-reverse-directive-with-interfaces.graphql @@ -81,6 +81,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -194,7 +195,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/embedding-directive-with-similar-queries.graphql b/graphql/schema/testdata/schemagen/output/embedding-directive-with-similar-queries.graphql index 205d6426a59..6f6c3e2183a 100644 --- a/graphql/schema/testdata/schemagen/output/embedding-directive-with-similar-queries.graphql +++ b/graphql/schema/testdata/schemagen/output/embedding-directive-with-similar-queries.graphql @@ -7,19 +7,19 @@ type Product { description: String title: String imageUrl: String - product_vector: [Float] @hm_embedding + product_vector: [Float!] @hm_embedding } type Purchase @lambdaOnMutate(add: true) { user(filter: UserFilter): User @hasInverse(field: "purchase_history") product(filter: ProductFilter): Product - date: DateTime @search(by: [day]) + date: DateTime @search(by: ["day"]) } type User { email: String! @id purchase_history(filter: PurchaseFilter, order: PurchaseOrder, first: Int, offset: Int): [Purchase] @hasInverse(field: user) - user_vector: [Float] @hm_embedding + user_vector: [Float!] @hm_embedding purchase_historyAggregate(filter: PurchaseFilter): PurchaseAggregateResult } @@ -80,6 +80,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -193,7 +194,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION @@ -340,7 +341,7 @@ type ProductWithDistance @dgraph(type: "Product") { description: String title: String imageUrl: String - product_vector: [Float] @hm_embedding + product_vector: [Float!] @hm_embedding hm_distance: Float } @@ -374,7 +375,7 @@ type UserAggregateResult { type UserWithDistance @dgraph(type: "User") { email: String! @id purchase_history(filter: PurchaseFilter, order: PurchaseOrder, first: Int, offset: Int): [Purchase] @hasInverse(field: user) - user_vector: [Float] @hm_embedding + user_vector: [Float!] @hm_embedding purchase_historyAggregate(filter: PurchaseFilter): PurchaseAggregateResult } @@ -434,7 +435,7 @@ input AddProductInput { description: String title: String imageUrl: String - product_vector: [Float] + product_vector: [Float!] } input AddPurchaseInput { @@ -446,7 +447,7 @@ input AddPurchaseInput { input AddUserInput { email: String! purchase_history: [PurchaseRef] - user_vector: [Float] + user_vector: [Float!] } input ProductFilter { @@ -467,7 +468,7 @@ input ProductPatch { description: String title: String imageUrl: String - product_vector: [Float] + product_vector: [Float!] } input ProductRef { @@ -475,7 +476,7 @@ input ProductRef { description: String title: String imageUrl: String - product_vector: [Float] + product_vector: [Float!] } input PurchaseFilter { @@ -538,13 +539,13 @@ input UserOrder { input UserPatch { purchase_history: [PurchaseRef] - user_vector: [Float] + user_vector: [Float!] } input UserRef { email: String purchase_history: [PurchaseRef] - user_vector: [Float] + user_vector: [Float!] } ####################### diff --git a/graphql/schema/testdata/schemagen/output/field-with-id-directive.graphql b/graphql/schema/testdata/schemagen/output/field-with-id-directive.graphql old mode 100755 new mode 100644 index beecdfa3148..d32fbd90d7b --- a/graphql/schema/testdata/schemagen/output/field-with-id-directive.graphql +++ b/graphql/schema/testdata/schemagen/output/field-with-id-directive.graphql @@ -11,14 +11,14 @@ type Post { type Author { id: ID - name: String! @id @search(by: [regexp]) + name: String! @id @search(by: ["regexp"]) pen_name: String posts(filter: PostFilter, order: PostOrder, first: Int, offset: Int): [Post] postsAggregate(filter: PostFilter): PostAggregateResult } type Genre { - name: String! @id @search(by: [exact]) + name: String! @id @search(by: ["exact"]) } ####################### @@ -78,6 +78,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -191,7 +192,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/field-with-multiple-@id-fields.graphql b/graphql/schema/testdata/schemagen/output/field-with-multiple-@id-fields.graphql old mode 100755 new mode 100644 index c900da9a382..c00ed51e4f2 --- a/graphql/schema/testdata/schemagen/output/field-with-multiple-@id-fields.graphql +++ b/graphql/schema/testdata/schemagen/output/field-with-multiple-@id-fields.graphql @@ -11,7 +11,7 @@ type Post { type Author { id: ID - name: String! @id @search(by: [regexp]) + name: String! @id @search(by: ["regexp"]) pen_name: String! @id posts(filter: PostFilter, order: PostOrder, first: Int, offset: Int): [Post] postsAggregate(filter: PostFilter): PostAggregateResult @@ -78,6 +78,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -191,7 +192,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/field-with-reverse-predicate-in-dgraph-directive.graphql b/graphql/schema/testdata/schemagen/output/field-with-reverse-predicate-in-dgraph-directive.graphql old mode 100755 new mode 100644 index df233160251..0e792bc93e5 --- a/graphql/schema/testdata/schemagen/output/field-with-reverse-predicate-in-dgraph-directive.graphql +++ b/graphql/schema/testdata/schemagen/output/field-with-reverse-predicate-in-dgraph-directive.graphql @@ -73,6 +73,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -186,7 +187,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/filter-cleanSchema-all-empty.graphql b/graphql/schema/testdata/schemagen/output/filter-cleanSchema-all-empty.graphql index 3edc81e66a8..4d11af5aec5 100644 --- a/graphql/schema/testdata/schemagen/output/filter-cleanSchema-all-empty.graphql +++ b/graphql/schema/testdata/schemagen/output/filter-cleanSchema-all-empty.graphql @@ -76,6 +76,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -189,7 +190,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/filter-cleanSchema-circular.graphql b/graphql/schema/testdata/schemagen/output/filter-cleanSchema-circular.graphql index cb02a65c8c8..733e141fa1d 100644 --- a/graphql/schema/testdata/schemagen/output/filter-cleanSchema-circular.graphql +++ b/graphql/schema/testdata/schemagen/output/filter-cleanSchema-circular.graphql @@ -80,6 +80,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -193,7 +194,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/filter-cleanSchema-custom-mutation.graphql b/graphql/schema/testdata/schemagen/output/filter-cleanSchema-custom-mutation.graphql index ff7aa950e48..7214038a78c 100644 --- a/graphql/schema/testdata/schemagen/output/filter-cleanSchema-custom-mutation.graphql +++ b/graphql/schema/testdata/schemagen/output/filter-cleanSchema-custom-mutation.graphql @@ -68,6 +68,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -181,7 +182,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/filter-cleanSchema-directLink.graphql b/graphql/schema/testdata/schemagen/output/filter-cleanSchema-directLink.graphql index dc802d622d7..51d9632b963 100644 --- a/graphql/schema/testdata/schemagen/output/filter-cleanSchema-directLink.graphql +++ b/graphql/schema/testdata/schemagen/output/filter-cleanSchema-directLink.graphql @@ -78,6 +78,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -191,7 +192,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/generate-directive.graphql b/graphql/schema/testdata/schemagen/output/generate-directive.graphql index 46ebace514f..837390df513 100644 --- a/graphql/schema/testdata/schemagen/output/generate-directive.graphql +++ b/graphql/schema/testdata/schemagen/output/generate-directive.graphql @@ -4,14 +4,14 @@ interface Character @secret(field: "password") @generate(query: {get:false,password:false}, subscription: false) { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] friendsAggregate(filter: CharacterFilter): CharacterAggregateResult } type Human implements Character @generate(query: {aggregate:true}, subscription: true) @secret(field: "password") { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] totalCredits: Int friendsAggregate(filter: CharacterFilter): CharacterAggregateResult @@ -79,6 +79,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -192,7 +193,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/geo-type.graphql b/graphql/schema/testdata/schemagen/output/geo-type.graphql index de3e69e8f80..676d3d70e2e 100644 --- a/graphql/schema/testdata/schemagen/output/geo-type.graphql +++ b/graphql/schema/testdata/schemagen/output/geo-type.graphql @@ -70,6 +70,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -183,7 +184,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/hasInverse-with-interface-having-directive.graphql b/graphql/schema/testdata/schemagen/output/hasInverse-with-interface-having-directive.graphql old mode 100755 new mode 100644 index 3a0e3c1dcff..f655010f961 --- a/graphql/schema/testdata/schemagen/output/hasInverse-with-interface-having-directive.graphql +++ b/graphql/schema/testdata/schemagen/output/hasInverse-with-interface-having-directive.graphql @@ -4,21 +4,21 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) posts(filter: PostFilter, order: PostOrder, first: Int, offset: Int): [Post] @hasInverse(field: author) postsAggregate(filter: PostFilter): PostAggregateResult } interface Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: posts) } type Question implements Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: posts) answered: Boolean @@ -26,7 +26,7 @@ type Question implements Post { type Answer implements Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: posts) markedUseful: Boolean @@ -89,6 +89,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -202,7 +203,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/hasInverse-with-interface.graphql b/graphql/schema/testdata/schemagen/output/hasInverse-with-interface.graphql old mode 100755 new mode 100644 index 4fecdc70a88..abe50f88d35 --- a/graphql/schema/testdata/schemagen/output/hasInverse-with-interface.graphql +++ b/graphql/schema/testdata/schemagen/output/hasInverse-with-interface.graphql @@ -4,7 +4,7 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) questions(filter: QuestionFilter, order: QuestionOrder, first: Int, offset: Int): [Question] @hasInverse(field: author) answers(filter: AnswerFilter, order: AnswerOrder, first: Int, offset: Int): [Answer] @hasInverse(field: author) questionsAggregate(filter: QuestionFilter): QuestionAggregateResult @@ -13,14 +13,14 @@ type Author { interface Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! } type Question implements Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: questions) answered: Boolean @@ -28,7 +28,7 @@ type Question implements Post { type Answer implements Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: answers) markedUseful: Boolean @@ -91,6 +91,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -204,7 +205,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/hasInverse-with-type-having-directive.graphql b/graphql/schema/testdata/schemagen/output/hasInverse-with-type-having-directive.graphql old mode 100755 new mode 100644 index 3a0e3c1dcff..f655010f961 --- a/graphql/schema/testdata/schemagen/output/hasInverse-with-type-having-directive.graphql +++ b/graphql/schema/testdata/schemagen/output/hasInverse-with-type-having-directive.graphql @@ -4,21 +4,21 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) posts(filter: PostFilter, order: PostOrder, first: Int, offset: Int): [Post] @hasInverse(field: author) postsAggregate(filter: PostFilter): PostAggregateResult } interface Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: posts) } type Question implements Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: posts) answered: Boolean @@ -26,7 +26,7 @@ type Question implements Post { type Answer implements Post { id: ID! - text: String @search(by: [fulltext]) + text: String @search(by: ["fulltext"]) datePublished: DateTime @search author(filter: AuthorFilter): Author! @hasInverse(field: posts) markedUseful: Boolean @@ -89,6 +89,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -202,7 +203,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/hasInverse.graphql b/graphql/schema/testdata/schemagen/output/hasInverse.graphql old mode 100755 new mode 100644 index 7085dc1c44f..ba9fa60d1d2 --- a/graphql/schema/testdata/schemagen/output/hasInverse.graphql +++ b/graphql/schema/testdata/schemagen/output/hasInverse.graphql @@ -70,6 +70,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -183,7 +184,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/hasInverse_withSubscription.graphql b/graphql/schema/testdata/schemagen/output/hasInverse_withSubscription.graphql old mode 100755 new mode 100644 index c5366c0976f..30d5a7f2d1b --- a/graphql/schema/testdata/schemagen/output/hasInverse_withSubscription.graphql +++ b/graphql/schema/testdata/schemagen/output/hasInverse_withSubscription.graphql @@ -70,6 +70,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -183,7 +184,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/hasfilter.graphql b/graphql/schema/testdata/schemagen/output/hasfilter.graphql index 74c1a475b4b..ffb8bb6080b 100644 --- a/graphql/schema/testdata/schemagen/output/hasfilter.graphql +++ b/graphql/schema/testdata/schemagen/output/hasfilter.graphql @@ -72,6 +72,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -185,7 +186,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/ignore-unsupported-directive.graphql b/graphql/schema/testdata/schemagen/output/ignore-unsupported-directive.graphql old mode 100755 new mode 100644 index df3262368c0..009d67edc9d --- a/graphql/schema/testdata/schemagen/output/ignore-unsupported-directive.graphql +++ b/graphql/schema/testdata/schemagen/output/ignore-unsupported-directive.graphql @@ -71,6 +71,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -184,7 +185,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/interface-with-dgraph-pred.graphql b/graphql/schema/testdata/schemagen/output/interface-with-dgraph-pred.graphql index a915812c3a7..7c17e9ee928 100644 --- a/graphql/schema/testdata/schemagen/output/interface-with-dgraph-pred.graphql +++ b/graphql/schema/testdata/schemagen/output/interface-with-dgraph-pred.graphql @@ -80,6 +80,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -193,7 +194,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/interface-with-id-directive.graphql b/graphql/schema/testdata/schemagen/output/interface-with-id-directive.graphql old mode 100755 new mode 100644 index eb2d4b277a8..1b57c8256bf --- a/graphql/schema/testdata/schemagen/output/interface-with-id-directive.graphql +++ b/graphql/schema/testdata/schemagen/output/interface-with-id-directive.graphql @@ -76,6 +76,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -189,7 +190,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/interface-with-no-ids.graphql b/graphql/schema/testdata/schemagen/output/interface-with-no-ids.graphql old mode 100755 new mode 100644 index a49d47feefd..8c365964d7a --- a/graphql/schema/testdata/schemagen/output/interface-with-no-ids.graphql +++ b/graphql/schema/testdata/schemagen/output/interface-with-no-ids.graphql @@ -74,6 +74,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -187,7 +188,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/interfaces-with-types-and-password.graphql b/graphql/schema/testdata/schemagen/output/interfaces-with-types-and-password.graphql old mode 100755 new mode 100644 index a6df4ec85bb..b1e89feb689 --- a/graphql/schema/testdata/schemagen/output/interfaces-with-types-and-password.graphql +++ b/graphql/schema/testdata/schemagen/output/interfaces-with-types-and-password.graphql @@ -4,7 +4,7 @@ interface Character @secret(field: "password") { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] appearsIn: [Episode!]! @search friendsAggregate(filter: CharacterFilter): CharacterAggregateResult @@ -12,7 +12,7 @@ interface Character @secret(field: "password") { type Human implements Character @secret(field: "password") { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] appearsIn: [Episode!]! @search starships(filter: StarshipFilter, order: StarshipOrder, first: Int, offset: Int): [Starship] @@ -23,7 +23,7 @@ type Human implements Character @secret(field: "password") { type Droid implements Character @secret(field: "password") { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] appearsIn: [Episode!]! @search primaryFunction: String @@ -38,7 +38,7 @@ enum Episode { type Starship { id: ID! - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) length: Float } @@ -99,6 +99,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -212,7 +213,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/interfaces-with-types.graphql b/graphql/schema/testdata/schemagen/output/interfaces-with-types.graphql old mode 100755 new mode 100644 index bed253f757d..22d7356b93d --- a/graphql/schema/testdata/schemagen/output/interfaces-with-types.graphql +++ b/graphql/schema/testdata/schemagen/output/interfaces-with-types.graphql @@ -4,7 +4,7 @@ interface Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] appearsIn: [Episode!]! @search friendsAggregate(filter: CharacterFilter): CharacterAggregateResult @@ -12,7 +12,7 @@ interface Character { type Human implements Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] appearsIn: [Episode!]! @search starships(filter: StarshipFilter, order: StarshipOrder, first: Int, offset: Int): [Starship] @@ -23,7 +23,7 @@ type Human implements Character { type Droid implements Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] appearsIn: [Episode!]! @search primaryFunction: String @@ -38,7 +38,7 @@ enum Episode { type Starship { id: ID! - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) length: Float } @@ -99,6 +99,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -212,7 +213,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/lambda-directive.graphql b/graphql/schema/testdata/schemagen/output/lambda-directive.graphql index e7d78020a6e..228b7c3272e 100644 --- a/graphql/schema/testdata/schemagen/output/lambda-directive.graphql +++ b/graphql/schema/testdata/schemagen/output/lambda-directive.graphql @@ -66,6 +66,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -179,7 +180,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/language-tags.graphql b/graphql/schema/testdata/schemagen/output/language-tags.graphql old mode 100755 new mode 100644 index a8d49f7089c..6367f535c52 --- a/graphql/schema/testdata/schemagen/output/language-tags.graphql +++ b/graphql/schema/testdata/schemagen/output/language-tags.graphql @@ -12,12 +12,12 @@ type Person implements Node { f2: String @dgraph(pred: "T.f@no") f3: String @dgraph(pred: "f3@en") name: String! @id - nameHi: String @dgraph(pred: "Person.name@hi") @search(by: [term,exact]) - nameEn: String @dgraph(pred: "Person.name@en") @search(by: [regexp]) + nameHi: String @dgraph(pred: "Person.name@hi") @search(by: ["term","exact"]) + nameEn: String @dgraph(pred: "Person.name@en") @search(by: ["regexp"]) nameHiEn: String @dgraph(pred: "Person.name@hi:en") nameHi_En_Untag: String @dgraph(pred: "Person.name@hi:en:.") name_Untag_AnyLang: String @dgraph(pred: "Person.name@.") - address: String @search(by: [fulltext]) + address: String @search(by: ["fulltext"]) addressHi: String @dgraph(pred: "Person.address@hi") professionEn: String @dgraph(pred: "Person.profession@en") } @@ -79,6 +79,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -192,7 +193,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/no-id-field-with-searchables.graphql b/graphql/schema/testdata/schemagen/output/no-id-field-with-searchables.graphql old mode 100755 new mode 100644 index 056eb595595..e86e5f91fe9 --- a/graphql/schema/testdata/schemagen/output/no-id-field-with-searchables.graphql +++ b/graphql/schema/testdata/schemagen/output/no-id-field-with-searchables.graphql @@ -63,6 +63,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -176,7 +177,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/no-id-field.graphql b/graphql/schema/testdata/schemagen/output/no-id-field.graphql old mode 100755 new mode 100644 index fbd3b6e9961..c87e74c24ce --- a/graphql/schema/testdata/schemagen/output/no-id-field.graphql +++ b/graphql/schema/testdata/schemagen/output/no-id-field.graphql @@ -76,6 +76,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -189,7 +190,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/password-type.graphql b/graphql/schema/testdata/schemagen/output/password-type.graphql old mode 100755 new mode 100644 index 50fd9a43acc..b73cc040c76 --- a/graphql/schema/testdata/schemagen/output/password-type.graphql +++ b/graphql/schema/testdata/schemagen/output/password-type.graphql @@ -64,6 +64,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -177,7 +178,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/random.graphql b/graphql/schema/testdata/schemagen/output/random.graphql index 1883253acc9..00fca17f370 100644 --- a/graphql/schema/testdata/schemagen/output/random.graphql +++ b/graphql/schema/testdata/schemagen/output/random.graphql @@ -82,6 +82,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -195,7 +196,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/searchables-references.graphql b/graphql/schema/testdata/schemagen/output/searchables-references.graphql old mode 100755 new mode 100644 index 16e3cb98ed6..402ddb8bc9e --- a/graphql/schema/testdata/schemagen/output/searchables-references.graphql +++ b/graphql/schema/testdata/schemagen/output/searchables-references.graphql @@ -4,7 +4,7 @@ type Author { id: ID! - name: String! @search(by: [hash]) + name: String! @search(by: ["hash"]) dob: DateTime posts(filter: PostFilter, order: PostOrder, first: Int, offset: Int): [Post] postsAggregate(filter: PostFilter): PostAggregateResult @@ -12,8 +12,8 @@ type Author { type Post { postID: ID! - title: String! @search(by: [term,fulltext]) - text: String @search(by: [fulltext,term]) + title: String! @search(by: ["term","fulltext"]) + text: String @search(by: ["fulltext","term"]) datePublished: DateTime } @@ -74,6 +74,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -187,7 +188,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/searchables.graphql b/graphql/schema/testdata/schemagen/output/searchables.graphql old mode 100755 new mode 100644 index d0253dece91..398c6c5f105 --- a/graphql/schema/testdata/schemagen/output/searchables.graphql +++ b/graphql/schema/testdata/schemagen/output/searchables.graphql @@ -4,30 +4,30 @@ type Post { postID: ID! - title: String! @search(by: [term]) - titleByEverything: String! @search(by: [term,fulltext,trigram,hash]) - text: String @search(by: [fulltext]) - tags: [String] @search(by: [trigram]) - tagsHash: [String] @search(by: [hash]) - tagsExact: [String] @search(by: [exact]) - publishByYear: DateTime @search(by: [year]) - publishByMonth: DateTime @search(by: [month]) - publishByDay: DateTime @search(by: [day]) - publishByHour: DateTime @search(by: [hour]) + title: String! @search(by: ["term"]) + titleByEverything: String! @search(by: ["term","fulltext","trigram","hash"]) + text: String @search(by: ["fulltext"]) + tags: [String] @search(by: ["trigram"]) + tagsHash: [String] @search(by: ["hash"]) + tagsExact: [String] @search(by: ["exact"]) + publishByYear: DateTime @search(by: ["year"]) + publishByMonth: DateTime @search(by: ["month"]) + publishByDay: DateTime @search(by: ["day"]) + publishByHour: DateTime @search(by: ["hour"]) publishTimestamp: Int64 @search - numViewers: Int64 @search(by: [int64]) + numViewers: Int64 @search(by: ["int64"]) numLikes: Int @search score: Float @search isPublished: Boolean @search postType: PostType @search postTypeNonNull: PostType! @search postTypeList: [PostType] @search - postTypeTrigram: PostType @search(by: [trigram]) - postTypeRegexp: PostType @search(by: [regexp]) - postTypeExact: [PostType] @search(by: [exact]) - postTypeHash: PostType @search(by: [hash]) - postTypeRegexpExact: PostType @search(by: [exact,regexp]) - postTypeHashRegexp: PostType @search(by: [hash,regexp]) + postTypeTrigram: PostType @search(by: ["trigram"]) + postTypeRegexp: PostType @search(by: ["regexp"]) + postTypeExact: [PostType] @search(by: ["exact"]) + postTypeHash: PostType @search(by: ["hash"]) + postTypeRegexpExact: PostType @search(by: ["exact","regexp"]) + postTypeHashRegexp: PostType @search(by: ["hash","regexp"]) postTypeNone: PostType @search(by: []) } @@ -94,6 +94,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -207,7 +208,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/single-type-with-enum.graphql b/graphql/schema/testdata/schemagen/output/single-type-with-enum.graphql old mode 100755 new mode 100644 index 2fa9e7f8ef7..4f0ab5c15a4 --- a/graphql/schema/testdata/schemagen/output/single-type-with-enum.graphql +++ b/graphql/schema/testdata/schemagen/output/single-type-with-enum.graphql @@ -72,6 +72,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -185,7 +186,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/single-type.graphql b/graphql/schema/testdata/schemagen/output/single-type.graphql old mode 100755 new mode 100644 index 28fae1ba7b0..ff86bbd0fd9 --- a/graphql/schema/testdata/schemagen/output/single-type.graphql +++ b/graphql/schema/testdata/schemagen/output/single-type.graphql @@ -67,6 +67,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -180,7 +181,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/type-implements-multiple-interfaces.graphql b/graphql/schema/testdata/schemagen/output/type-implements-multiple-interfaces.graphql old mode 100755 new mode 100644 index a165f859edb..5c7fd60680f --- a/graphql/schema/testdata/schemagen/output/type-implements-multiple-interfaces.graphql +++ b/graphql/schema/testdata/schemagen/output/type-implements-multiple-interfaces.graphql @@ -4,7 +4,7 @@ interface Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] friendsAggregate(filter: CharacterFilter): CharacterAggregateResult } @@ -18,7 +18,7 @@ type Human implements Character & Employee { employeeId: String! title: String! id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] totalCredits: Int friendsAggregate(filter: CharacterFilter): CharacterAggregateResult @@ -81,6 +81,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -194,7 +195,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/type-reference.graphql b/graphql/schema/testdata/schemagen/output/type-reference.graphql old mode 100755 new mode 100644 index e12d8a7300f..35a4098f079 --- a/graphql/schema/testdata/schemagen/output/type-reference.graphql +++ b/graphql/schema/testdata/schemagen/output/type-reference.graphql @@ -71,6 +71,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -184,7 +185,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/type-with-arguments-on-field.graphql b/graphql/schema/testdata/schemagen/output/type-with-arguments-on-field.graphql index 7dbc6dd73fc..1519cb5e4c2 100644 --- a/graphql/schema/testdata/schemagen/output/type-with-arguments-on-field.graphql +++ b/graphql/schema/testdata/schemagen/output/type-with-arguments-on-field.graphql @@ -72,6 +72,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -185,7 +186,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/type-with-custom-field-on-dgraph-type.graphql b/graphql/schema/testdata/schemagen/output/type-with-custom-field-on-dgraph-type.graphql index b9ed4f1e665..a1c4095153e 100644 --- a/graphql/schema/testdata/schemagen/output/type-with-custom-field-on-dgraph-type.graphql +++ b/graphql/schema/testdata/schemagen/output/type-with-custom-field-on-dgraph-type.graphql @@ -71,6 +71,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -184,7 +185,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/type-with-custom-fields-on-remote-type.graphql b/graphql/schema/testdata/schemagen/output/type-with-custom-fields-on-remote-type.graphql index 463404f5488..926e2b8bafc 100644 --- a/graphql/schema/testdata/schemagen/output/type-with-custom-fields-on-remote-type.graphql +++ b/graphql/schema/testdata/schemagen/output/type-with-custom-fields-on-remote-type.graphql @@ -71,6 +71,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -184,7 +185,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/type-without-orderables.graphql b/graphql/schema/testdata/schemagen/output/type-without-orderables.graphql index ae5bc26ca2f..41e9a340588 100644 --- a/graphql/schema/testdata/schemagen/output/type-without-orderables.graphql +++ b/graphql/schema/testdata/schemagen/output/type-without-orderables.graphql @@ -66,6 +66,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -179,7 +180,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/testdata/schemagen/output/union.graphql b/graphql/schema/testdata/schemagen/output/union.graphql index 7155d1324d0..ba91c1433fc 100644 --- a/graphql/schema/testdata/schemagen/output/union.graphql +++ b/graphql/schema/testdata/schemagen/output/union.graphql @@ -4,7 +4,7 @@ interface Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] enemyOf(filter: ResidentFilter): Resident appearsIn: [Episode!]! @search @@ -13,7 +13,7 @@ interface Character { type Human implements Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] enemyOf(filter: ResidentFilter): Resident appearsIn: [Episode!]! @search @@ -25,7 +25,7 @@ type Human implements Character { type Droid implements Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) friends(filter: CharacterFilter, order: CharacterOrder, first: Int, offset: Int): [Character] enemyOf(filter: ResidentFilter): Resident appearsIn: [Episode!]! @search @@ -41,7 +41,7 @@ enum Episode { type Starship { id: ID! - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) length: Float } @@ -113,6 +113,7 @@ enum DgraphIndex { day hour geo + hnsw } input AuthRule { @@ -226,7 +227,7 @@ input GenerateMutationParams { } directive @hasInverse(field: String!) on FIELD_DEFINITION -directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION +directive @search(by: [String!]) on FIELD_DEFINITION directive @hm_embedding on FIELD_DEFINITION directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION directive @id(interface: Boolean) on FIELD_DEFINITION diff --git a/graphql/schema/wrappers_test.go b/graphql/schema/wrappers_test.go index b119842d41a..b356eb728ab 100644 --- a/graphql/schema/wrappers_test.go +++ b/graphql/schema/wrappers_test.go @@ -37,7 +37,7 @@ func TestDgraphMapping_WithoutDirectives(t *testing.T) { type Author { id: ID! - name: String! @search(by: [hash, trigram]) + name: String! @search(by: ["hash", "trigram"]) dob: DateTime @search reputation: Float @search posts: [Post!] @hasInverse(field: author) @@ -61,7 +61,7 @@ interface Employee { interface Character { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) appearsIn: [Episode!] @search } @@ -82,7 +82,7 @@ enum Episode { type Starship { id: ID! - name: String! @search(by: [term]) + name: String! @search(by: ["term"]) length: Float }` @@ -222,7 +222,7 @@ func TestDgraphMapping_WithDirectives(t *testing.T) { type Author @dgraph(type: "dgraph.author") { id: ID! - name: String! @search(by: [hash, trigram]) + name: String! @search(by: ["hash", "trigram"]) dob: DateTime @search reputation: Float @search posts: [Post!] @hasInverse(field: author) @@ -246,7 +246,7 @@ func TestDgraphMapping_WithDirectives(t *testing.T) { interface Character @dgraph(type: "performance.character") { id: ID! - name: String! @search(by: [exact]) + name: String! @search(by: ["exact"]) appearsIn: [Episode!] @search @dgraph(pred: "appears_in") } @@ -267,7 +267,7 @@ func TestDgraphMapping_WithDirectives(t *testing.T) { type Starship @dgraph(type: "star.ship") { id: ID! - name: String! @search(by: [term]) @dgraph(pred: "star.ship.name") + name: String! @search(by: ["term"]) @dgraph(pred: "star.ship.name") length: Float }` @@ -1007,7 +1007,7 @@ func TestAllowedHeadersList(t *testing.T) { } ) { username: String! @id - userRole: String @search(by: [hash]) + userRole: String @search(by: ["hash"]) } # Dgraph.Authorization {"VerificationKey":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsppQMzPRyYP9KcIAg4CG\nUV3NGCIRdi2PqkFAWzlyo0mpZlHf5Hxzqb7KMaXBt8Yh+1fbi9jcBbB4CYgbvgV0\n7pAZY/HE4ET9LqnjeF2sjmYiGVxLARv8MHXpNLcw7NGcL0FgSX7+B2PB2WjBPnJY\ndvaJ5tsT+AuZbySaJNS1Ha77lW6gy/dmBDybZ1UU+ixRjDWEqPmtD71g2Fpk8fgr\nReNm2h/ZQsJ19onFaGPQN6L6uJR+hfYN0xmOdTC21rXRMUJT8Pw9Xsi6wSt+tI4T\nKxDfMTxKksfjv93dnnof5zJtIcMFQlSKLOrgDC0WP07gVTR2b85tFod80ykevvgu\nAQIDAQAB\n-----END PUBLIC KEY-----","Header":"X-Test-Dgraph","Namespace":"https://dgraph.io/jwt/claims","Algo":"RS256"} `, diff --git a/systest/backup/common/utils.go b/systest/backup/common/utils.go index cab1b54004c..dc60fd2b81f 100644 --- a/systest/backup/common/utils.go +++ b/systest/backup/common/utils.go @@ -108,7 +108,7 @@ func AddItemSchema(t *testing.T, header http.Header, whichAlpha string) { updateSchemaParams := &common.GraphQLParams{ Query: `mutation { updateGQLSchema( - input: { set: { schema: "type Item {id: ID!, name: String! @search(by: [hash]), price: String!}"}}) + input: { set: { schema: "type Item {id: ID!, name: String! @search(by: [\"hash\"]), price: String!}"}}) { gqlSchema { schema diff --git a/systest/multi-tenancy/basic_test.go b/systest/multi-tenancy/basic_test.go index d3d15189bd7..a90b7b64240 100644 --- a/systest/multi-tenancy/basic_test.go +++ b/systest/multi-tenancy/basic_test.go @@ -194,7 +194,7 @@ func (msuite *MultitenancyTestSuite) TestPersistentQuery() { sch := `type Product { productID: ID! - name: String @search(by: [term]) + name: String @search(by: ["term"]) }` require.NoError(t, hcli1.UpdateGQLSchema(sch)) require.NoError(t, hcli2.UpdateGQLSchema(sch))