diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 288693cd7..b39ee0bf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,16 +16,16 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.22 - name: Run linters - uses: golangci/golangci-lint-action@v3.2.0 + uses: golangci/golangci-lint-action@v3.7.0 with: - version: v1.48.0 + version: v1.55.2 test: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.20', '1.21' ] + go: ['1.21', '1.22'] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 diff --git a/.golangci.yml b/.golangci.yml index 489c63651..a8ee70a8f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - go: '1.19' + go: '1.21' timeout: 10m linters-settings: @@ -25,13 +25,11 @@ linters: disable-all: true enable: - bodyclose - - deadcode - - depguard - dogsled - dupl - errcheck - gocritic - # - gofmt; Enable back when upgrading CI to Go 1.20. + - gofmt - goheader - gosec - gosimple @@ -39,12 +37,10 @@ linters: - ineffassign - misspell - staticcheck - - structcheck - stylecheck - typecheck - unconvert - unused - - varcheck - whitespace issues: diff --git a/entgql/internal/todo/ent.graphql b/entgql/internal/todo/ent.graphql index 35fe0f76b..204516c5d 100644 --- a/entgql/internal/todo/ent.graphql +++ b/entgql/internal/todo/ent.graphql @@ -1,18 +1,24 @@ -directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -"""Represents BillProduct object""" +directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @goModel(model: String, models: [String!], forceGenerate: Boolean) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +""" +Represents BillProduct object +""" type BillProduct implements Node { id: ID! name: String! sku: String! quantity: Uint64! } -"""BillProductWhereInput is used for filtering BillProduct objects.""" +""" +BillProductWhereInput is used for filtering BillProduct objects. +""" input BillProductWhereInput { not: BillProductWhereInput and: [BillProductWhereInput!] or: [BillProductWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -21,7 +27,9 @@ input BillProductWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -35,7 +43,9 @@ input BillProductWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """sku field predicates""" + """ + sku field predicates + """ sku: String skuNEQ: String skuIn: [String!] @@ -49,7 +59,9 @@ input BillProductWhereInput { skuHasSuffix: String skuEqualFold: String skuContainsFold: String - """quantity field predicates""" + """ + quantity field predicates + """ quantity: Uint64 quantityNEQ: Uint64 quantityIn: [Uint64!] @@ -59,75 +71,115 @@ input BillProductWhereInput { quantityLT: Uint64 quantityLTE: Uint64 } -"""Represents Category object""" +""" +Represents Category object +""" type Category implements Node { id: ID! text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList subCategories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type CategoryList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Category]! } -"""Ordering options for Category connections""" +""" +Ordering options for Category connections +""" input CategoryOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Categories.""" + """ + The field by which to order Categories. + """ field: CategoryOrderField! } -"""Properties by which Category connections can be ordered.""" +""" +Properties by which Category connections can be ordered. +""" enum CategoryOrderField { ID TEXT + STATUS DURATION COUNT TODOS_COUNT } -"""CategoryStatus is enum for the field status""" +""" +CategoryStatus is enum for the field status +""" enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { ENABLED DISABLED } -"""CategoryWhereInput is used for filtering Category objects.""" +""" +CategoryWhereInput is used for filtering Category objects. +""" input CategoryWhereInput { not: CategoryWhereInput and: [CategoryWhereInput!] or: [CategoryWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -136,7 +188,9 @@ input CategoryWhereInput { idGTE: ID idLT: ID idLTE: ID - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -150,12 +204,16 @@ input CategoryWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """status field predicates""" + """ + status field predicates + """ status: CategoryStatus statusNEQ: CategoryStatus statusIn: [CategoryStatus!] statusNotIn: [CategoryStatus!] - """config field predicates""" + """ + config field predicates + """ config: CategoryConfigInput configNEQ: CategoryConfigInput configIn: [CategoryConfigInput!] @@ -166,7 +224,9 @@ input CategoryWhereInput { configLTE: CategoryConfigInput configIsNil: Boolean configNotNil: Boolean - """duration field predicates""" + """ + duration field predicates + """ duration: Duration durationNEQ: Duration durationIn: [Duration!] @@ -177,7 +237,9 @@ input CategoryWhereInput { durationLTE: Duration durationIsNil: Boolean durationNotNil: Boolean - """count field predicates""" + """ + count field predicates + """ count: Uint64 countNEQ: Uint64 countIn: [Uint64!] @@ -188,25 +250,34 @@ input CategoryWhereInput { countLTE: Uint64 countIsNil: Boolean countNotNil: Boolean - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] - """sub_categories edge predicates""" + """ + sub_categories edge predicates + """ hasSubCategories: Boolean hasSubCategoriesWith: [CategoryWhereInput!] } -"""CreateCategoryInput is used for create Category object.""" +""" +CreateCategoryInput is used for create Category object. +""" input CreateCategoryInput { text: String! status: CategoryStatus! config: CategoryConfigInput + types: CategoryTypesInput duration: Duration count: Uint64 strings: [String!] todoIDs: [ID!] subCategoryIDs: [ID!] } -"""CreateTodoInput is used for create Todo object.""" +""" +CreateTodoInput is used for create Todo object. +""" input CreateTodoInput { status: TodoStatus! priority: Int @@ -217,11 +288,14 @@ input CreateTodoInput { categoryID: ID secretID: ID } -"""CreateUserInput is used for create User object.""" +""" +CreateUserInput is used for create User object. +""" input CreateUserInput { name: String username: UUID password: String + requiredMetadata: Map! metadata: Map groupIDs: [ID!] friendIDs: [ID!] @@ -239,19 +313,29 @@ type Friendship implements Node { user: User! friend: User! } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type FriendshipList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Friendship]! } -"""FriendshipWhereInput is used for filtering Friendship objects.""" +""" +FriendshipWhereInput is used for filtering Friendship objects. +""" input FriendshipWhereInput { not: FriendshipWhereInput and: [FriendshipWhereInput!] or: [FriendshipWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -260,7 +344,9 @@ input FriendshipWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -270,36 +356,54 @@ input FriendshipWhereInput { createdAtLT: Time createdAtLTE: Time } -type Group implements Node @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { +type Group implements Node & NamedNode @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { id: ID! name: String! users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type GroupList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Group]! } -"""GroupWhereInput is used for filtering Group objects.""" +""" +GroupWhereInput is used for filtering Group objects. +""" input GroupWhereInput { not: GroupWhereInput and: [GroupWhereInput!] or: [GroupWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -308,7 +412,9 @@ input GroupWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -322,18 +428,24 @@ input GroupWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """users edge predicates""" + """ + users edge predicates + """ hasUsers: Boolean hasUsersWith: [UserWhereInput!] } -"""The builtin Map type""" +""" +The builtin Map type +""" scalar Map """ An object with an ID. Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) """ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder") { - """The id of the object.""" + """ + The id of the object. + """ id: ID! } type OneToMany implements Node { @@ -343,30 +455,48 @@ type OneToMany implements Node { parent: OneToMany children: [OneToMany!] } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type OneToManyList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [OneToMany]! } -"""Ordering options for OneToMany connections""" +""" +Ordering options for OneToMany connections +""" input OneToManyOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" + """ + The field by which to order OneToManies. + """ field: OneToManyOrderField! } -"""Properties by which OneToMany connections can be ordered.""" +""" +Properties by which OneToMany connections can be ordered. +""" enum OneToManyOrderField { NAME } -"""OneToManyWhereInput is used for filtering OneToMany objects.""" +""" +OneToManyWhereInput is used for filtering OneToMany objects. +""" input OneToManyWhereInput { not: OneToManyWhereInput and: [OneToManyWhereInput!] or: [OneToManyWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -375,7 +505,9 @@ input OneToManyWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -389,7 +521,9 @@ input OneToManyWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """field2 field predicates""" + """ + field2 field predicates + """ field2: String field2NEQ: String field2In: [String!] @@ -405,56 +539,125 @@ input OneToManyWhereInput { field2NotNil: Boolean field2EqualFold: String field2ContainsFold: String - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [OneToManyWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [OneToManyWhereInput!] } -"""Possible directions in which to order a list of items when provided an `orderBy` argument.""" +""" +Possible directions in which to order a list of items when provided an `orderBy` argument. +""" enum OrderDirection { - """Specifies an ascending order for a given `orderBy` argument.""" + """ + Specifies an ascending order for a given `orderBy` argument. + """ ASC - """Specifies a descending order for a given `orderBy` argument.""" + """ + Specifies a descending order for a given `orderBy` argument. + """ DESC } +type Organization implements Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Workspace") { + id: ID! + name: String! +} +""" +OrganizationWhereInput is used for filtering Workspace objects. +""" +input OrganizationWhereInput { + not: OrganizationWhereInput + and: [OrganizationWhereInput!] + or: [OrganizationWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String +} """ Information about pagination in a connection. https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo """ type PageInfo { - """When paginating forwards, are there more items?""" + """ + When paginating forwards, are there more items? + """ hasNextPage: Boolean! - """When paginating backwards, are there more items?""" + """ + When paginating backwards, are there more items? + """ hasPreviousPage: Boolean! - """When paginating backwards, the cursor to continue.""" + """ + When paginating backwards, the cursor to continue. + """ startCursor: Cursor - """When paginating forwards, the cursor to continue.""" + """ + When paginating forwards, the cursor to continue. + """ endCursor: Cursor } type Project implements Node { id: ID! todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList } -"""ProjectWhereInput is used for filtering Project objects.""" +""" +ProjectWhereInput is used for filtering Project objects. +""" input ProjectWhereInput { not: ProjectWhereInput and: [ProjectWhereInput!] or: [ProjectWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -463,87 +666,139 @@ input ProjectWhereInput { idGTE: ID idLT: ID idLTE: ID - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] } type Query { - """Fetches an object given its ID.""" + """ + Fetches an object given its ID. + """ node( - """ID of the object.""" + """ + ID of the object. + """ id: ID! ): Node - """Lookup nodes by a list of IDs.""" + """ + Lookup nodes by a list of IDs. + """ nodes( - """The list of node IDs.""" + """ + The list of node IDs. + """ ids: [ID!]! ): [Node]! billProducts: [BillProduct!]! categories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList oneToMany( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for OneToManies returned from the connection.""" + """ + Ordering options for OneToManies returned from the connection. + """ orderBy: OneToManyOrder - """Filtering options for OneToManies returned from the connection.""" + """ + Filtering options for OneToManies returned from the connection. + """ where: OneToManyWhereInput ): OneToManyList - """This is the todo item""" + """ + This is the todo item + """ todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""The builtin Time type""" +""" +The builtin Time type +""" scalar Time type Todo implements Node { id: ID! @@ -557,39 +812,65 @@ type Todo implements Node { init: Map custom: [Custom!] customp: [Custom] - """Todo parent""" + """ + Todo parent + """ parent: Todo - """Todo children""" + """ + Todo children + """ children( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList category: Category } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type TodoList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Todo]! } -"""Ordering options for Todo connections""" +""" +Ordering options for Todo connections +""" input TodoOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Todos.""" + """ + The field by which to order Todos. + """ field: TodoOrderField! } -"""Properties by which Todo connections can be ordered.""" +""" +Properties by which Todo connections can be ordered. +""" enum TodoOrderField { CREATED_AT STATUS @@ -599,18 +880,24 @@ enum TodoOrderField { CHILDREN_COUNT CATEGORY_TEXT } -"""TodoStatus is enum for the field status""" +""" +TodoStatus is enum for the field status +""" enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { IN_PROGRESS COMPLETED PENDING } -"""TodoWhereInput is used for filtering Todo objects.""" +""" +TodoWhereInput is used for filtering Todo objects. +""" input TodoWhereInput { not: TodoWhereInput and: [TodoWhereInput!] or: [TodoWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -619,7 +906,9 @@ input TodoWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -628,12 +917,16 @@ input TodoWhereInput { createdAtGTE: Time createdAtLT: Time createdAtLTE: Time - """status field predicates""" + """ + status field predicates + """ status: TodoStatus statusNEQ: TodoStatus statusIn: [TodoStatus!] statusNotIn: [TodoStatus!] - """priority field predicates""" + """ + priority field predicates + """ priority: Int priorityNEQ: Int priorityIn: [Int!] @@ -642,7 +935,9 @@ input TodoWhereInput { priorityGTE: Int priorityLT: Int priorityLTE: Int - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -656,31 +951,45 @@ input TodoWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """category_id field predicates""" + """ + category_id field predicates + """ categoryID: ID categoryIDNEQ: ID categoryIDIn: [ID!] categoryIDNotIn: [ID!] categoryIDIsNil: Boolean categoryIDNotNil: Boolean - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [TodoWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [TodoWhereInput!] - """category edge predicates""" + """ + category edge predicates + """ hasCategory: Boolean hasCategoryWith: [CategoryWhereInput!] } -"""The builtin Uint64 type""" +""" +The builtin Uint64 type +""" scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" +""" +UpdateCategoryInput is used for update Category object. +""" input UpdateCategoryInput { text: String status: CategoryStatus config: CategoryConfigInput clearConfig: Boolean + types: CategoryTypesInput + clearTypes: Boolean duration: Duration clearDuration: Boolean count: Uint64 @@ -695,13 +1004,17 @@ input UpdateCategoryInput { removeSubCategoryIDs: [ID!] clearSubCategories: Boolean } -"""UpdateFriendshipInput is used for update Friendship object.""" +""" +UpdateFriendshipInput is used for update Friendship object. +""" input UpdateFriendshipInput { createdAt: Time userID: ID friendID: ID } -"""UpdateTodoInput is used for update Todo object.""" +""" +UpdateTodoInput is used for update Todo object. +""" input UpdateTodoInput { status: TodoStatus priority: Int @@ -716,12 +1029,15 @@ input UpdateTodoInput { secretID: ID clearSecret: Boolean } -"""UpdateUserInput is used for update User object.""" +""" +UpdateUserInput is used for update User object. +""" input UpdateUserInput { name: String username: UUID password: String clearPassword: Boolean + requiredMetadata: Map metadata: Map clearMetadata: Boolean addGroupIDs: [ID!] @@ -735,66 +1051,107 @@ type User implements Node { id: ID! name: String! username: UUID! + requiredMetadata: Map! metadata: Map - """The groups of the user""" + """ + The groups of the user + """ groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList friends( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList friendships( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Friendships returned from the connection.""" + """ + Filtering options for Friendships returned from the connection. + """ where: FriendshipWhereInput ): FriendshipList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type UserList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [User]! } -"""Ordering options for User connections""" +""" +Ordering options for User connections +""" input UserOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Users.""" + """ + The field by which to order Users. + """ field: UserOrderField! } -"""Properties by which User connections can be ordered.""" +""" +Properties by which User connections can be ordered. +""" enum UserOrderField { GROUPS_COUNT } -"""UserWhereInput is used for filtering User objects.""" +""" +UserWhereInput is used for filtering User objects. +""" input UserWhereInput { not: UserWhereInput and: [UserWhereInput!] or: [UserWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -803,7 +1160,9 @@ input UserWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -817,7 +1176,9 @@ input UserWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """username field predicates""" + """ + username field predicates + """ username: UUID usernameNEQ: UUID usernameIn: [UUID!] @@ -826,13 +1187,19 @@ input UserWhereInput { usernameGTE: UUID usernameLT: UUID usernameLTE: UUID - """groups edge predicates""" + """ + groups edge predicates + """ hasGroups: Boolean hasGroupsWith: [GroupWhereInput!] - """friends edge predicates""" + """ + friends edge predicates + """ hasFriends: Boolean hasFriendsWith: [UserWhereInput!] - """friendships edge predicates""" + """ + friendships edge predicates + """ hasFriendships: Boolean hasFriendshipsWith: [FriendshipWhereInput!] } diff --git a/entgql/internal/todo/ent.resolvers.go b/entgql/internal/todo/ent.resolvers.go index 4fec0d19e..67be4b377 100644 --- a/entgql/internal/todo/ent.resolvers.go +++ b/entgql/internal/todo/ent.resolvers.go @@ -16,6 +16,7 @@ package todo // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" @@ -23,18 +24,22 @@ import ( "entgo.io/contrib/entgql/internal/todo/ent" ) +// Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id int) (ent.Noder, error) { return r.client.Noder(ctx, id) } +// Nodes is the resolver for the nodes field. func (r *queryResolver) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) { return r.client.Noders(ctx, ids) } +// BillProducts is the resolver for the billProducts field. func (r *queryResolver) BillProducts(ctx context.Context) ([]*ent.BillProduct, error) { return r.client.BillProduct.Query().All(ctx) } +// Categories is the resolver for the categories field. func (r *queryResolver) Categories(ctx context.Context, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryList, error) { return r.client.Category.Query(). PaginateLimitOffset(ctx, limit, offset, @@ -43,6 +48,7 @@ func (r *queryResolver) Categories(ctx context.Context, limit *int, offset *int, ) } +// Groups is the resolver for the groups field. func (r *queryResolver) Groups(ctx context.Context, limit *int, offset *int, where *ent.GroupWhereInput) (*ent.GroupList, error) { return r.client.Group.Query(). PaginateLimitOffset(ctx, limit, offset, @@ -50,6 +56,7 @@ func (r *queryResolver) Groups(ctx context.Context, limit *int, offset *int, whe ) } +// OneToMany is the resolver for the oneToMany field. func (r *queryResolver) OneToMany(ctx context.Context, limit *int, offset *int, orderBy *ent.OneToManyOrder, where *ent.OneToManyWhereInput) (*ent.OneToManyList, error) { return r.client.OneToMany.Query(). PaginateLimitOffset(ctx, limit, offset, @@ -58,7 +65,8 @@ func (r *queryResolver) OneToMany(ctx context.Context, limit *int, offset *int, ) } -func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { +// Todos is the resolver for the todos field. +func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { return r.client.Todo.Query(). PaginateLimitOffset(ctx, limit, offset, ent.WithTodoOrder(orderBy), @@ -66,6 +74,7 @@ func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orde ) } +// Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) { return r.client.User.Query(). PaginateLimitOffset(ctx, limit, offset, diff --git a/entgql/internal/todo/ent/billproduct/where.go b/entgql/internal/todo/ent/billproduct/where.go index abe1aeb37..59a129e88 100644 --- a/entgql/internal/todo/ent/billproduct/where.go +++ b/entgql/internal/todo/ent/billproduct/where.go @@ -253,32 +253,15 @@ func QuantityLTE(v uint64) predicate.BillProduct { // And groups predicates with the AND operator between them. func And(predicates ...predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BillProduct(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BillProduct(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.BillProduct(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/billproduct_create.go b/entgql/internal/todo/ent/billproduct_create.go index 088ca3ca5..41a92756f 100644 --- a/entgql/internal/todo/ent/billproduct_create.go +++ b/entgql/internal/todo/ent/billproduct_create.go @@ -58,7 +58,7 @@ func (bpc *BillProductCreate) Mutation() *BillProductMutation { // Save creates the BillProduct in the database. func (bpc *BillProductCreate) Save(ctx context.Context) (*BillProduct, error) { - return withHooks[*BillProduct, BillProductMutation](ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) + return withHooks(ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -138,11 +138,15 @@ func (bpc *BillProductCreate) createSpec() (*BillProduct, *sqlgraph.CreateSpec) // BillProductCreateBulk is the builder for creating many BillProduct entities in bulk. type BillProductCreateBulk struct { config + err error builders []*BillProductCreate } // Save creates the BillProduct entities in the database. func (bpcb *BillProductCreateBulk) Save(ctx context.Context) ([]*BillProduct, error) { + if bpcb.err != nil { + return nil, bpcb.err + } specs := make([]*sqlgraph.CreateSpec, len(bpcb.builders)) nodes := make([]*BillProduct, len(bpcb.builders)) mutators := make([]Mutator, len(bpcb.builders)) diff --git a/entgql/internal/todo/ent/billproduct_delete.go b/entgql/internal/todo/ent/billproduct_delete.go index deac9d1d6..a68cffab7 100644 --- a/entgql/internal/todo/ent/billproduct_delete.go +++ b/entgql/internal/todo/ent/billproduct_delete.go @@ -41,7 +41,7 @@ func (bpd *BillProductDelete) Where(ps ...predicate.BillProduct) *BillProductDel // Exec executes the deletion query and returns how many vertices were deleted. func (bpd *BillProductDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, BillProductMutation](ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) + return withHooks(ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/billproduct_query.go b/entgql/internal/todo/ent/billproduct_query.go index 949cc5f7e..5fcb46a0e 100644 --- a/entgql/internal/todo/ent/billproduct_query.go +++ b/entgql/internal/todo/ent/billproduct_query.go @@ -35,8 +35,8 @@ type BillProductQuery struct { order []billproduct.OrderOption inters []Interceptor predicates []predicate.BillProduct - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*BillProduct) error + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -445,6 +445,9 @@ func (bpq *BillProductQuery) sqlQuery(ctx context.Context) *sql.Selector { if bpq.ctx.Unique != nil && *bpq.ctx.Unique { selector.Distinct() } + for _, m := range bpq.modifiers { + m(selector) + } for _, p := range bpq.predicates { p(selector) } @@ -462,6 +465,12 @@ func (bpq *BillProductQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (bpq *BillProductQuery) Modify(modifiers ...func(s *sql.Selector)) *BillProductSelect { + bpq.modifiers = append(bpq.modifiers, modifiers...) + return bpq.Select() +} + // BillProductGroupBy is the group-by builder for BillProduct entities. type BillProductGroupBy struct { selector @@ -551,3 +560,9 @@ func (bps *BillProductSelect) sqlScan(ctx context.Context, root *BillProductQuer defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (bps *BillProductSelect) Modify(modifiers ...func(s *sql.Selector)) *BillProductSelect { + bps.modifiers = append(bps.modifiers, modifiers...) + return bps +} diff --git a/entgql/internal/todo/ent/billproduct_update.go b/entgql/internal/todo/ent/billproduct_update.go index f07e4dbd6..09a50f97a 100644 --- a/entgql/internal/todo/ent/billproduct_update.go +++ b/entgql/internal/todo/ent/billproduct_update.go @@ -31,8 +31,9 @@ import ( // BillProductUpdate is the builder for updating BillProduct entities. type BillProductUpdate struct { config - hooks []Hook - mutation *BillProductMutation + hooks []Hook + mutation *BillProductMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the BillProductUpdate builder. @@ -47,12 +48,28 @@ func (bpu *BillProductUpdate) SetName(s string) *BillProductUpdate { return bpu } +// SetNillableName sets the "name" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableName(s *string) *BillProductUpdate { + if s != nil { + bpu.SetName(*s) + } + return bpu +} + // SetSku sets the "sku" field. func (bpu *BillProductUpdate) SetSku(s string) *BillProductUpdate { bpu.mutation.SetSku(s) return bpu } +// SetNillableSku sets the "sku" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableSku(s *string) *BillProductUpdate { + if s != nil { + bpu.SetSku(*s) + } + return bpu +} + // SetQuantity sets the "quantity" field. func (bpu *BillProductUpdate) SetQuantity(u uint64) *BillProductUpdate { bpu.mutation.ResetQuantity() @@ -60,6 +77,14 @@ func (bpu *BillProductUpdate) SetQuantity(u uint64) *BillProductUpdate { return bpu } +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableQuantity(u *uint64) *BillProductUpdate { + if u != nil { + bpu.SetQuantity(*u) + } + return bpu +} + // AddQuantity adds u to the "quantity" field. func (bpu *BillProductUpdate) AddQuantity(u int64) *BillProductUpdate { bpu.mutation.AddQuantity(u) @@ -73,7 +98,7 @@ func (bpu *BillProductUpdate) Mutation() *BillProductMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (bpu *BillProductUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, BillProductMutation](ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) + return withHooks(ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -98,6 +123,12 @@ func (bpu *BillProductUpdate) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (bpu *BillProductUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *BillProductUpdate { + bpu.modifiers = append(bpu.modifiers, modifiers...) + return bpu +} + func (bpu *BillProductUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec := sqlgraph.NewUpdateSpec(billproduct.Table, billproduct.Columns, sqlgraph.NewFieldSpec(billproduct.FieldID, field.TypeInt)) if ps := bpu.mutation.predicates; len(ps) > 0 { @@ -119,6 +150,7 @@ func (bpu *BillProductUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := bpu.mutation.AddedQuantity(); ok { _spec.AddField(billproduct.FieldQuantity, field.TypeUint64, value) } + _spec.AddModifiers(bpu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, bpu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{billproduct.Label} @@ -134,9 +166,10 @@ func (bpu *BillProductUpdate) sqlSave(ctx context.Context) (n int, err error) { // BillProductUpdateOne is the builder for updating a single BillProduct entity. type BillProductUpdateOne struct { config - fields []string - hooks []Hook - mutation *BillProductMutation + fields []string + hooks []Hook + mutation *BillProductMutation + modifiers []func(*sql.UpdateBuilder) } // SetName sets the "name" field. @@ -145,12 +178,28 @@ func (bpuo *BillProductUpdateOne) SetName(s string) *BillProductUpdateOne { return bpuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableName(s *string) *BillProductUpdateOne { + if s != nil { + bpuo.SetName(*s) + } + return bpuo +} + // SetSku sets the "sku" field. func (bpuo *BillProductUpdateOne) SetSku(s string) *BillProductUpdateOne { bpuo.mutation.SetSku(s) return bpuo } +// SetNillableSku sets the "sku" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableSku(s *string) *BillProductUpdateOne { + if s != nil { + bpuo.SetSku(*s) + } + return bpuo +} + // SetQuantity sets the "quantity" field. func (bpuo *BillProductUpdateOne) SetQuantity(u uint64) *BillProductUpdateOne { bpuo.mutation.ResetQuantity() @@ -158,6 +207,14 @@ func (bpuo *BillProductUpdateOne) SetQuantity(u uint64) *BillProductUpdateOne { return bpuo } +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableQuantity(u *uint64) *BillProductUpdateOne { + if u != nil { + bpuo.SetQuantity(*u) + } + return bpuo +} + // AddQuantity adds u to the "quantity" field. func (bpuo *BillProductUpdateOne) AddQuantity(u int64) *BillProductUpdateOne { bpuo.mutation.AddQuantity(u) @@ -184,7 +241,7 @@ func (bpuo *BillProductUpdateOne) Select(field string, fields ...string) *BillPr // Save executes the query and returns the updated BillProduct entity. func (bpuo *BillProductUpdateOne) Save(ctx context.Context) (*BillProduct, error) { - return withHooks[*BillProduct, BillProductMutation](ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) + return withHooks(ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -209,6 +266,12 @@ func (bpuo *BillProductUpdateOne) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (bpuo *BillProductUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *BillProductUpdateOne { + bpuo.modifiers = append(bpuo.modifiers, modifiers...) + return bpuo +} + func (bpuo *BillProductUpdateOne) sqlSave(ctx context.Context) (_node *BillProduct, err error) { _spec := sqlgraph.NewUpdateSpec(billproduct.Table, billproduct.Columns, sqlgraph.NewFieldSpec(billproduct.FieldID, field.TypeInt)) id, ok := bpuo.mutation.ID() @@ -247,6 +310,7 @@ func (bpuo *BillProductUpdateOne) sqlSave(ctx context.Context) (_node *BillProdu if value, ok := bpuo.mutation.AddedQuantity(); ok { _spec.AddField(billproduct.FieldQuantity, field.TypeUint64, value) } + _spec.AddModifiers(bpuo.modifiers...) _node = &BillProduct{config: bpuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/category.go b/entgql/internal/todo/ent/category.go index 5b7774fb8..29d15bf28 100644 --- a/entgql/internal/todo/ent/category.go +++ b/entgql/internal/todo/ent/category.go @@ -39,6 +39,8 @@ type Category struct { Status category.Status `json:"status,omitempty"` // Config holds the value of the "config" field. Config *schematype.CategoryConfig `json:"config,omitempty"` + // Types holds the value of the "types" field. + Types *schematype.CategoryTypes `json:"types,omitempty"` // Duration holds the value of the "duration" field. Duration time.Duration `json:"duration,omitempty"` // Count holds the value of the "count" field. @@ -90,7 +92,7 @@ func (*Category) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case category.FieldStrings: + case category.FieldTypes, category.FieldStrings: values[i] = new([]byte) case category.FieldConfig: values[i] = new(schematype.CategoryConfig) @@ -137,6 +139,14 @@ func (c *Category) assignValues(columns []string, values []any) error { } else if value != nil { c.Config = value } + case category.FieldTypes: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field types", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &c.Types); err != nil { + return fmt.Errorf("unmarshal field types: %w", err) + } + } case category.FieldDuration: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field duration", values[i]) @@ -212,6 +222,9 @@ func (c *Category) String() string { builder.WriteString("config=") builder.WriteString(fmt.Sprintf("%v", c.Config)) builder.WriteString(", ") + builder.WriteString("types=") + builder.WriteString(fmt.Sprintf("%v", c.Types)) + builder.WriteString(", ") builder.WriteString("duration=") builder.WriteString(fmt.Sprintf("%v", c.Duration)) builder.WriteString(", ") diff --git a/entgql/internal/todo/ent/category/category.go b/entgql/internal/todo/ent/category/category.go index 15b57055f..8033932d5 100644 --- a/entgql/internal/todo/ent/category/category.go +++ b/entgql/internal/todo/ent/category/category.go @@ -36,6 +36,8 @@ const ( FieldStatus = "status" // FieldConfig holds the string denoting the config field in the database. FieldConfig = "config" + // FieldTypes holds the string denoting the types field in the database. + FieldTypes = "types" // FieldDuration holds the string denoting the duration field in the database. FieldDuration = "duration" // FieldCount holds the string denoting the count field in the database. @@ -65,6 +67,7 @@ var Columns = []string{ FieldText, FieldStatus, FieldConfig, + FieldTypes, FieldDuration, FieldCount, FieldStrings, diff --git a/entgql/internal/todo/ent/category/where.go b/entgql/internal/todo/ent/category/where.go index 444583950..f885ac6a0 100644 --- a/entgql/internal/todo/ent/category/where.go +++ b/entgql/internal/todo/ent/category/where.go @@ -226,6 +226,16 @@ func ConfigNotNil() predicate.Category { return predicate.Category(sql.FieldNotNull(FieldConfig)) } +// TypesIsNil applies the IsNil predicate on the "types" field. +func TypesIsNil() predicate.Category { + return predicate.Category(sql.FieldIsNull(FieldTypes)) +} + +// TypesNotNil applies the NotNil predicate on the "types" field. +func TypesNotNil() predicate.Category { + return predicate.Category(sql.FieldNotNull(FieldTypes)) +} + // DurationEQ applies the EQ predicate on the "duration" field. func DurationEQ(v time.Duration) predicate.Category { vc := int64(v) @@ -398,32 +408,15 @@ func HasSubCategoriesWith(preds ...predicate.Category) predicate.Category { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Category(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/category_create.go b/entgql/internal/todo/ent/category_create.go index c368e289c..7944e8b7d 100644 --- a/entgql/internal/todo/ent/category_create.go +++ b/entgql/internal/todo/ent/category_create.go @@ -54,6 +54,12 @@ func (cc *CategoryCreate) SetConfig(sc *schematype.CategoryConfig) *CategoryCrea return cc } +// SetTypes sets the "types" field. +func (cc *CategoryCreate) SetTypes(st *schematype.CategoryTypes) *CategoryCreate { + cc.mutation.SetTypes(st) + return cc +} + // SetDuration sets the "duration" field. func (cc *CategoryCreate) SetDuration(t time.Duration) *CategoryCreate { cc.mutation.SetDuration(t) @@ -131,7 +137,7 @@ func (cc *CategoryCreate) Mutation() *CategoryMutation { // Save creates the Category in the database. func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) + return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -218,6 +224,10 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { _spec.SetField(category.FieldConfig, field.TypeOther, value) _node.Config = value } + if value, ok := cc.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + _node.Types = value + } if value, ok := cc.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) _node.Duration = value @@ -268,11 +278,15 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { // CategoryCreateBulk is the builder for creating many Category entities in bulk. type CategoryCreateBulk struct { config + err error builders []*CategoryCreate } // Save creates the Category entities in the database. func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error) { + if ccb.err != nil { + return nil, ccb.err + } specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) nodes := make([]*Category, len(ccb.builders)) mutators := make([]Mutator, len(ccb.builders)) diff --git a/entgql/internal/todo/ent/category_delete.go b/entgql/internal/todo/ent/category_delete.go index 79bb5fa56..f2419242d 100644 --- a/entgql/internal/todo/ent/category_delete.go +++ b/entgql/internal/todo/ent/category_delete.go @@ -41,7 +41,7 @@ func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (cd *CategoryDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) + return withHooks(ctx, cd.sqlExec, cd.mutation, cd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/category_query.go b/entgql/internal/todo/ent/category_query.go index 59105edf9..848b5e1b8 100644 --- a/entgql/internal/todo/ent/category_query.go +++ b/entgql/internal/todo/ent/category_query.go @@ -39,8 +39,8 @@ type CategoryQuery struct { predicates []predicate.Category withTodos *TodoQuery withSubCategories *CategoryQuery - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Category) error + modifiers []func(*sql.Selector) withNamedTodos map[string]*TodoQuery withNamedSubCategories map[string]*CategoryQuery // intermediate query (i.e. traversal path). @@ -645,6 +645,9 @@ func (cq *CategoryQuery) sqlQuery(ctx context.Context) *sql.Selector { if cq.ctx.Unique != nil && *cq.ctx.Unique { selector.Distinct() } + for _, m := range cq.modifiers { + m(selector) + } for _, p := range cq.predicates { p(selector) } @@ -662,6 +665,12 @@ func (cq *CategoryQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (cq *CategoryQuery) Modify(modifiers ...func(s *sql.Selector)) *CategorySelect { + cq.modifiers = append(cq.modifiers, modifiers...) + return cq.Select() +} + // WithNamedTodos tells the query-builder to eager-load the nodes that are connected to the "todos" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (cq *CategoryQuery) WithNamedTodos(name string, opts ...func(*TodoQuery)) *CategoryQuery { @@ -779,3 +788,9 @@ func (cs *CategorySelect) sqlScan(ctx context.Context, root *CategoryQuery, v an defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (cs *CategorySelect) Modify(modifiers ...func(s *sql.Selector)) *CategorySelect { + cs.modifiers = append(cs.modifiers, modifiers...) + return cs +} diff --git a/entgql/internal/todo/ent/category_update.go b/entgql/internal/todo/ent/category_update.go index b807ebfa7..f0bf2aa58 100644 --- a/entgql/internal/todo/ent/category_update.go +++ b/entgql/internal/todo/ent/category_update.go @@ -35,8 +35,9 @@ import ( // CategoryUpdate is the builder for updating Category entities. type CategoryUpdate struct { config - hooks []Hook - mutation *CategoryMutation + hooks []Hook + mutation *CategoryMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the CategoryUpdate builder. @@ -51,12 +52,28 @@ func (cu *CategoryUpdate) SetText(s string) *CategoryUpdate { return cu } +// SetNillableText sets the "text" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableText(s *string) *CategoryUpdate { + if s != nil { + cu.SetText(*s) + } + return cu +} + // SetStatus sets the "status" field. func (cu *CategoryUpdate) SetStatus(c category.Status) *CategoryUpdate { cu.mutation.SetStatus(c) return cu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableStatus(c *category.Status) *CategoryUpdate { + if c != nil { + cu.SetStatus(*c) + } + return cu +} + // SetConfig sets the "config" field. func (cu *CategoryUpdate) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdate { cu.mutation.SetConfig(sc) @@ -69,6 +86,18 @@ func (cu *CategoryUpdate) ClearConfig() *CategoryUpdate { return cu } +// SetTypes sets the "types" field. +func (cu *CategoryUpdate) SetTypes(st *schematype.CategoryTypes) *CategoryUpdate { + cu.mutation.SetTypes(st) + return cu +} + +// ClearTypes clears the value of the "types" field. +func (cu *CategoryUpdate) ClearTypes() *CategoryUpdate { + cu.mutation.ClearTypes() + return cu +} + // SetDuration sets the "duration" field. func (cu *CategoryUpdate) SetDuration(t time.Duration) *CategoryUpdate { cu.mutation.ResetDuration() @@ -220,7 +249,7 @@ func (cu *CategoryUpdate) RemoveSubCategories(c ...*Category) *CategoryUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) + return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -260,6 +289,12 @@ func (cu *CategoryUpdate) check() error { return nil } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (cu *CategoryUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CategoryUpdate { + cu.modifiers = append(cu.modifiers, modifiers...) + return cu +} + func (cu *CategoryUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := cu.check(); err != nil { return n, err @@ -284,6 +319,12 @@ func (cu *CategoryUpdate) sqlSave(ctx context.Context) (n int, err error) { if cu.mutation.ConfigCleared() { _spec.ClearField(category.FieldConfig, field.TypeOther) } + if value, ok := cu.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + } + if cu.mutation.TypesCleared() { + _spec.ClearField(category.FieldTypes, field.TypeJSON) + } if value, ok := cu.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) } @@ -403,6 +444,7 @@ func (cu *CategoryUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(cu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{category.Label} @@ -418,9 +460,10 @@ func (cu *CategoryUpdate) sqlSave(ctx context.Context) (n int, err error) { // CategoryUpdateOne is the builder for updating a single Category entity. type CategoryUpdateOne struct { config - fields []string - hooks []Hook - mutation *CategoryMutation + fields []string + hooks []Hook + mutation *CategoryMutation + modifiers []func(*sql.UpdateBuilder) } // SetText sets the "text" field. @@ -429,12 +472,28 @@ func (cuo *CategoryUpdateOne) SetText(s string) *CategoryUpdateOne { return cuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableText(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetText(*s) + } + return cuo +} + // SetStatus sets the "status" field. func (cuo *CategoryUpdateOne) SetStatus(c category.Status) *CategoryUpdateOne { cuo.mutation.SetStatus(c) return cuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableStatus(c *category.Status) *CategoryUpdateOne { + if c != nil { + cuo.SetStatus(*c) + } + return cuo +} + // SetConfig sets the "config" field. func (cuo *CategoryUpdateOne) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdateOne { cuo.mutation.SetConfig(sc) @@ -447,6 +506,18 @@ func (cuo *CategoryUpdateOne) ClearConfig() *CategoryUpdateOne { return cuo } +// SetTypes sets the "types" field. +func (cuo *CategoryUpdateOne) SetTypes(st *schematype.CategoryTypes) *CategoryUpdateOne { + cuo.mutation.SetTypes(st) + return cuo +} + +// ClearTypes clears the value of the "types" field. +func (cuo *CategoryUpdateOne) ClearTypes() *CategoryUpdateOne { + cuo.mutation.ClearTypes() + return cuo +} + // SetDuration sets the "duration" field. func (cuo *CategoryUpdateOne) SetDuration(t time.Duration) *CategoryUpdateOne { cuo.mutation.ResetDuration() @@ -611,7 +682,7 @@ func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUp // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) + return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -651,6 +722,12 @@ func (cuo *CategoryUpdateOne) check() error { return nil } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (cuo *CategoryUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CategoryUpdateOne { + cuo.modifiers = append(cuo.modifiers, modifiers...) + return cuo +} + func (cuo *CategoryUpdateOne) sqlSave(ctx context.Context) (_node *Category, err error) { if err := cuo.check(); err != nil { return _node, err @@ -692,6 +769,12 @@ func (cuo *CategoryUpdateOne) sqlSave(ctx context.Context) (_node *Category, err if cuo.mutation.ConfigCleared() { _spec.ClearField(category.FieldConfig, field.TypeOther) } + if value, ok := cuo.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + } + if cuo.mutation.TypesCleared() { + _spec.ClearField(category.FieldTypes, field.TypeJSON) + } if value, ok := cuo.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) } @@ -811,6 +894,7 @@ func (cuo *CategoryUpdateOne) sqlSave(ctx context.Context) (_node *Category, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(cuo.modifiers...) _node = &Category{config: cuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/client.go b/entgql/internal/todo/ent/client.go index 394b82b65..feaf9096c 100644 --- a/entgql/internal/todo/ent/client.go +++ b/entgql/internal/todo/ent/client.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entgql/internal/todo/ent/migrate" "entgo.io/ent" @@ -34,6 +35,7 @@ import ( "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todo/ent/user" "entgo.io/contrib/entgql/internal/todo/ent/verysecret" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -62,15 +64,15 @@ type Client struct { User *UserClient // VerySecret is the client for interacting with the VerySecret builders. VerySecret *VerySecretClient + // Workspace is the client for interacting with the Workspace builders. + Workspace *WorkspaceClient // additional fields for node api tables tables } // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -86,6 +88,7 @@ func (c *Client) init() { c.Todo = NewTodoClient(c.config) c.User = NewUserClient(c.config) c.VerySecret = NewVerySecretClient(c.config) + c.Workspace = NewWorkspaceClient(c.config) } type ( @@ -106,6 +109,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -153,11 +163,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -177,6 +190,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Todo: NewTodoClient(cfg), User: NewUserClient(cfg), VerySecret: NewVerySecretClient(cfg), + Workspace: NewWorkspaceClient(cfg), }, nil } @@ -205,6 +219,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Todo: NewTodoClient(cfg), User: NewUserClient(cfg), VerySecret: NewVerySecretClient(cfg), + Workspace: NewWorkspaceClient(cfg), }, nil } @@ -235,7 +250,7 @@ func (c *Client) Close() error { func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.BillProduct, c.Category, c.Friendship, c.Group, c.OneToMany, c.Project, - c.Todo, c.User, c.VerySecret, + c.Todo, c.User, c.VerySecret, c.Workspace, } { n.Use(hooks...) } @@ -246,7 +261,7 @@ func (c *Client) Use(hooks ...Hook) { func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.BillProduct, c.Category, c.Friendship, c.Group, c.OneToMany, c.Project, - c.Todo, c.User, c.VerySecret, + c.Todo, c.User, c.VerySecret, c.Workspace, } { n.Intercept(interceptors...) } @@ -273,6 +288,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.User.mutate(ctx, m) case *VerySecretMutation: return c.VerySecret.mutate(ctx, m) + case *WorkspaceMutation: + return c.Workspace.mutate(ctx, m) default: return nil, fmt.Errorf("ent: unknown mutation type %T", m) } @@ -311,6 +328,21 @@ func (c *BillProductClient) CreateBulk(builders ...*BillProductCreate) *BillProd return &BillProductCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BillProductClient) MapCreateBulk(slice any, setFunc func(*BillProductCreate, int)) *BillProductCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BillProductCreateBulk{err: fmt.Errorf("calling to BillProductClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BillProductCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BillProductCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for BillProduct. func (c *BillProductClient) Update() *BillProductUpdate { mutation := newBillProductMutation(c.config, OpUpdate) @@ -429,6 +461,21 @@ func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreate return &CategoryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CategoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CategoryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Category. func (c *CategoryClient) Update() *CategoryUpdate { mutation := newCategoryMutation(c.config, OpUpdate) @@ -579,6 +626,21 @@ func (c *FriendshipClient) CreateBulk(builders ...*FriendshipCreate) *Friendship return &FriendshipCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *FriendshipClient) MapCreateBulk(slice any, setFunc func(*FriendshipCreate, int)) *FriendshipCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &FriendshipCreateBulk{err: fmt.Errorf("calling to FriendshipClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*FriendshipCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &FriendshipCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Friendship. func (c *FriendshipClient) Update() *FriendshipUpdate { mutation := newFriendshipMutation(c.config, OpUpdate) @@ -729,6 +791,21 @@ func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk { return &GroupCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GroupCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GroupCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Group. func (c *GroupClient) Update() *GroupUpdate { mutation := newGroupMutation(c.config, OpUpdate) @@ -863,6 +940,21 @@ func (c *OneToManyClient) CreateBulk(builders ...*OneToManyCreate) *OneToManyCre return &OneToManyCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *OneToManyClient) MapCreateBulk(slice any, setFunc func(*OneToManyCreate, int)) *OneToManyCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &OneToManyCreateBulk{err: fmt.Errorf("calling to OneToManyClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*OneToManyCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &OneToManyCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for OneToMany. func (c *OneToManyClient) Update() *OneToManyUpdate { mutation := newOneToManyMutation(c.config, OpUpdate) @@ -1013,6 +1105,21 @@ func (c *ProjectClient) CreateBulk(builders ...*ProjectCreate) *ProjectCreateBul return &ProjectCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ProjectClient) MapCreateBulk(slice any, setFunc func(*ProjectCreate, int)) *ProjectCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ProjectCreateBulk{err: fmt.Errorf("calling to ProjectClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ProjectCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ProjectCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Project. func (c *ProjectClient) Update() *ProjectUpdate { mutation := newProjectMutation(c.config, OpUpdate) @@ -1147,6 +1254,21 @@ func (c *TodoClient) CreateBulk(builders ...*TodoCreate) *TodoCreateBulk { return &TodoCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TodoClient) MapCreateBulk(slice any, setFunc func(*TodoCreate, int)) *TodoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TodoCreateBulk{err: fmt.Errorf("calling to TodoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TodoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TodoCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Todo. func (c *TodoClient) Update() *TodoUpdate { mutation := newTodoMutation(c.config, OpUpdate) @@ -1329,6 +1451,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) @@ -1495,6 +1632,21 @@ func (c *VerySecretClient) CreateBulk(builders ...*VerySecretCreate) *VerySecret return &VerySecretCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *VerySecretClient) MapCreateBulk(slice any, setFunc func(*VerySecretCreate, int)) *VerySecretCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VerySecretCreateBulk{err: fmt.Errorf("calling to VerySecretClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VerySecretCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VerySecretCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for VerySecret. func (c *VerySecretClient) Update() *VerySecretUpdate { mutation := newVerySecretMutation(c.config, OpUpdate) @@ -1580,14 +1732,147 @@ func (c *VerySecretClient) mutate(ctx context.Context, m *VerySecretMutation) (V } } +// WorkspaceClient is a client for the Workspace schema. +type WorkspaceClient struct { + config +} + +// NewWorkspaceClient returns a client for the Workspace from the given config. +func NewWorkspaceClient(c config) *WorkspaceClient { + return &WorkspaceClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `workspace.Hooks(f(g(h())))`. +func (c *WorkspaceClient) Use(hooks ...Hook) { + c.hooks.Workspace = append(c.hooks.Workspace, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `workspace.Intercept(f(g(h())))`. +func (c *WorkspaceClient) Intercept(interceptors ...Interceptor) { + c.inters.Workspace = append(c.inters.Workspace, interceptors...) +} + +// Create returns a builder for creating a Workspace entity. +func (c *WorkspaceClient) Create() *WorkspaceCreate { + mutation := newWorkspaceMutation(c.config, OpCreate) + return &WorkspaceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Workspace entities. +func (c *WorkspaceClient) CreateBulk(builders ...*WorkspaceCreate) *WorkspaceCreateBulk { + return &WorkspaceCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *WorkspaceClient) MapCreateBulk(slice any, setFunc func(*WorkspaceCreate, int)) *WorkspaceCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &WorkspaceCreateBulk{err: fmt.Errorf("calling to WorkspaceClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*WorkspaceCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &WorkspaceCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Workspace. +func (c *WorkspaceClient) Update() *WorkspaceUpdate { + mutation := newWorkspaceMutation(c.config, OpUpdate) + return &WorkspaceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *WorkspaceClient) UpdateOne(w *Workspace) *WorkspaceUpdateOne { + mutation := newWorkspaceMutation(c.config, OpUpdateOne, withWorkspace(w)) + return &WorkspaceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *WorkspaceClient) UpdateOneID(id int) *WorkspaceUpdateOne { + mutation := newWorkspaceMutation(c.config, OpUpdateOne, withWorkspaceID(id)) + return &WorkspaceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Workspace. +func (c *WorkspaceClient) Delete() *WorkspaceDelete { + mutation := newWorkspaceMutation(c.config, OpDelete) + return &WorkspaceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *WorkspaceClient) DeleteOne(w *Workspace) *WorkspaceDeleteOne { + return c.DeleteOneID(w.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *WorkspaceClient) DeleteOneID(id int) *WorkspaceDeleteOne { + builder := c.Delete().Where(workspace.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &WorkspaceDeleteOne{builder} +} + +// Query returns a query builder for Workspace. +func (c *WorkspaceClient) Query() *WorkspaceQuery { + return &WorkspaceQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeWorkspace}, + inters: c.Interceptors(), + } +} + +// Get returns a Workspace entity by its id. +func (c *WorkspaceClient) Get(ctx context.Context, id int) (*Workspace, error) { + return c.Query().Where(workspace.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *WorkspaceClient) GetX(ctx context.Context, id int) *Workspace { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *WorkspaceClient) Hooks() []Hook { + return c.hooks.Workspace +} + +// Interceptors returns the client interceptors. +func (c *WorkspaceClient) Interceptors() []Interceptor { + return c.inters.Workspace +} + +func (c *WorkspaceClient) mutate(ctx context.Context, m *WorkspaceMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&WorkspaceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&WorkspaceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&WorkspaceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&WorkspaceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Workspace mutation op: %q", m.Op()) + } +} + // hooks and interceptors per client, for fast access. type ( hooks struct { BillProduct, Category, Friendship, Group, OneToMany, Project, Todo, User, - VerySecret []ent.Hook + VerySecret, Workspace []ent.Hook } inters struct { BillProduct, Category, Friendship, Group, OneToMany, Project, Todo, User, - VerySecret []ent.Interceptor + VerySecret, Workspace []ent.Interceptor } ) diff --git a/entgql/internal/todo/ent/ent.go b/entgql/internal/todo/ent/ent.go index 16a8a69ab..82cdcdbdd 100644 --- a/entgql/internal/todo/ent/ent.go +++ b/entgql/internal/todo/ent/ent.go @@ -32,6 +32,7 @@ import ( "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todo/ent/user" "entgo.io/contrib/entgql/internal/todo/ent/verysecret" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -104,6 +105,7 @@ func checkColumn(table, column string) error { todo.Table: todo.ValidColumn, user.Table: user.ValidColumn, verysecret.Table: verysecret.ValidColumn, + workspace.Table: workspace.ValidColumn, }) }) return columnCheck(table, column) diff --git a/entgql/internal/todo/ent/entc.go b/entgql/internal/todo/ent/entc.go index 468963b77..7bd0e6c02 100644 --- a/entgql/internal/todo/ent/entc.go +++ b/entgql/internal/todo/ent/entc.go @@ -47,6 +47,9 @@ func main() { // // Code generated by entc, DO NOT EDIT. `, + Features: []gen.Feature{ + gen.FeatureModifier, + }, }, entc.Extensions(ex)) if err != nil { log.Fatalf("running ent codegen: %v", err) diff --git a/entgql/internal/todo/ent/friendship/where.go b/entgql/internal/todo/ent/friendship/where.go index 03fb00251..01bfa9881 100644 --- a/entgql/internal/todo/ent/friendship/where.go +++ b/entgql/internal/todo/ent/friendship/where.go @@ -212,32 +212,15 @@ func HasFriendWith(preds ...predicate.User) predicate.Friendship { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Friendship(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Friendship(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Friendship(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/friendship_create.go b/entgql/internal/todo/ent/friendship_create.go index 1c5daaf1c..75e280efe 100644 --- a/entgql/internal/todo/ent/friendship_create.go +++ b/entgql/internal/todo/ent/friendship_create.go @@ -79,7 +79,7 @@ func (fc *FriendshipCreate) Mutation() *FriendshipMutation { // Save creates the Friendship in the database. func (fc *FriendshipCreate) Save(ctx context.Context) (*Friendship, error) { fc.defaults() - return withHooks[*Friendship, FriendshipMutation](ctx, fc.sqlSave, fc.mutation, fc.hooks) + return withHooks(ctx, fc.sqlSave, fc.mutation, fc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -199,11 +199,15 @@ func (fc *FriendshipCreate) createSpec() (*Friendship, *sqlgraph.CreateSpec) { // FriendshipCreateBulk is the builder for creating many Friendship entities in bulk. type FriendshipCreateBulk struct { config + err error builders []*FriendshipCreate } // Save creates the Friendship entities in the database. func (fcb *FriendshipCreateBulk) Save(ctx context.Context) ([]*Friendship, error) { + if fcb.err != nil { + return nil, fcb.err + } specs := make([]*sqlgraph.CreateSpec, len(fcb.builders)) nodes := make([]*Friendship, len(fcb.builders)) mutators := make([]Mutator, len(fcb.builders)) diff --git a/entgql/internal/todo/ent/friendship_delete.go b/entgql/internal/todo/ent/friendship_delete.go index 603750fb2..198391f4d 100644 --- a/entgql/internal/todo/ent/friendship_delete.go +++ b/entgql/internal/todo/ent/friendship_delete.go @@ -41,7 +41,7 @@ func (fd *FriendshipDelete) Where(ps ...predicate.Friendship) *FriendshipDelete // Exec executes the deletion query and returns how many vertices were deleted. func (fd *FriendshipDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, FriendshipMutation](ctx, fd.sqlExec, fd.mutation, fd.hooks) + return withHooks(ctx, fd.sqlExec, fd.mutation, fd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/friendship_query.go b/entgql/internal/todo/ent/friendship_query.go index f3f0ba293..3558f1879 100644 --- a/entgql/internal/todo/ent/friendship_query.go +++ b/entgql/internal/todo/ent/friendship_query.go @@ -38,8 +38,8 @@ type FriendshipQuery struct { predicates []predicate.Friendship withUser *UserQuery withFriend *UserQuery - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Friendship) error + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -598,6 +598,9 @@ func (fq *FriendshipQuery) sqlQuery(ctx context.Context) *sql.Selector { if fq.ctx.Unique != nil && *fq.ctx.Unique { selector.Distinct() } + for _, m := range fq.modifiers { + m(selector) + } for _, p := range fq.predicates { p(selector) } @@ -615,6 +618,12 @@ func (fq *FriendshipQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (fq *FriendshipQuery) Modify(modifiers ...func(s *sql.Selector)) *FriendshipSelect { + fq.modifiers = append(fq.modifiers, modifiers...) + return fq.Select() +} + // FriendshipGroupBy is the group-by builder for Friendship entities. type FriendshipGroupBy struct { selector @@ -704,3 +713,9 @@ func (fs *FriendshipSelect) sqlScan(ctx context.Context, root *FriendshipQuery, defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (fs *FriendshipSelect) Modify(modifiers ...func(s *sql.Selector)) *FriendshipSelect { + fs.modifiers = append(fs.modifiers, modifiers...) + return fs +} diff --git a/entgql/internal/todo/ent/friendship_update.go b/entgql/internal/todo/ent/friendship_update.go index 6db6cc9d2..4ddcb5853 100644 --- a/entgql/internal/todo/ent/friendship_update.go +++ b/entgql/internal/todo/ent/friendship_update.go @@ -33,8 +33,9 @@ import ( // FriendshipUpdate is the builder for updating Friendship entities. type FriendshipUpdate struct { config - hooks []Hook - mutation *FriendshipMutation + hooks []Hook + mutation *FriendshipMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the FriendshipUpdate builder. @@ -63,12 +64,28 @@ func (fu *FriendshipUpdate) SetUserID(i int) *FriendshipUpdate { return fu } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (fu *FriendshipUpdate) SetNillableUserID(i *int) *FriendshipUpdate { + if i != nil { + fu.SetUserID(*i) + } + return fu +} + // SetFriendID sets the "friend_id" field. func (fu *FriendshipUpdate) SetFriendID(i int) *FriendshipUpdate { fu.mutation.SetFriendID(i) return fu } +// SetNillableFriendID sets the "friend_id" field if the given value is not nil. +func (fu *FriendshipUpdate) SetNillableFriendID(i *int) *FriendshipUpdate { + if i != nil { + fu.SetFriendID(*i) + } + return fu +} + // SetUser sets the "user" edge to the User entity. func (fu *FriendshipUpdate) SetUser(u *User) *FriendshipUpdate { return fu.SetUserID(u.ID) @@ -98,7 +115,7 @@ func (fu *FriendshipUpdate) ClearFriend() *FriendshipUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (fu *FriendshipUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, FriendshipMutation](ctx, fu.sqlSave, fu.mutation, fu.hooks) + return withHooks(ctx, fu.sqlSave, fu.mutation, fu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -134,6 +151,12 @@ func (fu *FriendshipUpdate) check() error { return nil } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (fu *FriendshipUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FriendshipUpdate { + fu.modifiers = append(fu.modifiers, modifiers...) + return fu +} + func (fu *FriendshipUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := fu.check(); err != nil { return n, err @@ -207,6 +230,7 @@ func (fu *FriendshipUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(fu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, fu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{friendship.Label} @@ -222,9 +246,10 @@ func (fu *FriendshipUpdate) sqlSave(ctx context.Context) (n int, err error) { // FriendshipUpdateOne is the builder for updating a single Friendship entity. type FriendshipUpdateOne struct { config - fields []string - hooks []Hook - mutation *FriendshipMutation + fields []string + hooks []Hook + mutation *FriendshipMutation + modifiers []func(*sql.UpdateBuilder) } // SetCreatedAt sets the "created_at" field. @@ -247,12 +272,28 @@ func (fuo *FriendshipUpdateOne) SetUserID(i int) *FriendshipUpdateOne { return fuo } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (fuo *FriendshipUpdateOne) SetNillableUserID(i *int) *FriendshipUpdateOne { + if i != nil { + fuo.SetUserID(*i) + } + return fuo +} + // SetFriendID sets the "friend_id" field. func (fuo *FriendshipUpdateOne) SetFriendID(i int) *FriendshipUpdateOne { fuo.mutation.SetFriendID(i) return fuo } +// SetNillableFriendID sets the "friend_id" field if the given value is not nil. +func (fuo *FriendshipUpdateOne) SetNillableFriendID(i *int) *FriendshipUpdateOne { + if i != nil { + fuo.SetFriendID(*i) + } + return fuo +} + // SetUser sets the "user" edge to the User entity. func (fuo *FriendshipUpdateOne) SetUser(u *User) *FriendshipUpdateOne { return fuo.SetUserID(u.ID) @@ -295,7 +336,7 @@ func (fuo *FriendshipUpdateOne) Select(field string, fields ...string) *Friendsh // Save executes the query and returns the updated Friendship entity. func (fuo *FriendshipUpdateOne) Save(ctx context.Context) (*Friendship, error) { - return withHooks[*Friendship, FriendshipMutation](ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) + return withHooks(ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -331,6 +372,12 @@ func (fuo *FriendshipUpdateOne) check() error { return nil } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (fuo *FriendshipUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FriendshipUpdateOne { + fuo.modifiers = append(fuo.modifiers, modifiers...) + return fuo +} + func (fuo *FriendshipUpdateOne) sqlSave(ctx context.Context) (_node *Friendship, err error) { if err := fuo.check(); err != nil { return _node, err @@ -421,6 +468,7 @@ func (fuo *FriendshipUpdateOne) sqlSave(ctx context.Context) (_node *Friendship, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(fuo.modifiers...) _node = &Friendship{config: fuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/gql_collection.go b/entgql/internal/todo/ent/gql_collection.go index 058ddf82a..c39c9c496 100644 --- a/entgql/internal/todo/ent/gql_collection.go +++ b/entgql/internal/todo/ent/gql_collection.go @@ -30,6 +30,7 @@ import ( "entgo.io/contrib/entgql/internal/todo/ent/project" "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todo/ent/user" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" ) @@ -40,13 +41,13 @@ func (bp *BillProductQuery) CollectFields(ctx context.Context, satisfies ...stri if fc == nil { return bp, nil } - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := bp.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return bp, nil } -func (bp *BillProductQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (bp *BillProductQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -87,7 +88,7 @@ type billproductPaginateArgs struct { opts []BillProductPaginateOption } -func newBillProductPaginateArgs(rv map[string]interface{}) *billproductPaginateArgs { +func newBillProductPaginateArgs(rv map[string]any) *billproductPaginateArgs { args := &billproductPaginateArgs{} if rv == nil { return args @@ -110,13 +111,13 @@ func (c *CategoryQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return c, nil } - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := c.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return c, nil } -func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (c *CategoryQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -125,6 +126,7 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "todos": var ( alias = field.Alias @@ -193,25 +195,30 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(category.TodosColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(category.TodosColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } c.WithNamedTodos(alias, func(wq *TodoQuery) { *wq = *query }) + case "subCategories": var ( alias = field.Alias @@ -284,19 +291,23 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Category")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Category"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Category")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Category"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(category.SubCategoriesPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(category.SubCategoriesPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -318,6 +329,11 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati selectedFields = append(selectedFields, category.FieldConfig) fieldSeen[category.FieldConfig] = struct{}{} } + case "types": + if _, ok := fieldSeen[category.FieldTypes]; !ok { + selectedFields = append(selectedFields, category.FieldTypes) + fieldSeen[category.FieldTypes] = struct{}{} + } case "duration": if _, ok := fieldSeen[category.FieldDuration]; !ok { selectedFields = append(selectedFields, category.FieldDuration) @@ -350,7 +366,7 @@ type categoryPaginateArgs struct { opts []CategoryPaginateOption } -func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { +func newCategoryPaginateArgs(rv map[string]any) *categoryPaginateArgs { args := &categoryPaginateArgs{} if rv == nil { return args @@ -365,10 +381,10 @@ func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { switch v := v.(type) { case []*CategoryOrder: args.opts = append(args.opts, WithCategoryOrder(v)) - case []interface{}: + case []any: var orders []*CategoryOrder for i := range v { - mv, ok := v[i].(map[string]interface{}) + mv, ok := v[i].(map[string]any) if !ok { continue } @@ -401,13 +417,13 @@ func (f *FriendshipQuery) CollectFields(ctx context.Context, satisfies ...string if fc == nil { return f, nil } - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := f.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return f, nil } -func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (f *FriendshipQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -416,13 +432,14 @@ func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "user": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: f.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } f.withUser = query @@ -430,13 +447,14 @@ func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, friendship.FieldUserID) fieldSeen[friendship.FieldUserID] = struct{}{} } + case "friend": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: f.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } f.withFriend = query @@ -476,7 +494,7 @@ type friendshipPaginateArgs struct { opts []FriendshipPaginateOption } -func newFriendshipPaginateArgs(rv map[string]interface{}) *friendshipPaginateArgs { +func newFriendshipPaginateArgs(rv map[string]any) *friendshipPaginateArgs { args := &friendshipPaginateArgs{} if rv == nil { return args @@ -499,13 +517,13 @@ func (gr *GroupQuery) CollectFields(ctx context.Context, satisfies ...string) (* if fc == nil { return gr, nil } - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := gr.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return gr, nil } -func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (gr *GroupQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -514,6 +532,7 @@ func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.Operation ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "users": var ( alias = field.Alias @@ -586,19 +605,23 @@ func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.Operation } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(group.UsersPrimaryKey[1], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(group.UsersPrimaryKey[1], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -627,7 +650,7 @@ type groupPaginateArgs struct { opts []GroupPaginateOption } -func newGroupPaginateArgs(rv map[string]interface{}) *groupPaginateArgs { +func newGroupPaginateArgs(rv map[string]any) *groupPaginateArgs { args := &groupPaginateArgs{} if rv == nil { return args @@ -650,13 +673,13 @@ func (otm *OneToManyQuery) CollectFields(ctx context.Context, satisfies ...strin if fc == nil { return otm, nil } - if err := otm.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := otm.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return otm, nil } -func (otm *OneToManyQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (otm *OneToManyQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -665,13 +688,14 @@ func (otm *OneToManyQuery) collectField(ctx context.Context, opCtx *graphql.Oper ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "parent": var ( alias = field.Alias path = append(path, alias) query = (&OneToManyClient{config: otm.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, onetomanyImplementors)...); err != nil { return err } otm.withParent = query @@ -679,13 +703,14 @@ func (otm *OneToManyQuery) collectField(ctx context.Context, opCtx *graphql.Oper selectedFields = append(selectedFields, onetomany.FieldParentID) fieldSeen[onetomany.FieldParentID] = struct{}{} } + case "children": var ( alias = field.Alias path = append(path, alias) query = (&OneToManyClient{config: otm.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, onetomanyImplementors)...); err != nil { return err } otm.WithNamedChildren(alias, func(wq *OneToManyQuery) { @@ -718,7 +743,7 @@ type onetomanyPaginateArgs struct { opts []OneToManyPaginateOption } -func newOneToManyPaginateArgs(rv map[string]interface{}) *onetomanyPaginateArgs { +func newOneToManyPaginateArgs(rv map[string]any) *onetomanyPaginateArgs { args := &onetomanyPaginateArgs{} if rv == nil { return args @@ -731,7 +756,7 @@ func newOneToManyPaginateArgs(rv map[string]interface{}) *onetomanyPaginateArgs } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: + case map[string]any: var ( err1, err2 error order = &OneToManyOrder{Field: &OneToManyOrderField{}, Direction: entgql.OrderDirectionAsc} @@ -763,16 +788,17 @@ func (pr *ProjectQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return pr, nil } - if err := pr.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := pr.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return pr, nil } -func (pr *ProjectQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (pr *ProjectQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "todos": var ( alias = field.Alias @@ -841,19 +867,23 @@ func (pr *ProjectQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(project.TodosColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(project.TodosColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -870,7 +900,7 @@ type projectPaginateArgs struct { opts []ProjectPaginateOption } -func newProjectPaginateArgs(rv map[string]interface{}) *projectPaginateArgs { +func newProjectPaginateArgs(rv map[string]any) *projectPaginateArgs { args := &projectPaginateArgs{} if rv == nil { return args @@ -893,13 +923,13 @@ func (t *TodoQuery) CollectFields(ctx context.Context, satisfies ...string) (*To if fc == nil { return t, nil } - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := t.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return t, nil } -func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (t *TodoQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -908,16 +938,18 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "parent": var ( alias = field.Alias path = append(path, alias) query = (&TodoClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, todoImplementors)...); err != nil { return err } t.withParent = query + case "children": var ( alias = field.Alias @@ -986,32 +1018,37 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(todo.ChildrenColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(todo.ChildrenColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } t.WithNamedChildren(alias, func(wq *TodoQuery) { *wq = *query }) + case "category": var ( alias = field.Alias path = append(path, alias) query = (&CategoryClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, categoryImplementors)...); err != nil { return err } t.withCategory = query @@ -1076,7 +1113,7 @@ type todoPaginateArgs struct { opts []TodoPaginateOption } -func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { +func newTodoPaginateArgs(rv map[string]any) *todoPaginateArgs { args := &todoPaginateArgs{} if rv == nil { return args @@ -1089,24 +1126,30 @@ func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: - var ( - err1, err2 error - order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithTodoOrder(order)) - } - case *TodoOrder: - if v != nil { - args.opts = append(args.opts, WithTodoOrder(v)) + case []*TodoOrder: + args.opts = append(args.opts, WithTodoOrder(v)) + case []any: + var orders []*TodoOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} + ) + if d, ok := mv[directionField]; ok { + err1 = order.Direction.UnmarshalGQL(d) + } + if f, ok := mv[fieldField]; ok { + err2 = order.Field.UnmarshalGQL(f) + } + if err1 == nil && err2 == nil { + orders = append(orders, order) + } } + args.opts = append(args.opts, WithTodoOrder(orders)) } } if v, ok := rv[whereField].(*TodoWhereInput); ok { @@ -1121,13 +1164,13 @@ func (u *UserQuery) CollectFields(ctx context.Context, satisfies ...string) (*Us if fc == nil { return u, nil } - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := u.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return u, nil } -func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (u *UserQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -1136,6 +1179,7 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "groups": var ( alias = field.Alias @@ -1208,25 +1252,30 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Group")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Group"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Group")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Group"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(user.GroupsPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(user.GroupsPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } u.WithNamedGroups(alias, func(wq *GroupQuery) { *wq = *query }) + case "friends": var ( alias = field.Alias @@ -1299,25 +1348,30 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(user.FriendsPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(user.FriendsPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } u.WithNamedFriends(alias, func(wq *UserQuery) { *wq = *query }) + case "friendships": var ( alias = field.Alias @@ -1386,19 +1440,23 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Friendship")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Friendship"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Friendship")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Friendship"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(user.FriendshipsColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(user.FriendshipsColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -1415,6 +1473,11 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo selectedFields = append(selectedFields, user.FieldUsername) fieldSeen[user.FieldUsername] = struct{}{} } + case "requiredMetadata": + if _, ok := fieldSeen[user.FieldRequiredMetadata]; !ok { + selectedFields = append(selectedFields, user.FieldRequiredMetadata) + fieldSeen[user.FieldRequiredMetadata] = struct{}{} + } case "metadata": if _, ok := fieldSeen[user.FieldMetadata]; !ok { selectedFields = append(selectedFields, user.FieldMetadata) @@ -1437,7 +1500,7 @@ type userPaginateArgs struct { opts []UserPaginateOption } -func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { +func newUserPaginateArgs(rv map[string]any) *userPaginateArgs { args := &userPaginateArgs{} if rv == nil { return args @@ -1450,7 +1513,7 @@ func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: + case map[string]any: var ( err1, err2 error order = &UserOrder{Field: &UserOrderField{}, Direction: entgql.OrderDirectionAsc} @@ -1476,6 +1539,66 @@ func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (w *WorkspaceQuery) CollectFields(ctx context.Context, satisfies ...string) (*WorkspaceQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return w, nil + } + if err := w.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return w, nil +} + +func (w *WorkspaceQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + var ( + unknownSeen bool + fieldSeen = make(map[string]struct{}, len(workspace.Columns)) + selectedFields = []string{workspace.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + case "name": + if _, ok := fieldSeen[workspace.FieldName]; !ok { + selectedFields = append(selectedFields, workspace.FieldName) + fieldSeen[workspace.FieldName] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + w.Select(selectedFields...) + } + return nil +} + +type organizationPaginateArgs struct { + limit, offset *int + opts []OrganizationPaginateOption +} + +func newOrganizationPaginateArgs(rv map[string]any) *organizationPaginateArgs { + args := &organizationPaginateArgs{} + if rv == nil { + return args + } + if v := rv[limitField]; v != nil { + args.limit = v.(*int) + } + if v := rv[offsetField]; v != nil { + args.offset = v.(*int) + } + if v, ok := rv[whereField].(*OrganizationWhereInput); ok { + args.opts = append(args.opts, WithOrganizationFilter(v.Filter)) + } + return args +} + const ( limitField = "limit" offsetField = "offset" @@ -1485,35 +1608,18 @@ const ( whereField = "where" ) -func fieldArgs(ctx context.Context, whereInput interface{}, path ...string) map[string]interface{} { - fc := graphql.GetFieldContext(ctx) - if fc == nil { +func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { + field := collectedField(ctx, path...) + if field == nil || field.Arguments == nil { return nil } oc := graphql.GetOperationContext(ctx) - for _, name := range path { - var field *graphql.CollectedField - for _, f := range graphql.CollectFields(oc, fc.Field.Selections, nil) { - if f.Alias == name { - field = &f - break - } - } - if field == nil { - return nil - } - cf, err := fc.Child(ctx, *field) - if err != nil { - args := field.ArgumentMap(oc.Variables) - return unmarshalArgs(ctx, whereInput, args) - } - fc = cf - } - return fc.Args + args := field.ArgumentMap(oc.Variables) + return unmarshalArgs(ctx, whereInput, args) } // unmarshalArgs allows extracting the field arguments from their raw representation. -func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string]interface{}) map[string]interface{} { +func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{limitField, offsetField} { v, ok := args[k] if !ok { @@ -1533,39 +1639,17 @@ func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string] return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } diff --git a/entgql/internal/todo/ent/gql_edge.go b/entgql/internal/todo/ent/gql_edge.go index 904fce3d8..2c4b49406 100644 --- a/entgql/internal/todo/ent/gql_edge.go +++ b/entgql/internal/todo/ent/gql_edge.go @@ -23,7 +23,7 @@ import ( ) func (c *Category) Todos( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), @@ -122,7 +122,7 @@ func (otm *OneToMany) Children(ctx context.Context) (result []*OneToMany, err er } func (pr *Project) Todos( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), @@ -151,7 +151,7 @@ func (t *Todo) Parent(ctx context.Context) (*Todo, error) { } func (t *Todo) Children( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), diff --git a/entgql/internal/todo/ent/gql_mutation_input.go b/entgql/internal/todo/ent/gql_mutation_input.go index aea95fa1f..730c07fff 100644 --- a/entgql/internal/todo/ent/gql_mutation_input.go +++ b/entgql/internal/todo/ent/gql_mutation_input.go @@ -30,6 +30,7 @@ type CreateCategoryInput struct { Text string Status category.Status Config *schematype.CategoryConfig + Types *schematype.CategoryTypes Duration *time.Duration Count *uint64 Strings []string @@ -44,6 +45,9 @@ func (i *CreateCategoryInput) Mutate(m *CategoryMutation) { if v := i.Config; v != nil { m.SetConfig(v) } + if v := i.Types; v != nil { + m.SetTypes(v) + } if v := i.Duration; v != nil { m.SetDuration(*v) } @@ -73,6 +77,8 @@ type UpdateCategoryInput struct { Status *category.Status ClearConfig bool Config *schematype.CategoryConfig + ClearTypes bool + Types *schematype.CategoryTypes ClearDuration bool Duration *time.Duration ClearCount bool @@ -102,6 +108,12 @@ func (i *UpdateCategoryInput) Mutate(m *CategoryMutation) { if v := i.Config; v != nil { m.SetConfig(v) } + if i.ClearTypes { + m.ClearTypes() + } + if v := i.Types; v != nil { + m.SetTypes(v) + } if i.ClearDuration { m.ClearDuration() } @@ -299,12 +311,13 @@ func (c *TodoUpdateOne) SetInput(i UpdateTodoInput) *TodoUpdateOne { // CreateUserInput represents a mutation input for creating users. type CreateUserInput struct { - Name *string - Username *uuid.UUID - Password *string - Metadata map[string]interface{} - GroupIDs []int - FriendIDs []int + Name *string + Username *uuid.UUID + Password *string + RequiredMetadata map[string]interface{} + Metadata map[string]interface{} + GroupIDs []int + FriendIDs []int } // Mutate applies the CreateUserInput on the UserMutation builder. @@ -318,6 +331,9 @@ func (i *CreateUserInput) Mutate(m *UserMutation) { if v := i.Password; v != nil { m.SetPassword(*v) } + if v := i.RequiredMetadata; v != nil { + m.SetRequiredMetadata(v) + } if v := i.Metadata; v != nil { m.SetMetadata(v) } @@ -337,18 +353,19 @@ func (c *UserCreate) SetInput(i CreateUserInput) *UserCreate { // UpdateUserInput represents a mutation input for updating users. type UpdateUserInput struct { - Name *string - Username *uuid.UUID - ClearPassword bool - Password *string - ClearMetadata bool - Metadata map[string]interface{} - ClearGroups bool - AddGroupIDs []int - RemoveGroupIDs []int - ClearFriends bool - AddFriendIDs []int - RemoveFriendIDs []int + Name *string + Username *uuid.UUID + ClearPassword bool + Password *string + RequiredMetadata map[string]interface{} + ClearMetadata bool + Metadata map[string]interface{} + ClearGroups bool + AddGroupIDs []int + RemoveGroupIDs []int + ClearFriends bool + AddFriendIDs []int + RemoveFriendIDs []int } // Mutate applies the UpdateUserInput on the UserMutation builder. @@ -365,6 +382,9 @@ func (i *UpdateUserInput) Mutate(m *UserMutation) { if v := i.Password; v != nil { m.SetPassword(*v) } + if v := i.RequiredMetadata; v != nil { + m.SetRequiredMetadata(v) + } if i.ClearMetadata { m.ClearMetadata() } diff --git a/entgql/internal/todo/ent/gql_node.go b/entgql/internal/todo/ent/gql_node.go index de25d2eda..6af6bc93e 100644 --- a/entgql/internal/todo/ent/gql_node.go +++ b/entgql/internal/todo/ent/gql_node.go @@ -31,6 +31,7 @@ import ( "entgo.io/contrib/entgql/internal/todo/ent/project" "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todo/ent/user" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" @@ -45,29 +46,53 @@ type Noder interface { IsNode() } +var billproductImplementors = []string{"BillProduct", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *BillProduct) IsNode() {} +func (*BillProduct) IsNode() {} + +var categoryImplementors = []string{"Category", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Category) IsNode() {} +func (*Category) IsNode() {} + +var friendshipImplementors = []string{"Friendship", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Friendship) IsNode() {} +func (*Friendship) IsNode() {} + +var groupImplementors = []string{"Group", "Node", "NamedNode"} // IsNode implements the Node interface check for GQLGen. -func (n *Group) IsNode() {} +func (*Group) IsNode() {} + +// IsNamedNode implements the NamedNode interface check for GQLGen. +func (*Group) IsNamedNode() {} + +var onetomanyImplementors = []string{"OneToMany", "Node"} + +// IsNode implements the Node interface check for GQLGen. +func (*OneToMany) IsNode() {} + +var projectImplementors = []string{"Project", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *OneToMany) IsNode() {} +func (*Project) IsNode() {} + +var todoImplementors = []string{"Todo", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Project) IsNode() {} +func (*Todo) IsNode() {} + +var userImplementors = []string{"User", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Todo) IsNode() {} +func (*User) IsNode() {} + +var workspaceImplementors = []string{"Organization", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *User) IsNode() {} +func (*Workspace) IsNode() {} var errNodeInvalidID = &NotFoundError{"node"} @@ -130,99 +155,84 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) case billproduct.Table: query := c.BillProduct.Query(). Where(billproduct.ID(id)) - query, err := query.CollectFields(ctx, "BillProduct") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, billproductImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case category.Table: query := c.Category.Query(). Where(category.ID(id)) - query, err := query.CollectFields(ctx, "Category") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, categoryImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case friendship.Table: query := c.Friendship.Query(). Where(friendship.ID(id)) - query, err := query.CollectFields(ctx, "Friendship") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, friendshipImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case group.Table: query := c.Group.Query(). Where(group.ID(id)) - query, err := query.CollectFields(ctx, "Group") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, groupImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case onetomany.Table: query := c.OneToMany.Query(). Where(onetomany.ID(id)) - query, err := query.CollectFields(ctx, "OneToMany") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, onetomanyImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case project.Table: query := c.Project.Query(). Where(project.ID(id)) - query, err := query.CollectFields(ctx, "Project") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, projectImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case todo.Table: query := c.Todo.Query(). Where(todo.ID(id)) - query, err := query.CollectFields(ctx, "Todo") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, todoImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case user.Table: query := c.User.Query(). Where(user.ID(id)) - query, err := query.CollectFields(ctx, "User") - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, userImplementors...); err != nil { + return nil, err + } } - n, err := query.Only(ctx) - if err != nil { - return nil, err + return query.Only(ctx) + case workspace.Table: + query := c.Workspace.Query(). + Where(workspace.ID(id)) + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, workspaceImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) } @@ -299,7 +309,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case billproduct.Table: query := c.BillProduct.Query(). Where(billproduct.IDIn(ids...)) - query, err := query.CollectFields(ctx, "BillProduct") + query, err := query.CollectFields(ctx, billproductImplementors...) if err != nil { return nil, err } @@ -315,7 +325,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case category.Table: query := c.Category.Query(). Where(category.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Category") + query, err := query.CollectFields(ctx, categoryImplementors...) if err != nil { return nil, err } @@ -331,7 +341,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case friendship.Table: query := c.Friendship.Query(). Where(friendship.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Friendship") + query, err := query.CollectFields(ctx, friendshipImplementors...) if err != nil { return nil, err } @@ -347,7 +357,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case group.Table: query := c.Group.Query(). Where(group.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Group") + query, err := query.CollectFields(ctx, groupImplementors...) if err != nil { return nil, err } @@ -363,7 +373,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case onetomany.Table: query := c.OneToMany.Query(). Where(onetomany.IDIn(ids...)) - query, err := query.CollectFields(ctx, "OneToMany") + query, err := query.CollectFields(ctx, onetomanyImplementors...) if err != nil { return nil, err } @@ -379,7 +389,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case project.Table: query := c.Project.Query(). Where(project.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Project") + query, err := query.CollectFields(ctx, projectImplementors...) if err != nil { return nil, err } @@ -395,7 +405,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case todo.Table: query := c.Todo.Query(). Where(todo.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Todo") + query, err := query.CollectFields(ctx, todoImplementors...) if err != nil { return nil, err } @@ -411,7 +421,23 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case user.Table: query := c.User.Query(). Where(user.IDIn(ids...)) - query, err := query.CollectFields(ctx, "User") + query, err := query.CollectFields(ctx, userImplementors...) + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } + case workspace.Table: + query := c.Workspace.Query(). + Where(workspace.IDIn(ids...)) + query, err := query.CollectFields(ctx, workspaceImplementors...) if err != nil { return nil, err } diff --git a/entgql/internal/todo/ent/gql_node_descriptor.go b/entgql/internal/todo/ent/gql_node_descriptor.go index c0bc67f94..d2c36b293 100644 --- a/entgql/internal/todo/ent/gql_node_descriptor.go +++ b/entgql/internal/todo/ent/gql_node_descriptor.go @@ -91,7 +91,7 @@ func (c *Category) Node(ctx context.Context) (node *Node, err error) { node = &Node{ ID: c.ID, Type: "Category", - Fields: make([]*Field, 6), + Fields: make([]*Field, 7), Edges: make([]*Edge, 2), } var buf []byte @@ -119,10 +119,18 @@ func (c *Category) Node(ctx context.Context) (node *Node, err error) { Name: "config", Value: string(buf), } - if buf, err = json.Marshal(c.Duration); err != nil { + if buf, err = json.Marshal(c.Types); err != nil { return nil, err } node.Fields[3] = &Field{ + Type: "*schematype.CategoryTypes", + Name: "types", + Value: string(buf), + } + if buf, err = json.Marshal(c.Duration); err != nil { + return nil, err + } + node.Fields[4] = &Field{ Type: "time.Duration", Name: "duration", Value: string(buf), @@ -130,7 +138,7 @@ func (c *Category) Node(ctx context.Context) (node *Node, err error) { if buf, err = json.Marshal(c.Count); err != nil { return nil, err } - node.Fields[4] = &Field{ + node.Fields[5] = &Field{ Type: "uint64", Name: "count", Value: string(buf), @@ -138,7 +146,7 @@ func (c *Category) Node(ctx context.Context) (node *Node, err error) { if buf, err = json.Marshal(c.Strings); err != nil { return nil, err } - node.Fields[5] = &Field{ + node.Fields[6] = &Field{ Type: "[]string", Name: "strings", Value: string(buf), @@ -432,7 +440,7 @@ func (u *User) Node(ctx context.Context) (node *Node, err error) { node = &Node{ ID: u.ID, Type: "User", - Fields: make([]*Field, 4), + Fields: make([]*Field, 5), Edges: make([]*Edge, 3), } var buf []byte @@ -460,10 +468,18 @@ func (u *User) Node(ctx context.Context) (node *Node, err error) { Name: "password", Value: string(buf), } - if buf, err = json.Marshal(u.Metadata); err != nil { + if buf, err = json.Marshal(u.RequiredMetadata); err != nil { return nil, err } node.Fields[3] = &Field{ + Type: "map[string]interface {}", + Name: "required_metadata", + Value: string(buf), + } + if buf, err = json.Marshal(u.Metadata); err != nil { + return nil, err + } + node.Fields[4] = &Field{ Type: "map[string]interface {}", Name: "metadata", Value: string(buf), @@ -501,6 +517,26 @@ func (u *User) Node(ctx context.Context) (node *Node, err error) { return node, nil } +// Node implements Noder interface +func (w *Workspace) Node(ctx context.Context) (node *Node, err error) { + node = &Node{ + ID: w.ID, + Type: "Workspace", + Fields: make([]*Field, 1), + Edges: make([]*Edge, 0), + } + var buf []byte + if buf, err = json.Marshal(w.Name); err != nil { + return nil, err + } + node.Fields[0] = &Field{ + Type: "string", + Name: "name", + Value: string(buf), + } + return node, nil +} + // Node returns the node with given global ID. // // This API helpful in case you want to build diff --git a/entgql/internal/todo/ent/gql_pagination.go b/entgql/internal/todo/ent/gql_pagination.go index 3258d0289..c55ed0bf3 100644 --- a/entgql/internal/todo/ent/gql_pagination.go +++ b/entgql/internal/todo/ent/gql_pagination.go @@ -32,6 +32,7 @@ import ( "entgo.io/contrib/entgql/internal/todo/ent/project" "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todo/ent/user" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" @@ -338,12 +339,12 @@ func (bp *BillProductQuery) PaginateLimitOffset( bp.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bp.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := bp.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -376,7 +377,9 @@ func (bp *BillProductQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = bp.Clone().Count(ctx); err != nil { + c := bp.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -389,16 +392,17 @@ func (bp *BillProductQuery) Paginate( if bp, err = pager.applyCursors(bp, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { bp.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -572,11 +576,11 @@ func (p *categoryPager) applyFilter(query *CategoryQuery) (*CategoryQuery, error } func (p *categoryPager) toCursor(c *Category) Cursor { - cs := make([]any, 0, len(p.order)) - for _, o := range p.order { - cs = append(cs, o.Field.toCursor(c).Value) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(c).Value) } - return Cursor{ID: c.ID, Value: cs} + return Cursor{ID: c.ID, Value: cs_} } func (p *categoryPager) applyCursors(query *CategoryQuery, after, before *Cursor) (*CategoryQuery, error) { @@ -703,12 +707,12 @@ func (c *CategoryQuery) PaginateLimitOffset( c.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -741,7 +745,9 @@ func (c *CategoryQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = c.Clone().Count(ctx); err != nil { + c := c.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -754,16 +760,17 @@ func (c *CategoryQuery) Paginate( if c, err = pager.applyCursors(c, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { c.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -805,6 +812,20 @@ var ( } }, } + // CategoryOrderFieldStatus orders Category by status. + CategoryOrderFieldStatus = &CategoryOrderField{ + Value: func(c *Category) (ent.Value, error) { + return c.Status, nil + }, + column: category.FieldStatus, + toTerm: category.ByStatus, + toCursor: func(c *Category) Cursor { + return Cursor{ + ID: c.ID, + Value: c.Status, + } + }, + } // CategoryOrderFieldDuration orders Category by duration. CategoryOrderFieldDuration = &CategoryOrderField{ Value: func(c *Category) (ent.Value, error) { @@ -862,6 +883,8 @@ func (f CategoryOrderField) String() string { str = "ID" case CategoryOrderFieldText.column: str = "TEXT" + case CategoryOrderFieldStatus.column: + str = "STATUS" case CategoryOrderFieldDuration.column: str = "DURATION" case CategoryOrderFieldCount.column: @@ -888,6 +911,8 @@ func (f *CategoryOrderField) UnmarshalGQL(v interface{}) error { *f = *CategoryOrderFieldID case "TEXT": *f = *CategoryOrderFieldText + case "STATUS": + *f = *CategoryOrderFieldStatus case "DURATION": *f = *CategoryOrderFieldDuration case "COUNT": @@ -1143,12 +1168,12 @@ func (f *FriendshipQuery) PaginateLimitOffset( f.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := f.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1181,7 +1206,9 @@ func (f *FriendshipQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = f.Clone().Count(ctx); err != nil { + c := f.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1194,16 +1221,17 @@ func (f *FriendshipQuery) Paginate( if f, err = pager.applyCursors(f, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { f.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1377,11 +1405,11 @@ func (p *groupPager) applyFilter(query *GroupQuery) (*GroupQuery, error) { } func (p *groupPager) toCursor(gr *Group) Cursor { - cs := make([]any, 0, len(p.order)) - for _, o := range p.order { - cs = append(cs, o.Field.toCursor(gr).Value) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(gr).Value) } - return Cursor{ID: gr.ID, Value: cs} + return Cursor{ID: gr.ID, Value: cs_} } func (p *groupPager) applyCursors(query *GroupQuery, after, before *Cursor) (*GroupQuery, error) { @@ -1495,12 +1523,12 @@ func (gr *GroupQuery) PaginateLimitOffset( gr.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := gr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := gr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1533,7 +1561,9 @@ func (gr *GroupQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = gr.Clone().Count(ctx); err != nil { + c := gr.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1546,16 +1576,17 @@ func (gr *GroupQuery) Paginate( if gr, err = pager.applyCursors(gr, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { gr.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1811,12 +1842,12 @@ func (otm *OneToManyQuery) PaginateLimitOffset( otm.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := otm.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := otm.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := otm.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := otm.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1849,7 +1880,9 @@ func (otm *OneToManyQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = otm.Clone().Count(ctx); err != nil { + c := otm.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1862,16 +1895,17 @@ func (otm *OneToManyQuery) Paginate( if otm, err = pager.applyCursors(otm, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { otm.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := otm.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := otm.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := otm.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := otm.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2174,12 +2208,12 @@ func (pr *ProjectQuery) PaginateLimitOffset( pr.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := pr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := pr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2212,7 +2246,9 @@ func (pr *ProjectQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = pr.Clone().Count(ctx); err != nil { + c := pr.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2225,16 +2261,17 @@ func (pr *ProjectQuery) Paginate( if pr, err = pager.applyCursors(pr, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { pr.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := pr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := pr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2356,19 +2393,14 @@ func (c *TodoList) build(nodes []*Todo, pager *todoPager, after *Cursor, first * type TodoPaginateOption func(*todoPager) error // WithTodoOrder configures pagination ordering. -func WithTodoOrder(order *TodoOrder) TodoPaginateOption { - if order == nil { - order = DefaultTodoOrder - } - o := *order +func WithTodoOrder(order []*TodoOrder) TodoPaginateOption { return func(pager *todoPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultTodoOrder.Field + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } } - pager.order = &o + pager.order = append(pager.order, order...) return nil } } @@ -2386,7 +2418,7 @@ func WithTodoFilter(filter func(*TodoQuery) (*TodoQuery, error)) TodoPaginateOpt type todoPager struct { reverse bool - order *TodoOrder + order []*TodoOrder filter func(*TodoQuery) (*TodoQuery, error) } @@ -2397,8 +2429,10 @@ func newTodoPager(opts []TodoPaginateOption, reverse bool) (*todoPager, error) { return nil, err } } - if pager.order == nil { - pager.order = DefaultTodoOrder + for i, o := range pager.order { + if i > 0 && o.Field == pager.order[i-1].Field { + return nil, fmt.Errorf("duplicate order direction %q", o.Direction) + } } return pager, nil } @@ -2411,57 +2445,100 @@ func (p *todoPager) applyFilter(query *TodoQuery) (*TodoQuery, error) { } func (p *todoPager) toCursor(t *Todo) Cursor { - return p.order.Field.toCursor(t) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(t).Value) + } + return Cursor{ID: t.ID, Value: cs_} } func (p *todoPager) applyCursors(query *TodoQuery, after, before *Cursor) (*TodoQuery, error) { - direction := p.order.Direction + idDirection := entgql.OrderDirectionAsc if p.reverse { - direction = direction.Reverse() + idDirection = entgql.OrderDirectionDesc + } + fields, directions := make([]string, 0, len(p.order)), make([]OrderDirection, 0, len(p.order)) + for _, o := range p.order { + fields = append(fields, o.Field.column) + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + directions = append(directions, direction) + } + predicates, err := entgql.MultiCursorsPredicate(after, before, &entgql.MultiCursorsOptions{ + FieldID: DefaultTodoOrder.Field.column, + DirectionID: idDirection, + Fields: fields, + Directions: directions, + }) + if err != nil { + return nil, err } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultTodoOrder.Field.column, p.order.Field.column, direction) { + for _, predicate := range predicates { query = query.Where(predicate) } return query, nil } func (p *todoPager) applyOrder(query *TodoQuery) *TodoQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultTodoOrder.Field { - query = query.Order(DefaultTodoOrder.Field.toTerm(direction.OrderTermOption())) + var defaultOrdered bool + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + if o.Field.column == DefaultTodoOrder.Field.column { + defaultOrdered = true + } + switch o.Field.column { + case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, TodoOrderFieldCategoryText.column: + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } + } } - switch p.order.Field.column { - case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, CategoryOrderFieldCategoryText.column: - default: - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) + if !defaultOrdered { + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() } + query = query.Order(DefaultTodoOrder.Field.toTerm(direction.OrderTermOption())) } return query } func (p *todoPager) orderExpr(query *TodoQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - switch p.order.Field.column { - case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, CategoryOrderFieldCategoryText.column: - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - default: - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) + for _, o := range p.order { + switch o.Field.column { + case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, TodoOrderFieldCategoryText.column: + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } } } return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultTodoOrder.Field { - b.Comma().Ident(DefaultTodoOrder.Field.column).Pad().WriteString(string(direction)) + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + b.Ident(o.Field.column).Pad().WriteString(string(direction)) + b.Comma() } + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + b.Ident(DefaultTodoOrder.Field.column).Pad().WriteString(string(direction)) }) } @@ -2499,12 +2576,12 @@ func (t *TodoQuery) PaginateLimitOffset( t.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2537,7 +2614,9 @@ func (t *TodoQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = t.Clone().Count(ctx); err != nil { + c := t.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2550,16 +2629,17 @@ func (t *TodoQuery) Paginate( if t, err = pager.applyCursors(t, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { t.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2668,8 +2748,8 @@ var ( } }, } - // CategoryOrderFieldCategoryText orders by CATEGORY_TEXT. - CategoryOrderFieldCategoryText = &TodoOrderField{ + // TodoOrderFieldCategoryText orders by CATEGORY_TEXT. + TodoOrderFieldCategoryText = &TodoOrderField{ Value: func(t *Todo) (ent.Value, error) { return t.Value("category_text") }, @@ -2706,7 +2786,7 @@ func (f TodoOrderField) String() string { str = "PARENT_STATUS" case TodoOrderFieldChildrenCount.column: str = "CHILDREN_COUNT" - case CategoryOrderFieldCategoryText.column: + case TodoOrderFieldCategoryText.column: str = "CATEGORY_TEXT" } return str @@ -2737,7 +2817,7 @@ func (f *TodoOrderField) UnmarshalGQL(v interface{}) error { case "CHILDREN_COUNT": *f = *TodoOrderFieldChildrenCount case "CATEGORY_TEXT": - *f = *CategoryOrderFieldCategoryText + *f = *TodoOrderFieldCategoryText default: return fmt.Errorf("%s is not a valid TodoOrderField", str) } @@ -2996,12 +3076,12 @@ func (u *UserQuery) PaginateLimitOffset( u.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := u.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := u.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -3034,7 +3114,9 @@ func (u *UserQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = u.Clone().Count(ctx); err != nil { + c := u.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -3047,16 +3129,17 @@ func (u *UserQuery) Paginate( if u, err = pager.applyCursors(u, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { u.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -3161,3 +3244,325 @@ func (u *User) ToEdge(order *UserOrder) *UserEdge { Cursor: order.Field.toCursor(u), } } + +// Organization is the type alias for Workspace. +type Organization = Workspace + +// OrganizationEdge is the edge representation of Organization. +type OrganizationEdge struct { + Node *Organization `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// OrganizationList is the connection containing edges to Organization. +type OrganizationList struct { + Edges []*OrganizationEdge `json:"edges"` + Items []*Organization `json:"items"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *OrganizationList) build(nodes []*Organization, pager *organizationPager, after *Cursor, first *int, before *Cursor, last *int, withPageInfo bool) { + c.Items = nodes + c.Edges = make([]*OrganizationEdge, len(nodes)) + if withPageInfo { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *Organization + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *Organization { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *Organization { + return nodes[i] + } + } + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &OrganizationEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + } else { + for i := range nodes { + node := nodes[i] + c.Edges[i] = &OrganizationEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + } + + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// OrganizationPaginateOption enables pagination customization. +type OrganizationPaginateOption func(*organizationPager) error + +// WithOrganizationOrder configures pagination ordering. +func WithOrganizationOrder(order *OrganizationOrder) OrganizationPaginateOption { + if order == nil { + order = DefaultOrganizationOrder + } + o := *order + return func(pager *organizationPager) error { + if err := o.Direction.Validate(); err != nil { + return err + } + if o.Field == nil { + o.Field = DefaultOrganizationOrder.Field + } + pager.order = &o + return nil + } +} + +// WithOrganizationFilter configures pagination filter. +func WithOrganizationFilter(filter func(*WorkspaceQuery) (*WorkspaceQuery, error)) OrganizationPaginateOption { + return func(pager *organizationPager) error { + if filter == nil { + return errors.New("WorkspaceQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type organizationPager struct { + reverse bool + order *OrganizationOrder + filter func(*WorkspaceQuery) (*WorkspaceQuery, error) +} + +func newOrganizationPager(opts []OrganizationPaginateOption, reverse bool) (*organizationPager, error) { + pager := &organizationPager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + if pager.order == nil { + pager.order = DefaultOrganizationOrder + } + return pager, nil +} + +func (p *organizationPager) applyFilter(query *WorkspaceQuery) (*WorkspaceQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *organizationPager) toCursor(w *Organization) Cursor { + return p.order.Field.toCursor(w) +} + +func (p *organizationPager) applyCursors(query *WorkspaceQuery, after, before *Cursor) (*WorkspaceQuery, error) { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + for _, predicate := range entgql.CursorsPredicate(after, before, DefaultOrganizationOrder.Field.column, p.order.Field.column, direction) { + query = query.Where(predicate) + } + return query, nil +} + +func (p *organizationPager) applyOrder(query *WorkspaceQuery) *WorkspaceQuery { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) + if p.order.Field != DefaultOrganizationOrder.Field { + query = query.Order(DefaultOrganizationOrder.Field.toTerm(direction.OrderTermOption())) + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return query +} + +func (p *organizationPager) orderExpr(query *WorkspaceQuery) sql.Querier { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return sql.ExprFunc(func(b *sql.Builder) { + b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) + if p.order.Field != DefaultOrganizationOrder.Field { + b.Comma().Ident(DefaultOrganizationOrder.Field.column).Pad().WriteString(string(direction)) + } + }) +} + +// Paginate executes the query and returns a limit/offset paginated connection to Organization. +func (w *WorkspaceQuery) PaginateLimitOffset( + ctx context.Context, limit *int, offset *int, opts ...OrganizationPaginateOption, +) (*OrganizationList, error) { + if err := validateLimitOffset(limit, offset); err != nil { + return nil, err + } + pager, err := newOrganizationPager(opts, false) + if err != nil { + return nil, err + } + if w, err = pager.applyFilter(w); err != nil { + return nil, err + } + conn := &OrganizationList{Edges: []*OrganizationEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, itemsField) + if hasCollectedField(ctx, totalCountField) { + hasPagination := limit != nil || offset != nil + if hasPagination || ignoredEdges { + if conn.TotalCount, err = w.Clone().Count(ctx); err != nil { + return nil, err + } + } + } + if ignoredEdges || (limit != nil && *limit == 0) { + return conn, nil + } + if limit != nil { + w.Limit(*limit) + } + if offset != nil { + w.Offset(*offset) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := w.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + if field := collectedField(ctx, itemsField); field != nil { + if err := w.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + return nil, err + } + } + w = pager.applyOrder(w) + nodes, err := w.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, nil, nil, nil, nil, false) + return conn, nil +} + +// Paginate executes the query and returns a relay based cursor connection to Organization. +func (w *WorkspaceQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...OrganizationPaginateOption, +) (*OrganizationList, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newOrganizationPager(opts, last != nil) + if err != nil { + return nil, err + } + if w, err = pager.applyFilter(w); err != nil { + return nil, err + } + conn := &OrganizationList{Edges: []*OrganizationEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + c := w.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if w, err = pager.applyCursors(w, after, before); err != nil { + return nil, err + } + limit := paginateLimit(first, last) + if limit != 0 { + w.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := w.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + if field := collectedField(ctx, itemsField); field != nil { + if err := w.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + return nil, err + } + } + w = pager.applyOrder(w) + nodes, err := w.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last, true) + return conn, nil +} + +// OrganizationOrderField defines the ordering field of Workspace. +type OrganizationOrderField struct { + // Value extracts the ordering value from the given Workspace. + Value func(*Organization) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) workspace.OrderOption + toCursor func(*Organization) Cursor +} + +// OrganizationOrder defines the ordering of Workspace. +type OrganizationOrder struct { + Direction OrderDirection `json:"direction"` + Field *OrganizationOrderField `json:"field"` +} + +// DefaultOrganizationOrder is the default ordering of Workspace. +var DefaultOrganizationOrder = &OrganizationOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &OrganizationOrderField{ + Value: func(w *Organization) (ent.Value, error) { + return w.ID, nil + }, + column: workspace.FieldID, + toTerm: workspace.ByID, + toCursor: func(w *Organization) Cursor { + return Cursor{ID: w.ID} + }, + }, +} + +// ToEdge converts Organization into OrganizationEdge. +func (w *Organization) ToEdge(order *OrganizationOrder) *OrganizationEdge { + if order == nil { + order = DefaultOrganizationOrder + } + return &OrganizationEdge{ + Node: w, + Cursor: order.Field.toCursor(w), + } +} diff --git a/entgql/internal/todo/ent/gql_where_input.go b/entgql/internal/todo/ent/gql_where_input.go index b9398dd1c..e1f3560da 100644 --- a/entgql/internal/todo/ent/gql_where_input.go +++ b/entgql/internal/todo/ent/gql_where_input.go @@ -31,6 +31,7 @@ import ( "entgo.io/contrib/entgql/internal/todo/ent/schema/schematype" "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todo/ent/user" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" "github.com/google/uuid" ) @@ -2229,3 +2230,181 @@ func (i *UserWhereInput) P() (predicate.User, error) { return user.And(predicates...), nil } } + +// OrganizationWhereInput represents a where input for filtering Workspace queries. +type OrganizationWhereInput struct { + Predicates []predicate.Workspace `json:"-"` + Not *OrganizationWhereInput `json:"not,omitempty"` + Or []*OrganizationWhereInput `json:"or,omitempty"` + And []*OrganizationWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *int `json:"id,omitempty"` + IDNEQ *int `json:"idNEQ,omitempty"` + IDIn []int `json:"idIn,omitempty"` + IDNotIn []int `json:"idNotIn,omitempty"` + IDGT *int `json:"idGT,omitempty"` + IDGTE *int `json:"idGTE,omitempty"` + IDLT *int `json:"idLT,omitempty"` + IDLTE *int `json:"idLTE,omitempty"` + + // "name" field predicates. + Name *string `json:"name,omitempty"` + NameNEQ *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGT *string `json:"nameGT,omitempty"` + NameGTE *string `json:"nameGTE,omitempty"` + NameLT *string `json:"nameLT,omitempty"` + NameLTE *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *OrganizationWhereInput) AddPredicates(predicates ...predicate.Workspace) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the OrganizationWhereInput filter on the WorkspaceQuery builder. +func (i *OrganizationWhereInput) Filter(q *WorkspaceQuery) (*WorkspaceQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyOrganizationWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyOrganizationWhereInput is returned in case the OrganizationWhereInput is empty. +var ErrEmptyOrganizationWhereInput = errors.New("ent: empty predicate OrganizationWhereInput") + +// P returns a predicate for filtering workspaces. +// An error is returned if the input is empty or invalid. +func (i *OrganizationWhereInput) P() (predicate.Workspace, error) { + var predicates []predicate.Workspace + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, workspace.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.Workspace, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, workspace.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.Workspace, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, workspace.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, workspace.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, workspace.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, workspace.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, workspace.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, workspace.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, workspace.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, workspace.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, workspace.IDLTE(*i.IDLTE)) + } + if i.Name != nil { + predicates = append(predicates, workspace.NameEQ(*i.Name)) + } + if i.NameNEQ != nil { + predicates = append(predicates, workspace.NameNEQ(*i.NameNEQ)) + } + if len(i.NameIn) > 0 { + predicates = append(predicates, workspace.NameIn(i.NameIn...)) + } + if len(i.NameNotIn) > 0 { + predicates = append(predicates, workspace.NameNotIn(i.NameNotIn...)) + } + if i.NameGT != nil { + predicates = append(predicates, workspace.NameGT(*i.NameGT)) + } + if i.NameGTE != nil { + predicates = append(predicates, workspace.NameGTE(*i.NameGTE)) + } + if i.NameLT != nil { + predicates = append(predicates, workspace.NameLT(*i.NameLT)) + } + if i.NameLTE != nil { + predicates = append(predicates, workspace.NameLTE(*i.NameLTE)) + } + if i.NameContains != nil { + predicates = append(predicates, workspace.NameContains(*i.NameContains)) + } + if i.NameHasPrefix != nil { + predicates = append(predicates, workspace.NameHasPrefix(*i.NameHasPrefix)) + } + if i.NameHasSuffix != nil { + predicates = append(predicates, workspace.NameHasSuffix(*i.NameHasSuffix)) + } + if i.NameEqualFold != nil { + predicates = append(predicates, workspace.NameEqualFold(*i.NameEqualFold)) + } + if i.NameContainsFold != nil { + predicates = append(predicates, workspace.NameContainsFold(*i.NameContainsFold)) + } + + switch len(predicates) { + case 0: + return nil, ErrEmptyOrganizationWhereInput + case 1: + return predicates[0], nil + default: + return workspace.And(predicates...), nil + } +} diff --git a/entgql/internal/todo/ent/group/where.go b/entgql/internal/todo/ent/group/where.go index c7431e161..6867a1aa7 100644 --- a/entgql/internal/todo/ent/group/where.go +++ b/entgql/internal/todo/ent/group/where.go @@ -162,32 +162,15 @@ func HasUsersWith(preds ...predicate.User) predicate.Group { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Group(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/group_create.go b/entgql/internal/todo/ent/group_create.go index f1e5b1cbc..930535566 100644 --- a/entgql/internal/todo/ent/group_create.go +++ b/entgql/internal/todo/ent/group_create.go @@ -71,7 +71,7 @@ func (gc *GroupCreate) Mutation() *GroupMutation { // Save creates the Group in the database. func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) { gc.defaults() - return withHooks[*Group, GroupMutation](ctx, gc.sqlSave, gc.mutation, gc.hooks) + return withHooks(ctx, gc.sqlSave, gc.mutation, gc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -161,11 +161,15 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { // GroupCreateBulk is the builder for creating many Group entities in bulk. type GroupCreateBulk struct { config + err error builders []*GroupCreate } // Save creates the Group entities in the database. func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { + if gcb.err != nil { + return nil, gcb.err + } specs := make([]*sqlgraph.CreateSpec, len(gcb.builders)) nodes := make([]*Group, len(gcb.builders)) mutators := make([]Mutator, len(gcb.builders)) diff --git a/entgql/internal/todo/ent/group_delete.go b/entgql/internal/todo/ent/group_delete.go index 98b19527b..ea2b595db 100644 --- a/entgql/internal/todo/ent/group_delete.go +++ b/entgql/internal/todo/ent/group_delete.go @@ -41,7 +41,7 @@ func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (gd *GroupDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gd.sqlExec, gd.mutation, gd.hooks) + return withHooks(ctx, gd.sqlExec, gd.mutation, gd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/group_query.go b/entgql/internal/todo/ent/group_query.go index 3689551a9..63898b310 100644 --- a/entgql/internal/todo/ent/group_query.go +++ b/entgql/internal/todo/ent/group_query.go @@ -38,8 +38,8 @@ type GroupQuery struct { inters []Interceptor predicates []predicate.Group withUsers *UserQuery - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Group) error + modifiers []func(*sql.Selector) withNamedUsers map[string]*UserQuery // intermediate query (i.e. traversal path). sql *sql.Selector @@ -563,6 +563,9 @@ func (gq *GroupQuery) sqlQuery(ctx context.Context) *sql.Selector { if gq.ctx.Unique != nil && *gq.ctx.Unique { selector.Distinct() } + for _, m := range gq.modifiers { + m(selector) + } for _, p := range gq.predicates { p(selector) } @@ -580,6 +583,12 @@ func (gq *GroupQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (gq *GroupQuery) Modify(modifiers ...func(s *sql.Selector)) *GroupSelect { + gq.modifiers = append(gq.modifiers, modifiers...) + return gq.Select() +} + // WithNamedUsers tells the query-builder to eager-load the nodes that are connected to the "users" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (gq *GroupQuery) WithNamedUsers(name string, opts ...func(*UserQuery)) *GroupQuery { @@ -683,3 +692,9 @@ func (gs *GroupSelect) sqlScan(ctx context.Context, root *GroupQuery, v any) err defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (gs *GroupSelect) Modify(modifiers ...func(s *sql.Selector)) *GroupSelect { + gs.modifiers = append(gs.modifiers, modifiers...) + return gs +} diff --git a/entgql/internal/todo/ent/group_update.go b/entgql/internal/todo/ent/group_update.go index 8edcd22db..167eabe09 100644 --- a/entgql/internal/todo/ent/group_update.go +++ b/entgql/internal/todo/ent/group_update.go @@ -32,8 +32,9 @@ import ( // GroupUpdate is the builder for updating Group entities. type GroupUpdate struct { config - hooks []Hook - mutation *GroupMutation + hooks []Hook + mutation *GroupMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the GroupUpdate builder. @@ -99,7 +100,7 @@ func (gu *GroupUpdate) RemoveUsers(u ...*User) *GroupUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (gu *GroupUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gu.sqlSave, gu.mutation, gu.hooks) + return withHooks(ctx, gu.sqlSave, gu.mutation, gu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -124,6 +125,12 @@ func (gu *GroupUpdate) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (gu *GroupUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupUpdate { + gu.modifiers = append(gu.modifiers, modifiers...) + return gu +} + func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec := sqlgraph.NewUpdateSpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) if ps := gu.mutation.predicates; len(ps) > 0 { @@ -181,6 +188,7 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(gu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} @@ -196,9 +204,10 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { // GroupUpdateOne is the builder for updating a single Group entity. type GroupUpdateOne struct { config - fields []string - hooks []Hook - mutation *GroupMutation + fields []string + hooks []Hook + mutation *GroupMutation + modifiers []func(*sql.UpdateBuilder) } // SetName sets the "name" field. @@ -271,7 +280,7 @@ func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOn // Save executes the query and returns the updated Group entity. func (guo *GroupUpdateOne) Save(ctx context.Context) (*Group, error) { - return withHooks[*Group, GroupMutation](ctx, guo.sqlSave, guo.mutation, guo.hooks) + return withHooks(ctx, guo.sqlSave, guo.mutation, guo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -296,6 +305,12 @@ func (guo *GroupUpdateOne) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (guo *GroupUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GroupUpdateOne { + guo.modifiers = append(guo.modifiers, modifiers...) + return guo +} + func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) { _spec := sqlgraph.NewUpdateSpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) id, ok := guo.mutation.ID() @@ -370,6 +385,7 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(guo.modifiers...) _node = &Group{config: guo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/hook/hook.go b/entgql/internal/todo/ent/hook/hook.go index 9a82114af..a1710a7be 100644 --- a/entgql/internal/todo/ent/hook/hook.go +++ b/entgql/internal/todo/ent/hook/hook.go @@ -131,6 +131,18 @@ func (f VerySecretFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.VerySecretMutation", m) } +// The WorkspaceFunc type is an adapter to allow the use of ordinary +// function as Workspace mutator. +type WorkspaceFunc func(context.Context, *ent.WorkspaceMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f WorkspaceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.WorkspaceMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WorkspaceMutation", m) +} + // Condition is a hook condition function. type Condition func(context.Context, ent.Mutation) bool diff --git a/entgql/internal/todo/ent/migrate/schema.go b/entgql/internal/todo/ent/migrate/schema.go index cd708b2a3..d5a611113 100644 --- a/entgql/internal/todo/ent/migrate/schema.go +++ b/entgql/internal/todo/ent/migrate/schema.go @@ -41,6 +41,7 @@ var ( {Name: "text", Type: field.TypeString, Size: 2147483647}, {Name: "status", Type: field.TypeEnum, Enums: []string{"ENABLED", "DISABLED"}}, {Name: "config", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"sqlite3": "json"}}, + {Name: "types", Type: field.TypeJSON, Nullable: true}, {Name: "duration", Type: field.TypeInt64, Nullable: true}, {Name: "count", Type: field.TypeUint64, Nullable: true}, {Name: "strings", Type: field.TypeJSON, Nullable: true}, @@ -181,6 +182,7 @@ var ( {Name: "name", Type: field.TypeString, Default: "Anonymous"}, {Name: "username", Type: field.TypeUUID}, {Name: "password", Type: field.TypeString, Nullable: true}, + {Name: "required_metadata", Type: field.TypeJSON}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, } // UsersTable holds the schema information for the "users" table. @@ -200,6 +202,17 @@ var ( Columns: VerySecretsColumns, PrimaryKey: []*schema.Column{VerySecretsColumns[0]}, } + // WorkspacesColumns holds the columns for the "workspaces" table. + WorkspacesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "name", Type: field.TypeString}, + } + // WorkspacesTable holds the schema information for the "workspaces" table. + WorkspacesTable = &schema.Table{ + Name: "workspaces", + Columns: WorkspacesColumns, + PrimaryKey: []*schema.Column{WorkspacesColumns[0]}, + } // CategorySubCategoriesColumns holds the columns for the "category_sub_categories" table. CategorySubCategoriesColumns = []*schema.Column{ {Name: "category_id", Type: field.TypeInt}, @@ -261,6 +274,7 @@ var ( TodosTable, UsersTable, VerySecretsTable, + WorkspacesTable, CategorySubCategoriesTable, UserGroupsTable, } diff --git a/entgql/internal/todo/ent/mutation.go b/entgql/internal/todo/ent/mutation.go index 1dc5049ad..70e8290ad 100644 --- a/entgql/internal/todo/ent/mutation.go +++ b/entgql/internal/todo/ent/mutation.go @@ -35,6 +35,7 @@ import ( "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todo/ent/user" "entgo.io/contrib/entgql/internal/todo/ent/verysecret" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/google/uuid" @@ -58,6 +59,7 @@ const ( TypeTodo = "Todo" TypeUser = "User" TypeVerySecret = "VerySecret" + TypeWorkspace = "Workspace" ) // BillProductMutation represents an operation that mutates the BillProduct nodes in the graph. @@ -539,6 +541,7 @@ type CategoryMutation struct { text *string status *category.Status _config **schematype.CategoryConfig + types **schematype.CategoryTypes duration *time.Duration addduration *time.Duration count *uint64 @@ -782,6 +785,55 @@ func (m *CategoryMutation) ResetConfig() { delete(m.clearedFields, category.FieldConfig) } +// SetTypes sets the "types" field. +func (m *CategoryMutation) SetTypes(st *schematype.CategoryTypes) { + m.types = &st +} + +// Types returns the value of the "types" field in the mutation. +func (m *CategoryMutation) Types() (r *schematype.CategoryTypes, exists bool) { + v := m.types + if v == nil { + return + } + return *v, true +} + +// OldTypes returns the old "types" field's value of the Category entity. +// If the Category object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CategoryMutation) OldTypes(ctx context.Context) (v *schematype.CategoryTypes, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTypes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTypes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTypes: %w", err) + } + return oldValue.Types, nil +} + +// ClearTypes clears the value of the "types" field. +func (m *CategoryMutation) ClearTypes() { + m.types = nil + m.clearedFields[category.FieldTypes] = struct{}{} +} + +// TypesCleared returns if the "types" field was cleared in this mutation. +func (m *CategoryMutation) TypesCleared() bool { + _, ok := m.clearedFields[category.FieldTypes] + return ok +} + +// ResetTypes resets all changes to the "types" field. +func (m *CategoryMutation) ResetTypes() { + m.types = nil + delete(m.clearedFields, category.FieldTypes) +} + // SetDuration sets the "duration" field. func (m *CategoryMutation) SetDuration(t time.Duration) { m.duration = &t @@ -1129,7 +1181,7 @@ func (m *CategoryMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *CategoryMutation) Fields() []string { - fields := make([]string, 0, 6) + fields := make([]string, 0, 7) if m.text != nil { fields = append(fields, category.FieldText) } @@ -1139,6 +1191,9 @@ func (m *CategoryMutation) Fields() []string { if m._config != nil { fields = append(fields, category.FieldConfig) } + if m.types != nil { + fields = append(fields, category.FieldTypes) + } if m.duration != nil { fields = append(fields, category.FieldDuration) } @@ -1162,6 +1217,8 @@ func (m *CategoryMutation) Field(name string) (ent.Value, bool) { return m.Status() case category.FieldConfig: return m.Config() + case category.FieldTypes: + return m.Types() case category.FieldDuration: return m.Duration() case category.FieldCount: @@ -1183,6 +1240,8 @@ func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldStatus(ctx) case category.FieldConfig: return m.OldConfig(ctx) + case category.FieldTypes: + return m.OldTypes(ctx) case category.FieldDuration: return m.OldDuration(ctx) case category.FieldCount: @@ -1219,6 +1278,13 @@ func (m *CategoryMutation) SetField(name string, value ent.Value) error { } m.SetConfig(v) return nil + case category.FieldTypes: + v, ok := value.(*schematype.CategoryTypes) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTypes(v) + return nil case category.FieldDuration: v, ok := value.(time.Duration) if !ok { @@ -1300,6 +1366,9 @@ func (m *CategoryMutation) ClearedFields() []string { if m.FieldCleared(category.FieldConfig) { fields = append(fields, category.FieldConfig) } + if m.FieldCleared(category.FieldTypes) { + fields = append(fields, category.FieldTypes) + } if m.FieldCleared(category.FieldDuration) { fields = append(fields, category.FieldDuration) } @@ -1326,6 +1395,9 @@ func (m *CategoryMutation) ClearField(name string) error { case category.FieldConfig: m.ClearConfig() return nil + case category.FieldTypes: + m.ClearTypes() + return nil case category.FieldDuration: m.ClearDuration() return nil @@ -1352,6 +1424,9 @@ func (m *CategoryMutation) ResetField(name string) error { case category.FieldConfig: m.ResetConfig() return nil + case category.FieldTypes: + m.ResetTypes() + return nil case category.FieldDuration: m.ResetDuration() return nil @@ -1701,6 +1776,7 @@ func (m *FriendshipMutation) ResetFriendID() { // ClearUser clears the "user" edge to the User entity. func (m *FriendshipMutation) ClearUser() { m.cleareduser = true + m.clearedFields[friendship.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. @@ -1727,6 +1803,7 @@ func (m *FriendshipMutation) ResetUser() { // ClearFriend clears the "friend" edge to the User entity. func (m *FriendshipMutation) ClearFriend() { m.clearedfriend = true + m.clearedFields[friendship.FieldFriendID] = struct{}{} } // FriendCleared reports if the "friend" edge to the User entity was cleared. @@ -2683,6 +2760,7 @@ func (m *OneToManyMutation) ResetParentID() { // ClearParent clears the "parent" edge to the OneToMany entity. func (m *OneToManyMutation) ClearParent() { m.clearedparent = true + m.clearedFields[onetomany.FieldParentID] = struct{}{} } // ParentCleared reports if the "parent" edge to the OneToMany entity was cleared. @@ -4069,6 +4147,7 @@ func (m *TodoMutation) ResetChildren() { // ClearCategory clears the "category" edge to the Category entity. func (m *TodoMutation) ClearCategory() { m.clearedcategory = true + m.clearedFields[todo.FieldCategoryID] = struct{}{} } // CategoryCleared reports if the "category" edge to the Category entity was cleared. @@ -4593,6 +4672,7 @@ type UserMutation struct { name *string username *uuid.UUID password *string + required_metadata *map[string]interface{} metadata *map[string]interface{} clearedFields map[string]struct{} groups map[int]struct{} @@ -4828,6 +4908,42 @@ func (m *UserMutation) ResetPassword() { delete(m.clearedFields, user.FieldPassword) } +// SetRequiredMetadata sets the "required_metadata" field. +func (m *UserMutation) SetRequiredMetadata(value map[string]interface{}) { + m.required_metadata = &value +} + +// RequiredMetadata returns the value of the "required_metadata" field in the mutation. +func (m *UserMutation) RequiredMetadata() (r map[string]interface{}, exists bool) { + v := m.required_metadata + if v == nil { + return + } + return *v, true +} + +// OldRequiredMetadata returns the old "required_metadata" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldRequiredMetadata(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRequiredMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRequiredMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRequiredMetadata: %w", err) + } + return oldValue.RequiredMetadata, nil +} + +// ResetRequiredMetadata resets all changes to the "required_metadata" field. +func (m *UserMutation) ResetRequiredMetadata() { + m.required_metadata = nil +} + // SetMetadata sets the "metadata" field. func (m *UserMutation) SetMetadata(value map[string]interface{}) { m.metadata = &value @@ -5073,7 +5189,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 4) + fields := make([]string, 0, 5) if m.name != nil { fields = append(fields, user.FieldName) } @@ -5083,6 +5199,9 @@ func (m *UserMutation) Fields() []string { if m.password != nil { fields = append(fields, user.FieldPassword) } + if m.required_metadata != nil { + fields = append(fields, user.FieldRequiredMetadata) + } if m.metadata != nil { fields = append(fields, user.FieldMetadata) } @@ -5100,6 +5219,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.Username() case user.FieldPassword: return m.Password() + case user.FieldRequiredMetadata: + return m.RequiredMetadata() case user.FieldMetadata: return m.Metadata() } @@ -5117,6 +5238,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldUsername(ctx) case user.FieldPassword: return m.OldPassword(ctx) + case user.FieldRequiredMetadata: + return m.OldRequiredMetadata(ctx) case user.FieldMetadata: return m.OldMetadata(ctx) } @@ -5149,6 +5272,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetPassword(v) return nil + case user.FieldRequiredMetadata: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRequiredMetadata(v) + return nil case user.FieldMetadata: v, ok := value.(map[string]interface{}) if !ok { @@ -5229,6 +5359,9 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldPassword: m.ResetPassword() return nil + case user.FieldRequiredMetadata: + m.ResetRequiredMetadata() + return nil case user.FieldMetadata: m.ResetMetadata() return nil @@ -5697,3 +5830,329 @@ func (m *VerySecretMutation) ClearEdge(name string) error { func (m *VerySecretMutation) ResetEdge(name string) error { return fmt.Errorf("unknown VerySecret edge %s", name) } + +// WorkspaceMutation represents an operation that mutates the Workspace nodes in the graph. +type WorkspaceMutation struct { + config + op Op + typ string + id *int + name *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Workspace, error) + predicates []predicate.Workspace +} + +var _ ent.Mutation = (*WorkspaceMutation)(nil) + +// workspaceOption allows management of the mutation configuration using functional options. +type workspaceOption func(*WorkspaceMutation) + +// newWorkspaceMutation creates new mutation for the Workspace entity. +func newWorkspaceMutation(c config, op Op, opts ...workspaceOption) *WorkspaceMutation { + m := &WorkspaceMutation{ + config: c, + op: op, + typ: TypeWorkspace, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withWorkspaceID sets the ID field of the mutation. +func withWorkspaceID(id int) workspaceOption { + return func(m *WorkspaceMutation) { + var ( + err error + once sync.Once + value *Workspace + ) + m.oldValue = func(ctx context.Context) (*Workspace, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Workspace.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withWorkspace sets the old Workspace of the mutation. +func withWorkspace(node *Workspace) workspaceOption { + return func(m *WorkspaceMutation) { + m.oldValue = func(context.Context) (*Workspace, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m WorkspaceMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m WorkspaceMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *WorkspaceMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *WorkspaceMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Workspace.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetName sets the "name" field. +func (m *WorkspaceMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *WorkspaceMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Workspace entity. +// If the Workspace object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkspaceMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *WorkspaceMutation) ResetName() { + m.name = nil +} + +// Where appends a list predicates to the WorkspaceMutation builder. +func (m *WorkspaceMutation) Where(ps ...predicate.Workspace) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the WorkspaceMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *WorkspaceMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Workspace, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *WorkspaceMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *WorkspaceMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Workspace). +func (m *WorkspaceMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *WorkspaceMutation) Fields() []string { + fields := make([]string, 0, 1) + if m.name != nil { + fields = append(fields, workspace.FieldName) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *WorkspaceMutation) Field(name string) (ent.Value, bool) { + switch name { + case workspace.FieldName: + return m.Name() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *WorkspaceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case workspace.FieldName: + return m.OldName(ctx) + } + return nil, fmt.Errorf("unknown Workspace field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *WorkspaceMutation) SetField(name string, value ent.Value) error { + switch name { + case workspace.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + } + return fmt.Errorf("unknown Workspace field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *WorkspaceMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *WorkspaceMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *WorkspaceMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Workspace numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *WorkspaceMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *WorkspaceMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *WorkspaceMutation) ClearField(name string) error { + return fmt.Errorf("unknown Workspace nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *WorkspaceMutation) ResetField(name string) error { + switch name { + case workspace.FieldName: + m.ResetName() + return nil + } + return fmt.Errorf("unknown Workspace field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *WorkspaceMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *WorkspaceMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *WorkspaceMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *WorkspaceMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *WorkspaceMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *WorkspaceMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *WorkspaceMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Workspace unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *WorkspaceMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Workspace edge %s", name) +} diff --git a/entgql/internal/todo/ent/onetomany/where.go b/entgql/internal/todo/ent/onetomany/where.go index 0a90bb964..70e8ffcaf 100644 --- a/entgql/internal/todo/ent/onetomany/where.go +++ b/entgql/internal/todo/ent/onetomany/where.go @@ -300,32 +300,15 @@ func HasChildrenWith(preds ...predicate.OneToMany) predicate.OneToMany { // And groups predicates with the AND operator between them. func And(predicates ...predicate.OneToMany) predicate.OneToMany { - return predicate.OneToMany(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.OneToMany(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.OneToMany) predicate.OneToMany { - return predicate.OneToMany(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.OneToMany(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.OneToMany) predicate.OneToMany { - return predicate.OneToMany(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.OneToMany(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/onetomany_create.go b/entgql/internal/todo/ent/onetomany_create.go index 01e9000ba..db7fd449b 100644 --- a/entgql/internal/todo/ent/onetomany_create.go +++ b/entgql/internal/todo/ent/onetomany_create.go @@ -94,7 +94,7 @@ func (otmc *OneToManyCreate) Mutation() *OneToManyMutation { // Save creates the OneToMany in the database. func (otmc *OneToManyCreate) Save(ctx context.Context) (*OneToMany, error) { - return withHooks[*OneToMany, OneToManyMutation](ctx, otmc.sqlSave, otmc.mutation, otmc.hooks) + return withHooks(ctx, otmc.sqlSave, otmc.mutation, otmc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -202,11 +202,15 @@ func (otmc *OneToManyCreate) createSpec() (*OneToMany, *sqlgraph.CreateSpec) { // OneToManyCreateBulk is the builder for creating many OneToMany entities in bulk. type OneToManyCreateBulk struct { config + err error builders []*OneToManyCreate } // Save creates the OneToMany entities in the database. func (otmcb *OneToManyCreateBulk) Save(ctx context.Context) ([]*OneToMany, error) { + if otmcb.err != nil { + return nil, otmcb.err + } specs := make([]*sqlgraph.CreateSpec, len(otmcb.builders)) nodes := make([]*OneToMany, len(otmcb.builders)) mutators := make([]Mutator, len(otmcb.builders)) diff --git a/entgql/internal/todo/ent/onetomany_delete.go b/entgql/internal/todo/ent/onetomany_delete.go index 2f80575f1..a4a6ead7f 100644 --- a/entgql/internal/todo/ent/onetomany_delete.go +++ b/entgql/internal/todo/ent/onetomany_delete.go @@ -41,7 +41,7 @@ func (otmd *OneToManyDelete) Where(ps ...predicate.OneToMany) *OneToManyDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (otmd *OneToManyDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, OneToManyMutation](ctx, otmd.sqlExec, otmd.mutation, otmd.hooks) + return withHooks(ctx, otmd.sqlExec, otmd.mutation, otmd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/onetomany_query.go b/entgql/internal/todo/ent/onetomany_query.go index 9f8b1466d..1ea3b5eed 100644 --- a/entgql/internal/todo/ent/onetomany_query.go +++ b/entgql/internal/todo/ent/onetomany_query.go @@ -38,8 +38,8 @@ type OneToManyQuery struct { predicates []predicate.OneToMany withParent *OneToManyQuery withChildren *OneToManyQuery - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*OneToMany) error + modifiers []func(*sql.Selector) withNamedChildren map[string]*OneToManyQuery // intermediate query (i.e. traversal path). sql *sql.Selector @@ -605,6 +605,9 @@ func (otmq *OneToManyQuery) sqlQuery(ctx context.Context) *sql.Selector { if otmq.ctx.Unique != nil && *otmq.ctx.Unique { selector.Distinct() } + for _, m := range otmq.modifiers { + m(selector) + } for _, p := range otmq.predicates { p(selector) } @@ -622,6 +625,12 @@ func (otmq *OneToManyQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (otmq *OneToManyQuery) Modify(modifiers ...func(s *sql.Selector)) *OneToManySelect { + otmq.modifiers = append(otmq.modifiers, modifiers...) + return otmq.Select() +} + // WithNamedChildren tells the query-builder to eager-load the nodes that are connected to the "children" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (otmq *OneToManyQuery) WithNamedChildren(name string, opts ...func(*OneToManyQuery)) *OneToManyQuery { @@ -725,3 +734,9 @@ func (otms *OneToManySelect) sqlScan(ctx context.Context, root *OneToManyQuery, defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (otms *OneToManySelect) Modify(modifiers ...func(s *sql.Selector)) *OneToManySelect { + otms.modifiers = append(otms.modifiers, modifiers...) + return otms +} diff --git a/entgql/internal/todo/ent/onetomany_update.go b/entgql/internal/todo/ent/onetomany_update.go index 79590049d..302b2e42f 100644 --- a/entgql/internal/todo/ent/onetomany_update.go +++ b/entgql/internal/todo/ent/onetomany_update.go @@ -31,8 +31,9 @@ import ( // OneToManyUpdate is the builder for updating OneToMany entities. type OneToManyUpdate struct { config - hooks []Hook - mutation *OneToManyMutation + hooks []Hook + mutation *OneToManyMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the OneToManyUpdate builder. @@ -47,6 +48,14 @@ func (otmu *OneToManyUpdate) SetName(s string) *OneToManyUpdate { return otmu } +// SetNillableName sets the "name" field if the given value is not nil. +func (otmu *OneToManyUpdate) SetNillableName(s *string) *OneToManyUpdate { + if s != nil { + otmu.SetName(*s) + } + return otmu +} + // SetField2 sets the "field2" field. func (otmu *OneToManyUpdate) SetField2(s string) *OneToManyUpdate { otmu.mutation.SetField2(s) @@ -141,7 +150,7 @@ func (otmu *OneToManyUpdate) RemoveChildren(o ...*OneToMany) *OneToManyUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (otmu *OneToManyUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, OneToManyMutation](ctx, otmu.sqlSave, otmu.mutation, otmu.hooks) + return withHooks(ctx, otmu.sqlSave, otmu.mutation, otmu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -176,6 +185,12 @@ func (otmu *OneToManyUpdate) check() error { return nil } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (otmu *OneToManyUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OneToManyUpdate { + otmu.modifiers = append(otmu.modifiers, modifiers...) + return otmu +} + func (otmu *OneToManyUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := otmu.check(); err != nil { return n, err @@ -271,6 +286,7 @@ func (otmu *OneToManyUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(otmu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, otmu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{onetomany.Label} @@ -286,9 +302,10 @@ func (otmu *OneToManyUpdate) sqlSave(ctx context.Context) (n int, err error) { // OneToManyUpdateOne is the builder for updating a single OneToMany entity. type OneToManyUpdateOne struct { config - fields []string - hooks []Hook - mutation *OneToManyMutation + fields []string + hooks []Hook + mutation *OneToManyMutation + modifiers []func(*sql.UpdateBuilder) } // SetName sets the "name" field. @@ -297,6 +314,14 @@ func (otmuo *OneToManyUpdateOne) SetName(s string) *OneToManyUpdateOne { return otmuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (otmuo *OneToManyUpdateOne) SetNillableName(s *string) *OneToManyUpdateOne { + if s != nil { + otmuo.SetName(*s) + } + return otmuo +} + // SetField2 sets the "field2" field. func (otmuo *OneToManyUpdateOne) SetField2(s string) *OneToManyUpdateOne { otmuo.mutation.SetField2(s) @@ -404,7 +429,7 @@ func (otmuo *OneToManyUpdateOne) Select(field string, fields ...string) *OneToMa // Save executes the query and returns the updated OneToMany entity. func (otmuo *OneToManyUpdateOne) Save(ctx context.Context) (*OneToMany, error) { - return withHooks[*OneToMany, OneToManyMutation](ctx, otmuo.sqlSave, otmuo.mutation, otmuo.hooks) + return withHooks(ctx, otmuo.sqlSave, otmuo.mutation, otmuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -439,6 +464,12 @@ func (otmuo *OneToManyUpdateOne) check() error { return nil } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (otmuo *OneToManyUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *OneToManyUpdateOne { + otmuo.modifiers = append(otmuo.modifiers, modifiers...) + return otmuo +} + func (otmuo *OneToManyUpdateOne) sqlSave(ctx context.Context) (_node *OneToMany, err error) { if err := otmuo.check(); err != nil { return _node, err @@ -551,6 +582,7 @@ func (otmuo *OneToManyUpdateOne) sqlSave(ctx context.Context) (_node *OneToMany, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(otmuo.modifiers...) _node = &OneToMany{config: otmuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/predicate/predicate.go b/entgql/internal/todo/ent/predicate/predicate.go index cbdbc3cd2..c845c1038 100644 --- a/entgql/internal/todo/ent/predicate/predicate.go +++ b/entgql/internal/todo/ent/predicate/predicate.go @@ -46,3 +46,6 @@ type User func(*sql.Selector) // VerySecret is the predicate function for verysecret builders. type VerySecret func(*sql.Selector) + +// Workspace is the predicate function for workspace builders. +type Workspace func(*sql.Selector) diff --git a/entgql/internal/todo/ent/project/where.go b/entgql/internal/todo/ent/project/where.go index f775ae331..7d816da36 100644 --- a/entgql/internal/todo/ent/project/where.go +++ b/entgql/internal/todo/ent/project/where.go @@ -92,32 +92,15 @@ func HasTodosWith(preds ...predicate.Todo) predicate.Project { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Project) predicate.Project { - return predicate.Project(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Project(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Project) predicate.Project { - return predicate.Project(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Project(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Project) predicate.Project { - return predicate.Project(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Project(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/project_create.go b/entgql/internal/todo/ent/project_create.go index 161e62dc2..9fdb5d49c 100644 --- a/entgql/internal/todo/ent/project_create.go +++ b/entgql/internal/todo/ent/project_create.go @@ -55,7 +55,7 @@ func (pc *ProjectCreate) Mutation() *ProjectMutation { // Save creates the Project in the database. func (pc *ProjectCreate) Save(ctx context.Context) (*Project, error) { - return withHooks[*Project, ProjectMutation](ctx, pc.sqlSave, pc.mutation, pc.hooks) + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -130,11 +130,15 @@ func (pc *ProjectCreate) createSpec() (*Project, *sqlgraph.CreateSpec) { // ProjectCreateBulk is the builder for creating many Project entities in bulk. type ProjectCreateBulk struct { config + err error builders []*ProjectCreate } // Save creates the Project entities in the database. func (pcb *ProjectCreateBulk) Save(ctx context.Context) ([]*Project, error) { + if pcb.err != nil { + return nil, pcb.err + } specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) nodes := make([]*Project, len(pcb.builders)) mutators := make([]Mutator, len(pcb.builders)) diff --git a/entgql/internal/todo/ent/project_delete.go b/entgql/internal/todo/ent/project_delete.go index b1c353ed7..747400ef9 100644 --- a/entgql/internal/todo/ent/project_delete.go +++ b/entgql/internal/todo/ent/project_delete.go @@ -41,7 +41,7 @@ func (pd *ProjectDelete) Where(ps ...predicate.Project) *ProjectDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (pd *ProjectDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, ProjectMutation](ctx, pd.sqlExec, pd.mutation, pd.hooks) + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/project_query.go b/entgql/internal/todo/ent/project_query.go index d957129a0..009b90bf4 100644 --- a/entgql/internal/todo/ent/project_query.go +++ b/entgql/internal/todo/ent/project_query.go @@ -38,8 +38,8 @@ type ProjectQuery struct { inters []Interceptor predicates []predicate.Project withTodos *TodoQuery - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Project) error + modifiers []func(*sql.Selector) withNamedTodos map[string]*TodoQuery // intermediate query (i.e. traversal path). sql *sql.Selector @@ -511,6 +511,9 @@ func (pq *ProjectQuery) sqlQuery(ctx context.Context) *sql.Selector { if pq.ctx.Unique != nil && *pq.ctx.Unique { selector.Distinct() } + for _, m := range pq.modifiers { + m(selector) + } for _, p := range pq.predicates { p(selector) } @@ -528,6 +531,12 @@ func (pq *ProjectQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (pq *ProjectQuery) Modify(modifiers ...func(s *sql.Selector)) *ProjectSelect { + pq.modifiers = append(pq.modifiers, modifiers...) + return pq.Select() +} + // WithNamedTodos tells the query-builder to eager-load the nodes that are connected to the "todos" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (pq *ProjectQuery) WithNamedTodos(name string, opts ...func(*TodoQuery)) *ProjectQuery { @@ -631,3 +640,9 @@ func (ps *ProjectSelect) sqlScan(ctx context.Context, root *ProjectQuery, v any) defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (ps *ProjectSelect) Modify(modifiers ...func(s *sql.Selector)) *ProjectSelect { + ps.modifiers = append(ps.modifiers, modifiers...) + return ps +} diff --git a/entgql/internal/todo/ent/project_update.go b/entgql/internal/todo/ent/project_update.go index 110d12dc6..ce4ac7ce7 100644 --- a/entgql/internal/todo/ent/project_update.go +++ b/entgql/internal/todo/ent/project_update.go @@ -32,8 +32,9 @@ import ( // ProjectUpdate is the builder for updating Project entities. type ProjectUpdate struct { config - hooks []Hook - mutation *ProjectMutation + hooks []Hook + mutation *ProjectMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the ProjectUpdate builder. @@ -85,7 +86,7 @@ func (pu *ProjectUpdate) RemoveTodos(t ...*Todo) *ProjectUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *ProjectUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, ProjectMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks) + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -110,6 +111,12 @@ func (pu *ProjectUpdate) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (pu *ProjectUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProjectUpdate { + pu.modifiers = append(pu.modifiers, modifiers...) + return pu +} + func (pu *ProjectUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec := sqlgraph.NewUpdateSpec(project.Table, project.Columns, sqlgraph.NewFieldSpec(project.FieldID, field.TypeInt)) if ps := pu.mutation.predicates; len(ps) > 0 { @@ -164,6 +171,7 @@ func (pu *ProjectUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(pu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{project.Label} @@ -179,9 +187,10 @@ func (pu *ProjectUpdate) sqlSave(ctx context.Context) (n int, err error) { // ProjectUpdateOne is the builder for updating a single Project entity. type ProjectUpdateOne struct { config - fields []string - hooks []Hook - mutation *ProjectMutation + fields []string + hooks []Hook + mutation *ProjectMutation + modifiers []func(*sql.UpdateBuilder) } // AddTodoIDs adds the "todos" edge to the Todo entity by IDs. @@ -240,7 +249,7 @@ func (puo *ProjectUpdateOne) Select(field string, fields ...string) *ProjectUpda // Save executes the query and returns the updated Project entity. func (puo *ProjectUpdateOne) Save(ctx context.Context) (*Project, error) { - return withHooks[*Project, ProjectMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks) + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -265,6 +274,12 @@ func (puo *ProjectUpdateOne) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (puo *ProjectUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProjectUpdateOne { + puo.modifiers = append(puo.modifiers, modifiers...) + return puo +} + func (puo *ProjectUpdateOne) sqlSave(ctx context.Context) (_node *Project, err error) { _spec := sqlgraph.NewUpdateSpec(project.Table, project.Columns, sqlgraph.NewFieldSpec(project.FieldID, field.TypeInt)) id, ok := puo.mutation.ID() @@ -336,6 +351,7 @@ func (puo *ProjectUpdateOne) sqlSave(ctx context.Context) (_node *Project, err e } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(puo.modifiers...) _node = &Project{config: puo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/runtime/runtime.go b/entgql/internal/todo/ent/runtime/runtime.go index e0c02312c..d79c4530d 100644 --- a/entgql/internal/todo/ent/runtime/runtime.go +++ b/entgql/internal/todo/ent/runtime/runtime.go @@ -19,6 +19,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entgql/internal/todo/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entgql/internal/todo/ent/schema/category.go b/entgql/internal/todo/ent/schema/category.go index 9fc0386f9..fe4c632de 100644 --- a/entgql/internal/todo/ent/schema/category.go +++ b/entgql/internal/todo/ent/schema/category.go @@ -53,12 +53,15 @@ func (Category) Fields() []ent.Field { ). Annotations( entgql.Type("CategoryStatus"), + entgql.OrderField("STATUS"), ), field.Other("config", &schematype.CategoryConfig{}). SchemaType(map[string]string{ dialect.SQLite: "json", }). Optional(), + field.JSON("types", &schematype.CategoryTypes{}). + Optional(), field.Int64("duration"). GoType(time.Duration(0)). Optional(). diff --git a/entgql/internal/todo/ent/schema/group.go b/entgql/internal/todo/ent/schema/group.go index 9f171571e..3564bad06 100644 --- a/entgql/internal/todo/ent/schema/group.go +++ b/entgql/internal/todo/ent/schema/group.go @@ -54,5 +54,6 @@ func (Group) Annotations() []schema.Annotation { annotation.HasPermissions([]string{"ADMIN", "MODERATOR"}), ), entgql.MultiOrder(), + entgql.Implements("NamedNode"), } } diff --git a/entgql/internal/todo/ent/schema/schematype/schematype.go b/entgql/internal/todo/ent/schema/schematype/schematype.go index 479b6584c..000782edc 100644 --- a/entgql/internal/todo/ent/schema/schematype/schematype.go +++ b/entgql/internal/todo/ent/schema/schematype/schematype.go @@ -38,3 +38,8 @@ func (t *CategoryConfig) Scan(v interface{}) (err error) { func (t *CategoryConfig) Value() (driver.Value, error) { return json.Marshal(t) } + +// CategoryTypes is a simple JSON type. +type CategoryTypes struct { + Public bool `json:"public,omitempty"` +} diff --git a/entgql/internal/todo/ent/schema/todo.go b/entgql/internal/todo/ent/schema/todo.go index 83f223de4..bfdca908f 100644 --- a/entgql/internal/todo/ent/schema/todo.go +++ b/entgql/internal/todo/ent/schema/todo.go @@ -125,5 +125,6 @@ func (Todo) Annotations() []schema.Annotation { entgql.RelayConnection(), entgql.QueryField().Description("This is the todo item"), entgql.Mutations(entgql.MutationCreate(), entgql.MutationUpdate()), + entgql.MultiOrder(), } } diff --git a/entgql/internal/todo/ent/schema/user.go b/entgql/internal/todo/ent/schema/user.go index 88e852b08..c37be6637 100644 --- a/entgql/internal/todo/ent/schema/user.go +++ b/entgql/internal/todo/ent/schema/user.go @@ -38,7 +38,8 @@ func (User) Fields() []ent.Field { field.String("password"). Sensitive(). Optional(), - field.JSON("metadata", map[string]interface{}{}). + field.JSON("required_metadata", map[string]any{}), + field.JSON("metadata", map[string]any{}). Optional(), } } diff --git a/entgql/internal/todo/ent/schema/workspace.go b/entgql/internal/todo/ent/schema/workspace.go new file mode 100644 index 000000000..eacbe9801 --- /dev/null +++ b/entgql/internal/todo/ent/schema/workspace.go @@ -0,0 +1,42 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "entgo.io/contrib/entgql" + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" +) + +// Workspace defines the workspace type schema. +type Workspace struct { + ent.Schema +} + +// Fields returns workspace fields. +func (Workspace) Fields() []ent.Field { + return []ent.Field{ + field.String("name"), + } +} + +func (Workspace) Annotations() []schema.Annotation { + return []schema.Annotation{ + // Intentionally change the type + // name to test fields collection. + entgql.Type("Organization"), + } +} diff --git a/entgql/internal/todo/ent/todo/where.go b/entgql/internal/todo/ent/todo/where.go index 4167e0c88..70eba5527 100644 --- a/entgql/internal/todo/ent/todo/where.go +++ b/entgql/internal/todo/ent/todo/where.go @@ -463,32 +463,15 @@ func HasSecretWith(preds ...predicate.VerySecret) predicate.Todo { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Todo(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/todo_create.go b/entgql/internal/todo/ent/todo_create.go index a7fc58841..8486dbe26 100644 --- a/entgql/internal/todo/ent/todo_create.go +++ b/entgql/internal/todo/ent/todo_create.go @@ -181,7 +181,7 @@ func (tc *TodoCreate) Mutation() *TodoMutation { // Save creates the Todo in the database. func (tc *TodoCreate) Save(ctx context.Context) (*Todo, error) { tc.defaults() - return withHooks[*Todo, TodoMutation](ctx, tc.sqlSave, tc.mutation, tc.hooks) + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -373,11 +373,15 @@ func (tc *TodoCreate) createSpec() (*Todo, *sqlgraph.CreateSpec) { // TodoCreateBulk is the builder for creating many Todo entities in bulk. type TodoCreateBulk struct { config + err error builders []*TodoCreate } // Save creates the Todo entities in the database. func (tcb *TodoCreateBulk) Save(ctx context.Context) ([]*Todo, error) { + if tcb.err != nil { + return nil, tcb.err + } specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) nodes := make([]*Todo, len(tcb.builders)) mutators := make([]Mutator, len(tcb.builders)) diff --git a/entgql/internal/todo/ent/todo_delete.go b/entgql/internal/todo/ent/todo_delete.go index 9bc05829e..51b0fb756 100644 --- a/entgql/internal/todo/ent/todo_delete.go +++ b/entgql/internal/todo/ent/todo_delete.go @@ -41,7 +41,7 @@ func (td *TodoDelete) Where(ps ...predicate.Todo) *TodoDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (td *TodoDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, td.sqlExec, td.mutation, td.hooks) + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/todo_query.go b/entgql/internal/todo/ent/todo_query.go index a0c7d72f2..81f8ce5bb 100644 --- a/entgql/internal/todo/ent/todo_query.go +++ b/entgql/internal/todo/ent/todo_query.go @@ -43,8 +43,8 @@ type TodoQuery struct { withCategory *CategoryQuery withSecret *VerySecretQuery withFKs bool - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Todo) error + modifiers []func(*sql.Selector) withNamedChildren map[string]*TodoQuery // intermediate query (i.e. traversal path). sql *sql.Selector @@ -764,6 +764,9 @@ func (tq *TodoQuery) sqlQuery(ctx context.Context) *sql.Selector { if tq.ctx.Unique != nil && *tq.ctx.Unique { selector.Distinct() } + for _, m := range tq.modifiers { + m(selector) + } for _, p := range tq.predicates { p(selector) } @@ -781,6 +784,12 @@ func (tq *TodoQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (tq *TodoQuery) Modify(modifiers ...func(s *sql.Selector)) *TodoSelect { + tq.modifiers = append(tq.modifiers, modifiers...) + return tq.Select() +} + // WithNamedChildren tells the query-builder to eager-load the nodes that are connected to the "children" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (tq *TodoQuery) WithNamedChildren(name string, opts ...func(*TodoQuery)) *TodoQuery { @@ -884,3 +893,9 @@ func (ts *TodoSelect) sqlScan(ctx context.Context, root *TodoQuery, v any) error defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (ts *TodoSelect) Modify(modifiers ...func(s *sql.Selector)) *TodoSelect { + ts.modifiers = append(ts.modifiers, modifiers...) + return ts +} diff --git a/entgql/internal/todo/ent/todo_update.go b/entgql/internal/todo/ent/todo_update.go index 640a9c753..c1dacd8c0 100644 --- a/entgql/internal/todo/ent/todo_update.go +++ b/entgql/internal/todo/ent/todo_update.go @@ -34,8 +34,9 @@ import ( // TodoUpdate is the builder for updating Todo entities. type TodoUpdate struct { config - hooks []Hook - mutation *TodoMutation + hooks []Hook + mutation *TodoMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the TodoUpdate builder. @@ -50,6 +51,14 @@ func (tu *TodoUpdate) SetStatus(t todo.Status) *TodoUpdate { return tu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableStatus(t *todo.Status) *TodoUpdate { + if t != nil { + tu.SetStatus(*t) + } + return tu +} + // SetPriority sets the "priority" field. func (tu *TodoUpdate) SetPriority(i int) *TodoUpdate { tu.mutation.ResetPriority() @@ -77,6 +86,14 @@ func (tu *TodoUpdate) SetText(s string) *TodoUpdate { return tu } +// SetNillableText sets the "text" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableText(s *string) *TodoUpdate { + if s != nil { + tu.SetText(*s) + } + return tu +} + // SetBlob sets the "blob" field. func (tu *TodoUpdate) SetBlob(b []byte) *TodoUpdate { tu.mutation.SetBlob(b) @@ -230,7 +247,7 @@ func (tu *TodoUpdate) ClearSecret() *TodoUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TodoUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, tu.sqlSave, tu.mutation, tu.hooks) + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -270,6 +287,12 @@ func (tu *TodoUpdate) check() error { return nil } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (tu *TodoUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TodoUpdate { + tu.modifiers = append(tu.modifiers, modifiers...) + return tu +} + func (tu *TodoUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := tu.check(); err != nil { return n, err @@ -431,6 +454,7 @@ func (tu *TodoUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(tu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{todo.Label} @@ -446,9 +470,10 @@ func (tu *TodoUpdate) sqlSave(ctx context.Context) (n int, err error) { // TodoUpdateOne is the builder for updating a single Todo entity. type TodoUpdateOne struct { config - fields []string - hooks []Hook - mutation *TodoMutation + fields []string + hooks []Hook + mutation *TodoMutation + modifiers []func(*sql.UpdateBuilder) } // SetStatus sets the "status" field. @@ -457,6 +482,14 @@ func (tuo *TodoUpdateOne) SetStatus(t todo.Status) *TodoUpdateOne { return tuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableStatus(t *todo.Status) *TodoUpdateOne { + if t != nil { + tuo.SetStatus(*t) + } + return tuo +} + // SetPriority sets the "priority" field. func (tuo *TodoUpdateOne) SetPriority(i int) *TodoUpdateOne { tuo.mutation.ResetPriority() @@ -484,6 +517,14 @@ func (tuo *TodoUpdateOne) SetText(s string) *TodoUpdateOne { return tuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableText(s *string) *TodoUpdateOne { + if s != nil { + tuo.SetText(*s) + } + return tuo +} + // SetBlob sets the "blob" field. func (tuo *TodoUpdateOne) SetBlob(b []byte) *TodoUpdateOne { tuo.mutation.SetBlob(b) @@ -650,7 +691,7 @@ func (tuo *TodoUpdateOne) Select(field string, fields ...string) *TodoUpdateOne // Save executes the query and returns the updated Todo entity. func (tuo *TodoUpdateOne) Save(ctx context.Context) (*Todo, error) { - return withHooks[*Todo, TodoMutation](ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -690,6 +731,12 @@ func (tuo *TodoUpdateOne) check() error { return nil } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (tuo *TodoUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TodoUpdateOne { + tuo.modifiers = append(tuo.modifiers, modifiers...) + return tuo +} + func (tuo *TodoUpdateOne) sqlSave(ctx context.Context) (_node *Todo, err error) { if err := tuo.check(); err != nil { return _node, err @@ -868,6 +915,7 @@ func (tuo *TodoUpdateOne) sqlSave(ctx context.Context) (_node *Todo, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(tuo.modifiers...) _node = &Todo{config: tuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/tx.go b/entgql/internal/todo/ent/tx.go index 3d49c2216..b047282f7 100644 --- a/entgql/internal/todo/ent/tx.go +++ b/entgql/internal/todo/ent/tx.go @@ -44,6 +44,8 @@ type Tx struct { User *UserClient // VerySecret is the client for interacting with the VerySecret builders. VerySecret *VerySecretClient + // Workspace is the client for interacting with the Workspace builders. + Workspace *WorkspaceClient // lazily loaded. client *Client @@ -184,6 +186,7 @@ func (tx *Tx) init() { tx.Todo = NewTodoClient(tx.config) tx.User = NewUserClient(tx.config) tx.VerySecret = NewVerySecretClient(tx.config) + tx.Workspace = NewWorkspaceClient(tx.config) } // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. diff --git a/entgql/internal/todo/ent/user.go b/entgql/internal/todo/ent/user.go index c8c00905a..d78c92d8f 100644 --- a/entgql/internal/todo/ent/user.go +++ b/entgql/internal/todo/ent/user.go @@ -38,6 +38,8 @@ type User struct { Username uuid.UUID `json:"username,omitempty"` // Password holds the value of the "password" field. Password string `json:"-"` + // RequiredMetadata holds the value of the "required_metadata" field. + RequiredMetadata map[string]interface{} `json:"required_metadata,omitempty"` // Metadata holds the value of the "metadata" field. Metadata map[string]interface{} `json:"metadata,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -97,7 +99,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case user.FieldMetadata: + case user.FieldRequiredMetadata, user.FieldMetadata: values[i] = new([]byte) case user.FieldID: values[i] = new(sql.NullInt64) @@ -144,6 +146,14 @@ func (u *User) assignValues(columns []string, values []any) error { } else if value.Valid { u.Password = value.String } + case user.FieldRequiredMetadata: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field required_metadata", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &u.RequiredMetadata); err != nil { + return fmt.Errorf("unmarshal field required_metadata: %w", err) + } + } case user.FieldMetadata: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field metadata", values[i]) @@ -211,6 +221,9 @@ func (u *User) String() string { builder.WriteString(", ") builder.WriteString("password=") builder.WriteString(", ") + builder.WriteString("required_metadata=") + builder.WriteString(fmt.Sprintf("%v", u.RequiredMetadata)) + builder.WriteString(", ") builder.WriteString("metadata=") builder.WriteString(fmt.Sprintf("%v", u.Metadata)) builder.WriteByte(')') diff --git a/entgql/internal/todo/ent/user/user.go b/entgql/internal/todo/ent/user/user.go index 879f7916d..55beb1349 100644 --- a/entgql/internal/todo/ent/user/user.go +++ b/entgql/internal/todo/ent/user/user.go @@ -33,6 +33,8 @@ const ( FieldUsername = "username" // FieldPassword holds the string denoting the password field in the database. FieldPassword = "password" + // FieldRequiredMetadata holds the string denoting the required_metadata field in the database. + FieldRequiredMetadata = "required_metadata" // FieldMetadata holds the string denoting the metadata field in the database. FieldMetadata = "metadata" // EdgeGroups holds the string denoting the groups edge name in mutations. @@ -65,6 +67,7 @@ var Columns = []string{ FieldName, FieldUsername, FieldPassword, + FieldRequiredMetadata, FieldMetadata, } diff --git a/entgql/internal/todo/ent/user/where.go b/entgql/internal/todo/ent/user/where.go index fb40d2876..2c9323b52 100644 --- a/entgql/internal/todo/ent/user/where.go +++ b/entgql/internal/todo/ent/user/where.go @@ -344,32 +344,15 @@ func HasFriendshipsWith(preds ...predicate.Friendship) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/user_create.go b/entgql/internal/todo/ent/user_create.go index ad25cb475..51ef55403 100644 --- a/entgql/internal/todo/ent/user_create.go +++ b/entgql/internal/todo/ent/user_create.go @@ -78,6 +78,12 @@ func (uc *UserCreate) SetNillablePassword(s *string) *UserCreate { return uc } +// SetRequiredMetadata sets the "required_metadata" field. +func (uc *UserCreate) SetRequiredMetadata(m map[string]interface{}) *UserCreate { + uc.mutation.SetRequiredMetadata(m) + return uc +} + // SetMetadata sets the "metadata" field. func (uc *UserCreate) SetMetadata(m map[string]interface{}) *UserCreate { uc.mutation.SetMetadata(m) @@ -137,7 +143,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { uc.defaults() - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -182,6 +188,9 @@ func (uc *UserCreate) check() error { if _, ok := uc.mutation.Username(); !ok { return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} } + if _, ok := uc.mutation.RequiredMetadata(); !ok { + return &ValidationError{Name: "required_metadata", err: errors.New(`ent: missing required field "User.required_metadata"`)} + } return nil } @@ -220,6 +229,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldPassword, field.TypeString, value) _node.Password = value } + if value, ok := uc.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + _node.RequiredMetadata = value + } if value, ok := uc.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) _node.Metadata = value @@ -282,11 +295,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entgql/internal/todo/ent/user_delete.go b/entgql/internal/todo/ent/user_delete.go index 0aa279023..5cd6bc9e1 100644 --- a/entgql/internal/todo/ent/user_delete.go +++ b/entgql/internal/todo/ent/user_delete.go @@ -41,7 +41,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/user_query.go b/entgql/internal/todo/ent/user_query.go index 53da9ec7f..2509512d0 100644 --- a/entgql/internal/todo/ent/user_query.go +++ b/entgql/internal/todo/ent/user_query.go @@ -41,8 +41,8 @@ type UserQuery struct { withGroups *GroupQuery withFriends *UserQuery withFriendships *FriendshipQuery - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*User) error + modifiers []func(*sql.Selector) withNamedGroups map[string]*GroupQuery withNamedFriends map[string]*UserQuery withNamedFriendships map[string]*FriendshipQuery @@ -757,6 +757,9 @@ func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { if uq.ctx.Unique != nil && *uq.ctx.Unique { selector.Distinct() } + for _, m := range uq.modifiers { + m(selector) + } for _, p := range uq.predicates { p(selector) } @@ -774,6 +777,12 @@ func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (uq *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { + uq.modifiers = append(uq.modifiers, modifiers...) + return uq.Select() +} + // WithNamedGroups tells the query-builder to eager-load the nodes that are connected to the "groups" // edge with the given name. The optional arguments are used to configure the query builder of the edge. func (uq *UserQuery) WithNamedGroups(name string, opts ...func(*GroupQuery)) *UserQuery { @@ -905,3 +914,9 @@ func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (us *UserSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { + us.modifiers = append(us.modifiers, modifiers...) + return us +} diff --git a/entgql/internal/todo/ent/user_update.go b/entgql/internal/todo/ent/user_update.go index c9dbf6fe6..b834e126d 100644 --- a/entgql/internal/todo/ent/user_update.go +++ b/entgql/internal/todo/ent/user_update.go @@ -34,8 +34,9 @@ import ( // UserUpdate is the builder for updating User entities. type UserUpdate struct { config - hooks []Hook - mutation *UserMutation + hooks []Hook + mutation *UserMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the UserUpdate builder. @@ -92,6 +93,12 @@ func (uu *UserUpdate) ClearPassword() *UserUpdate { return uu } +// SetRequiredMetadata sets the "required_metadata" field. +func (uu *UserUpdate) SetRequiredMetadata(m map[string]interface{}) *UserUpdate { + uu.mutation.SetRequiredMetadata(m) + return uu +} + // SetMetadata sets the "metadata" field. func (uu *UserUpdate) SetMetadata(m map[string]interface{}) *UserUpdate { uu.mutation.SetMetadata(m) @@ -219,7 +226,7 @@ func (uu *UserUpdate) RemoveFriendships(f ...*Friendship) *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -244,6 +251,12 @@ func (uu *UserUpdate) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (uu *UserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdate { + uu.modifiers = append(uu.modifiers, modifiers...) + return uu +} + func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) if ps := uu.mutation.predicates; len(ps) > 0 { @@ -265,6 +278,9 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if uu.mutation.PasswordCleared() { _spec.ClearField(user.FieldPassword, field.TypeString) } + if value, ok := uu.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + } if value, ok := uu.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) } @@ -418,6 +434,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(uu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} @@ -433,9 +450,10 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { // UserUpdateOne is the builder for updating a single User entity. type UserUpdateOne struct { config - fields []string - hooks []Hook - mutation *UserMutation + fields []string + hooks []Hook + mutation *UserMutation + modifiers []func(*sql.UpdateBuilder) } // SetName sets the "name" field. @@ -486,6 +504,12 @@ func (uuo *UserUpdateOne) ClearPassword() *UserUpdateOne { return uuo } +// SetRequiredMetadata sets the "required_metadata" field. +func (uuo *UserUpdateOne) SetRequiredMetadata(m map[string]interface{}) *UserUpdateOne { + uuo.mutation.SetRequiredMetadata(m) + return uuo +} + // SetMetadata sets the "metadata" field. func (uuo *UserUpdateOne) SetMetadata(m map[string]interface{}) *UserUpdateOne { uuo.mutation.SetMetadata(m) @@ -626,7 +650,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -651,6 +675,12 @@ func (uuo *UserUpdateOne) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (uuo *UserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdateOne { + uuo.modifiers = append(uuo.modifiers, modifiers...) + return uuo +} + func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) id, ok := uuo.mutation.ID() @@ -689,6 +719,9 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if uuo.mutation.PasswordCleared() { _spec.ClearField(user.FieldPassword, field.TypeString) } + if value, ok := uuo.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + } if value, ok := uuo.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) } @@ -842,6 +875,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + _spec.AddModifiers(uuo.modifiers...) _node = &User{config: uuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/verysecret/where.go b/entgql/internal/todo/ent/verysecret/where.go index f98780abd..086916dc6 100644 --- a/entgql/internal/todo/ent/verysecret/where.go +++ b/entgql/internal/todo/ent/verysecret/where.go @@ -138,32 +138,15 @@ func PasswordContainsFold(v string) predicate.VerySecret { // And groups predicates with the AND operator between them. func And(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.VerySecret(sql.NotPredicates(p)) } diff --git a/entgql/internal/todo/ent/verysecret_create.go b/entgql/internal/todo/ent/verysecret_create.go index 418edc5b7..6e9ead9bb 100644 --- a/entgql/internal/todo/ent/verysecret_create.go +++ b/entgql/internal/todo/ent/verysecret_create.go @@ -46,7 +46,7 @@ func (vsc *VerySecretCreate) Mutation() *VerySecretMutation { // Save creates the VerySecret in the database. func (vsc *VerySecretCreate) Save(ctx context.Context) (*VerySecret, error) { - return withHooks[*VerySecret, VerySecretMutation](ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) + return withHooks(ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -112,11 +112,15 @@ func (vsc *VerySecretCreate) createSpec() (*VerySecret, *sqlgraph.CreateSpec) { // VerySecretCreateBulk is the builder for creating many VerySecret entities in bulk. type VerySecretCreateBulk struct { config + err error builders []*VerySecretCreate } // Save creates the VerySecret entities in the database. func (vscb *VerySecretCreateBulk) Save(ctx context.Context) ([]*VerySecret, error) { + if vscb.err != nil { + return nil, vscb.err + } specs := make([]*sqlgraph.CreateSpec, len(vscb.builders)) nodes := make([]*VerySecret, len(vscb.builders)) mutators := make([]Mutator, len(vscb.builders)) diff --git a/entgql/internal/todo/ent/verysecret_delete.go b/entgql/internal/todo/ent/verysecret_delete.go index 11edb920d..24033ae49 100644 --- a/entgql/internal/todo/ent/verysecret_delete.go +++ b/entgql/internal/todo/ent/verysecret_delete.go @@ -41,7 +41,7 @@ func (vsd *VerySecretDelete) Where(ps ...predicate.VerySecret) *VerySecretDelete // Exec executes the deletion query and returns how many vertices were deleted. func (vsd *VerySecretDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) + return withHooks(ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todo/ent/verysecret_query.go b/entgql/internal/todo/ent/verysecret_query.go index 55c9a3985..73620ccce 100644 --- a/entgql/internal/todo/ent/verysecret_query.go +++ b/entgql/internal/todo/ent/verysecret_query.go @@ -35,8 +35,8 @@ type VerySecretQuery struct { order []verysecret.OrderOption inters []Interceptor predicates []predicate.VerySecret - modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*VerySecret) error + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -445,6 +445,9 @@ func (vsq *VerySecretQuery) sqlQuery(ctx context.Context) *sql.Selector { if vsq.ctx.Unique != nil && *vsq.ctx.Unique { selector.Distinct() } + for _, m := range vsq.modifiers { + m(selector) + } for _, p := range vsq.predicates { p(selector) } @@ -462,6 +465,12 @@ func (vsq *VerySecretQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// Modify adds a query modifier for attaching custom logic to queries. +func (vsq *VerySecretQuery) Modify(modifiers ...func(s *sql.Selector)) *VerySecretSelect { + vsq.modifiers = append(vsq.modifiers, modifiers...) + return vsq.Select() +} + // VerySecretGroupBy is the group-by builder for VerySecret entities. type VerySecretGroupBy struct { selector @@ -551,3 +560,9 @@ func (vss *VerySecretSelect) sqlScan(ctx context.Context, root *VerySecretQuery, defer rows.Close() return sql.ScanSlice(rows, v) } + +// Modify adds a query modifier for attaching custom logic to queries. +func (vss *VerySecretSelect) Modify(modifiers ...func(s *sql.Selector)) *VerySecretSelect { + vss.modifiers = append(vss.modifiers, modifiers...) + return vss +} diff --git a/entgql/internal/todo/ent/verysecret_update.go b/entgql/internal/todo/ent/verysecret_update.go index 730904838..fe7c7e140 100644 --- a/entgql/internal/todo/ent/verysecret_update.go +++ b/entgql/internal/todo/ent/verysecret_update.go @@ -31,8 +31,9 @@ import ( // VerySecretUpdate is the builder for updating VerySecret entities. type VerySecretUpdate struct { config - hooks []Hook - mutation *VerySecretMutation + hooks []Hook + mutation *VerySecretMutation + modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the VerySecretUpdate builder. @@ -47,6 +48,14 @@ func (vsu *VerySecretUpdate) SetPassword(s string) *VerySecretUpdate { return vsu } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsu *VerySecretUpdate) SetNillablePassword(s *string) *VerySecretUpdate { + if s != nil { + vsu.SetPassword(*s) + } + return vsu +} + // Mutation returns the VerySecretMutation object of the builder. func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { return vsu.mutation @@ -54,7 +63,7 @@ func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (vsu *VerySecretUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) + return withHooks(ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -79,6 +88,12 @@ func (vsu *VerySecretUpdate) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (vsu *VerySecretUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *VerySecretUpdate { + vsu.modifiers = append(vsu.modifiers, modifiers...) + return vsu +} + func (vsu *VerySecretUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec := sqlgraph.NewUpdateSpec(verysecret.Table, verysecret.Columns, sqlgraph.NewFieldSpec(verysecret.FieldID, field.TypeInt)) if ps := vsu.mutation.predicates; len(ps) > 0 { @@ -91,6 +106,7 @@ func (vsu *VerySecretUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := vsu.mutation.Password(); ok { _spec.SetField(verysecret.FieldPassword, field.TypeString, value) } + _spec.AddModifiers(vsu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, vsu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{verysecret.Label} @@ -106,9 +122,10 @@ func (vsu *VerySecretUpdate) sqlSave(ctx context.Context) (n int, err error) { // VerySecretUpdateOne is the builder for updating a single VerySecret entity. type VerySecretUpdateOne struct { config - fields []string - hooks []Hook - mutation *VerySecretMutation + fields []string + hooks []Hook + mutation *VerySecretMutation + modifiers []func(*sql.UpdateBuilder) } // SetPassword sets the "password" field. @@ -117,6 +134,14 @@ func (vsuo *VerySecretUpdateOne) SetPassword(s string) *VerySecretUpdateOne { return vsuo } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsuo *VerySecretUpdateOne) SetNillablePassword(s *string) *VerySecretUpdateOne { + if s != nil { + vsuo.SetPassword(*s) + } + return vsuo +} + // Mutation returns the VerySecretMutation object of the builder. func (vsuo *VerySecretUpdateOne) Mutation() *VerySecretMutation { return vsuo.mutation @@ -137,7 +162,7 @@ func (vsuo *VerySecretUpdateOne) Select(field string, fields ...string) *VerySec // Save executes the query and returns the updated VerySecret entity. func (vsuo *VerySecretUpdateOne) Save(ctx context.Context) (*VerySecret, error) { - return withHooks[*VerySecret, VerySecretMutation](ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) + return withHooks(ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -162,6 +187,12 @@ func (vsuo *VerySecretUpdateOne) ExecX(ctx context.Context) { } } +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (vsuo *VerySecretUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *VerySecretUpdateOne { + vsuo.modifiers = append(vsuo.modifiers, modifiers...) + return vsuo +} + func (vsuo *VerySecretUpdateOne) sqlSave(ctx context.Context) (_node *VerySecret, err error) { _spec := sqlgraph.NewUpdateSpec(verysecret.Table, verysecret.Columns, sqlgraph.NewFieldSpec(verysecret.FieldID, field.TypeInt)) id, ok := vsuo.mutation.ID() @@ -191,6 +222,7 @@ func (vsuo *VerySecretUpdateOne) sqlSave(ctx context.Context) (_node *VerySecret if value, ok := vsuo.mutation.Password(); ok { _spec.SetField(verysecret.FieldPassword, field.TypeString, value) } + _spec.AddModifiers(vsuo.modifiers...) _node = &VerySecret{config: vsuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entgql/internal/todo/ent/workspace.go b/entgql/internal/todo/ent/workspace.go new file mode 100644 index 000000000..a0a91443a --- /dev/null +++ b/entgql/internal/todo/ent/workspace.go @@ -0,0 +1,117 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/contrib/entgql/internal/todo/ent/workspace" + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Workspace is the model entity for the Workspace schema. +type Workspace struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Workspace) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case workspace.FieldID: + values[i] = new(sql.NullInt64) + case workspace.FieldName: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Workspace fields. +func (w *Workspace) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case workspace.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + w.ID = int(value.Int64) + case workspace.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + w.Name = value.String + } + default: + w.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Workspace. +// This includes values selected through modifiers, order, etc. +func (w *Workspace) Value(name string) (ent.Value, error) { + return w.selectValues.Get(name) +} + +// Update returns a builder for updating this Workspace. +// Note that you need to call Workspace.Unwrap() before calling this method if this Workspace +// was returned from a transaction, and the transaction was committed or rolled back. +func (w *Workspace) Update() *WorkspaceUpdateOne { + return NewWorkspaceClient(w.config).UpdateOne(w) +} + +// Unwrap unwraps the Workspace entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (w *Workspace) Unwrap() *Workspace { + _tx, ok := w.config.driver.(*txDriver) + if !ok { + panic("ent: Workspace is not a transactional entity") + } + w.config.driver = _tx.drv + return w +} + +// String implements the fmt.Stringer. +func (w *Workspace) String() string { + var builder strings.Builder + builder.WriteString("Workspace(") + builder.WriteString(fmt.Sprintf("id=%v, ", w.ID)) + builder.WriteString("name=") + builder.WriteString(w.Name) + builder.WriteByte(')') + return builder.String() +} + +// Workspaces is a parsable slice of Workspace. +type Workspaces []*Workspace diff --git a/entgql/internal/todo/ent/workspace/where.go b/entgql/internal/todo/ent/workspace/where.go new file mode 100644 index 000000000..8de62ab15 --- /dev/null +++ b/entgql/internal/todo/ent/workspace/where.go @@ -0,0 +1,152 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by entc, DO NOT EDIT. + +package workspace + +import ( + "entgo.io/contrib/entgql/internal/todo/ent/predicate" + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Workspace { + return predicate.Workspace(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Workspace { + return predicate.Workspace(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Workspace { + return predicate.Workspace(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Workspace { + return predicate.Workspace(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Workspace { + return predicate.Workspace(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Workspace { + return predicate.Workspace(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Workspace { + return predicate.Workspace(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Workspace { + return predicate.Workspace(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Workspace { + return predicate.Workspace(sql.FieldLTE(FieldID, id)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldEQ(FieldName, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Workspace { + return predicate.Workspace(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Workspace { + return predicate.Workspace(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Workspace { + return predicate.Workspace(sql.FieldContainsFold(FieldName, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Workspace) predicate.Workspace { + return predicate.Workspace(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Workspace) predicate.Workspace { + return predicate.Workspace(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Workspace) predicate.Workspace { + return predicate.Workspace(sql.NotPredicates(p)) +} diff --git a/entgql/internal/todo/ent/workspace/workspace.go b/entgql/internal/todo/ent/workspace/workspace.go new file mode 100644 index 000000000..6ff1632c3 --- /dev/null +++ b/entgql/internal/todo/ent/workspace/workspace.go @@ -0,0 +1,61 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by entc, DO NOT EDIT. + +package workspace + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the workspace type in the database. + Label = "workspace" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // Table holds the table name of the workspace in the database. + Table = "workspaces" +) + +// Columns holds all SQL columns for workspace fields. +var Columns = []string{ + FieldID, + FieldName, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the Workspace queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} diff --git a/entgql/internal/todo/ent/workspace_create.go b/entgql/internal/todo/ent/workspace_create.go new file mode 100644 index 000000000..bb49f4103 --- /dev/null +++ b/entgql/internal/todo/ent/workspace_create.go @@ -0,0 +1,197 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/contrib/entgql/internal/todo/ent/workspace" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WorkspaceCreate is the builder for creating a Workspace entity. +type WorkspaceCreate struct { + config + mutation *WorkspaceMutation + hooks []Hook +} + +// SetName sets the "name" field. +func (wc *WorkspaceCreate) SetName(s string) *WorkspaceCreate { + wc.mutation.SetName(s) + return wc +} + +// Mutation returns the WorkspaceMutation object of the builder. +func (wc *WorkspaceCreate) Mutation() *WorkspaceMutation { + return wc.mutation +} + +// Save creates the Workspace in the database. +func (wc *WorkspaceCreate) Save(ctx context.Context) (*Workspace, error) { + return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (wc *WorkspaceCreate) SaveX(ctx context.Context) *Workspace { + v, err := wc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wc *WorkspaceCreate) Exec(ctx context.Context) error { + _, err := wc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wc *WorkspaceCreate) ExecX(ctx context.Context) { + if err := wc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (wc *WorkspaceCreate) check() error { + if _, ok := wc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Workspace.name"`)} + } + return nil +} + +func (wc *WorkspaceCreate) sqlSave(ctx context.Context) (*Workspace, error) { + if err := wc.check(); err != nil { + return nil, err + } + _node, _spec := wc.createSpec() + if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + wc.mutation.id = &_node.ID + wc.mutation.done = true + return _node, nil +} + +func (wc *WorkspaceCreate) createSpec() (*Workspace, *sqlgraph.CreateSpec) { + var ( + _node = &Workspace{config: wc.config} + _spec = sqlgraph.NewCreateSpec(workspace.Table, sqlgraph.NewFieldSpec(workspace.FieldID, field.TypeInt)) + ) + if value, ok := wc.mutation.Name(); ok { + _spec.SetField(workspace.FieldName, field.TypeString, value) + _node.Name = value + } + return _node, _spec +} + +// WorkspaceCreateBulk is the builder for creating many Workspace entities in bulk. +type WorkspaceCreateBulk struct { + config + err error + builders []*WorkspaceCreate +} + +// Save creates the Workspace entities in the database. +func (wcb *WorkspaceCreateBulk) Save(ctx context.Context) ([]*Workspace, error) { + if wcb.err != nil { + return nil, wcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(wcb.builders)) + nodes := make([]*Workspace, len(wcb.builders)) + mutators := make([]Mutator, len(wcb.builders)) + for i := range wcb.builders { + func(i int, root context.Context) { + builder := wcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WorkspaceMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (wcb *WorkspaceCreateBulk) SaveX(ctx context.Context) []*Workspace { + v, err := wcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wcb *WorkspaceCreateBulk) Exec(ctx context.Context) error { + _, err := wcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wcb *WorkspaceCreateBulk) ExecX(ctx context.Context) { + if err := wcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/entgql/internal/todo/ent/workspace_delete.go b/entgql/internal/todo/ent/workspace_delete.go new file mode 100644 index 000000000..8abf87c6e --- /dev/null +++ b/entgql/internal/todo/ent/workspace_delete.go @@ -0,0 +1,102 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/contrib/entgql/internal/todo/ent/predicate" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WorkspaceDelete is the builder for deleting a Workspace entity. +type WorkspaceDelete struct { + config + hooks []Hook + mutation *WorkspaceMutation +} + +// Where appends a list predicates to the WorkspaceDelete builder. +func (wd *WorkspaceDelete) Where(ps ...predicate.Workspace) *WorkspaceDelete { + wd.mutation.Where(ps...) + return wd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (wd *WorkspaceDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, wd.sqlExec, wd.mutation, wd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (wd *WorkspaceDelete) ExecX(ctx context.Context) int { + n, err := wd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (wd *WorkspaceDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(workspace.Table, sqlgraph.NewFieldSpec(workspace.FieldID, field.TypeInt)) + if ps := wd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + wd.mutation.done = true + return affected, err +} + +// WorkspaceDeleteOne is the builder for deleting a single Workspace entity. +type WorkspaceDeleteOne struct { + wd *WorkspaceDelete +} + +// Where appends a list predicates to the WorkspaceDelete builder. +func (wdo *WorkspaceDeleteOne) Where(ps ...predicate.Workspace) *WorkspaceDeleteOne { + wdo.wd.mutation.Where(ps...) + return wdo +} + +// Exec executes the deletion query. +func (wdo *WorkspaceDeleteOne) Exec(ctx context.Context) error { + n, err := wdo.wd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{workspace.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (wdo *WorkspaceDeleteOne) ExecX(ctx context.Context) { + if err := wdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/entgql/internal/todo/ent/workspace_query.go b/entgql/internal/todo/ent/workspace_query.go new file mode 100644 index 000000000..93994370c --- /dev/null +++ b/entgql/internal/todo/ent/workspace_query.go @@ -0,0 +1,568 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/contrib/entgql/internal/todo/ent/predicate" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WorkspaceQuery is the builder for querying Workspace entities. +type WorkspaceQuery struct { + config + ctx *QueryContext + order []workspace.OrderOption + inters []Interceptor + predicates []predicate.Workspace + loadTotal []func(context.Context, []*Workspace) error + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the WorkspaceQuery builder. +func (wq *WorkspaceQuery) Where(ps ...predicate.Workspace) *WorkspaceQuery { + wq.predicates = append(wq.predicates, ps...) + return wq +} + +// Limit the number of records to be returned by this query. +func (wq *WorkspaceQuery) Limit(limit int) *WorkspaceQuery { + wq.ctx.Limit = &limit + return wq +} + +// Offset to start from. +func (wq *WorkspaceQuery) Offset(offset int) *WorkspaceQuery { + wq.ctx.Offset = &offset + return wq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (wq *WorkspaceQuery) Unique(unique bool) *WorkspaceQuery { + wq.ctx.Unique = &unique + return wq +} + +// Order specifies how the records should be ordered. +func (wq *WorkspaceQuery) Order(o ...workspace.OrderOption) *WorkspaceQuery { + wq.order = append(wq.order, o...) + return wq +} + +// First returns the first Workspace entity from the query. +// Returns a *NotFoundError when no Workspace was found. +func (wq *WorkspaceQuery) First(ctx context.Context) (*Workspace, error) { + nodes, err := wq.Limit(1).All(setContextOp(ctx, wq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{workspace.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (wq *WorkspaceQuery) FirstX(ctx context.Context) *Workspace { + node, err := wq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Workspace ID from the query. +// Returns a *NotFoundError when no Workspace ID was found. +func (wq *WorkspaceQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wq.Limit(1).IDs(setContextOp(ctx, wq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{workspace.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (wq *WorkspaceQuery) FirstIDX(ctx context.Context) int { + id, err := wq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Workspace entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Workspace entity is found. +// Returns a *NotFoundError when no Workspace entities are found. +func (wq *WorkspaceQuery) Only(ctx context.Context) (*Workspace, error) { + nodes, err := wq.Limit(2).All(setContextOp(ctx, wq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{workspace.Label} + default: + return nil, &NotSingularError{workspace.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (wq *WorkspaceQuery) OnlyX(ctx context.Context) *Workspace { + node, err := wq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Workspace ID in the query. +// Returns a *NotSingularError when more than one Workspace ID is found. +// Returns a *NotFoundError when no entities are found. +func (wq *WorkspaceQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wq.Limit(2).IDs(setContextOp(ctx, wq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{workspace.Label} + default: + err = &NotSingularError{workspace.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (wq *WorkspaceQuery) OnlyIDX(ctx context.Context) int { + id, err := wq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Workspaces. +func (wq *WorkspaceQuery) All(ctx context.Context) ([]*Workspace, error) { + ctx = setContextOp(ctx, wq.ctx, "All") + if err := wq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Workspace, *WorkspaceQuery]() + return withInterceptors[[]*Workspace](ctx, wq, qr, wq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (wq *WorkspaceQuery) AllX(ctx context.Context) []*Workspace { + nodes, err := wq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Workspace IDs. +func (wq *WorkspaceQuery) IDs(ctx context.Context) (ids []int, err error) { + if wq.ctx.Unique == nil && wq.path != nil { + wq.Unique(true) + } + ctx = setContextOp(ctx, wq.ctx, "IDs") + if err = wq.Select(workspace.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (wq *WorkspaceQuery) IDsX(ctx context.Context) []int { + ids, err := wq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (wq *WorkspaceQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, wq.ctx, "Count") + if err := wq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, wq, querierCount[*WorkspaceQuery](), wq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (wq *WorkspaceQuery) CountX(ctx context.Context) int { + count, err := wq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (wq *WorkspaceQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, wq.ctx, "Exist") + switch _, err := wq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (wq *WorkspaceQuery) ExistX(ctx context.Context) bool { + exist, err := wq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the WorkspaceQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (wq *WorkspaceQuery) Clone() *WorkspaceQuery { + if wq == nil { + return nil + } + return &WorkspaceQuery{ + config: wq.config, + ctx: wq.ctx.Clone(), + order: append([]workspace.OrderOption{}, wq.order...), + inters: append([]Interceptor{}, wq.inters...), + predicates: append([]predicate.Workspace{}, wq.predicates...), + // clone intermediate query. + sql: wq.sql.Clone(), + path: wq.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Workspace.Query(). +// GroupBy(workspace.FieldName). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (wq *WorkspaceQuery) GroupBy(field string, fields ...string) *WorkspaceGroupBy { + wq.ctx.Fields = append([]string{field}, fields...) + grbuild := &WorkspaceGroupBy{build: wq} + grbuild.flds = &wq.ctx.Fields + grbuild.label = workspace.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// } +// +// client.Workspace.Query(). +// Select(workspace.FieldName). +// Scan(ctx, &v) +func (wq *WorkspaceQuery) Select(fields ...string) *WorkspaceSelect { + wq.ctx.Fields = append(wq.ctx.Fields, fields...) + sbuild := &WorkspaceSelect{WorkspaceQuery: wq} + sbuild.label = workspace.Label + sbuild.flds, sbuild.scan = &wq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a WorkspaceSelect configured with the given aggregations. +func (wq *WorkspaceQuery) Aggregate(fns ...AggregateFunc) *WorkspaceSelect { + return wq.Select().Aggregate(fns...) +} + +func (wq *WorkspaceQuery) prepareQuery(ctx context.Context) error { + for _, inter := range wq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, wq); err != nil { + return err + } + } + } + for _, f := range wq.ctx.Fields { + if !workspace.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if wq.path != nil { + prev, err := wq.path(ctx) + if err != nil { + return err + } + wq.sql = prev + } + return nil +} + +func (wq *WorkspaceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Workspace, error) { + var ( + nodes = []*Workspace{} + _spec = wq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Workspace).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Workspace{config: wq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(wq.modifiers) > 0 { + _spec.Modifiers = wq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + for i := range wq.loadTotal { + if err := wq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (wq *WorkspaceQuery) sqlCount(ctx context.Context) (int, error) { + _spec := wq.querySpec() + if len(wq.modifiers) > 0 { + _spec.Modifiers = wq.modifiers + } + _spec.Node.Columns = wq.ctx.Fields + if len(wq.ctx.Fields) > 0 { + _spec.Unique = wq.ctx.Unique != nil && *wq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, wq.driver, _spec) +} + +func (wq *WorkspaceQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(workspace.Table, workspace.Columns, sqlgraph.NewFieldSpec(workspace.FieldID, field.TypeInt)) + _spec.From = wq.sql + if unique := wq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if wq.path != nil { + _spec.Unique = true + } + if fields := wq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, workspace.FieldID) + for i := range fields { + if fields[i] != workspace.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := wq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := wq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := wq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := wq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (wq *WorkspaceQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(wq.driver.Dialect()) + t1 := builder.Table(workspace.Table) + columns := wq.ctx.Fields + if len(columns) == 0 { + columns = workspace.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if wq.sql != nil { + selector = wq.sql + selector.Select(selector.Columns(columns...)...) + } + if wq.ctx.Unique != nil && *wq.ctx.Unique { + selector.Distinct() + } + for _, m := range wq.modifiers { + m(selector) + } + for _, p := range wq.predicates { + p(selector) + } + for _, p := range wq.order { + p(selector) + } + if offset := wq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := wq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (wq *WorkspaceQuery) Modify(modifiers ...func(s *sql.Selector)) *WorkspaceSelect { + wq.modifiers = append(wq.modifiers, modifiers...) + return wq.Select() +} + +// WorkspaceGroupBy is the group-by builder for Workspace entities. +type WorkspaceGroupBy struct { + selector + build *WorkspaceQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (wgb *WorkspaceGroupBy) Aggregate(fns ...AggregateFunc) *WorkspaceGroupBy { + wgb.fns = append(wgb.fns, fns...) + return wgb +} + +// Scan applies the selector query and scans the result into the given value. +func (wgb *WorkspaceGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, wgb.build.ctx, "GroupBy") + if err := wgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*WorkspaceQuery, *WorkspaceGroupBy](ctx, wgb.build, wgb, wgb.build.inters, v) +} + +func (wgb *WorkspaceGroupBy) sqlScan(ctx context.Context, root *WorkspaceQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(wgb.fns)) + for _, fn := range wgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*wgb.flds)+len(wgb.fns)) + for _, f := range *wgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*wgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := wgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// WorkspaceSelect is the builder for selecting fields of Workspace entities. +type WorkspaceSelect struct { + *WorkspaceQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ws *WorkspaceSelect) Aggregate(fns ...AggregateFunc) *WorkspaceSelect { + ws.fns = append(ws.fns, fns...) + return ws +} + +// Scan applies the selector query and scans the result into the given value. +func (ws *WorkspaceSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ws.ctx, "Select") + if err := ws.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*WorkspaceQuery, *WorkspaceSelect](ctx, ws.WorkspaceQuery, ws, ws.inters, v) +} + +func (ws *WorkspaceSelect) sqlScan(ctx context.Context, root *WorkspaceQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ws.fns)) + for _, fn := range ws.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ws.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ws.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (ws *WorkspaceSelect) Modify(modifiers ...func(s *sql.Selector)) *WorkspaceSelect { + ws.modifiers = append(ws.modifiers, modifiers...) + return ws +} diff --git a/entgql/internal/todo/ent/workspace_update.go b/entgql/internal/todo/ent/workspace_update.go new file mode 100644 index 000000000..92325ed73 --- /dev/null +++ b/entgql/internal/todo/ent/workspace_update.go @@ -0,0 +1,239 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by entc, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/contrib/entgql/internal/todo/ent/predicate" + "entgo.io/contrib/entgql/internal/todo/ent/workspace" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WorkspaceUpdate is the builder for updating Workspace entities. +type WorkspaceUpdate struct { + config + hooks []Hook + mutation *WorkspaceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the WorkspaceUpdate builder. +func (wu *WorkspaceUpdate) Where(ps ...predicate.Workspace) *WorkspaceUpdate { + wu.mutation.Where(ps...) + return wu +} + +// SetName sets the "name" field. +func (wu *WorkspaceUpdate) SetName(s string) *WorkspaceUpdate { + wu.mutation.SetName(s) + return wu +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (wu *WorkspaceUpdate) SetNillableName(s *string) *WorkspaceUpdate { + if s != nil { + wu.SetName(*s) + } + return wu +} + +// Mutation returns the WorkspaceMutation object of the builder. +func (wu *WorkspaceUpdate) Mutation() *WorkspaceMutation { + return wu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (wu *WorkspaceUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, wu.sqlSave, wu.mutation, wu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (wu *WorkspaceUpdate) SaveX(ctx context.Context) int { + affected, err := wu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (wu *WorkspaceUpdate) Exec(ctx context.Context) error { + _, err := wu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wu *WorkspaceUpdate) ExecX(ctx context.Context) { + if err := wu.Exec(ctx); err != nil { + panic(err) + } +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (wu *WorkspaceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WorkspaceUpdate { + wu.modifiers = append(wu.modifiers, modifiers...) + return wu +} + +func (wu *WorkspaceUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(workspace.Table, workspace.Columns, sqlgraph.NewFieldSpec(workspace.FieldID, field.TypeInt)) + if ps := wu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := wu.mutation.Name(); ok { + _spec.SetField(workspace.FieldName, field.TypeString, value) + } + _spec.AddModifiers(wu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{workspace.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + wu.mutation.done = true + return n, nil +} + +// WorkspaceUpdateOne is the builder for updating a single Workspace entity. +type WorkspaceUpdateOne struct { + config + fields []string + hooks []Hook + mutation *WorkspaceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetName sets the "name" field. +func (wuo *WorkspaceUpdateOne) SetName(s string) *WorkspaceUpdateOne { + wuo.mutation.SetName(s) + return wuo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (wuo *WorkspaceUpdateOne) SetNillableName(s *string) *WorkspaceUpdateOne { + if s != nil { + wuo.SetName(*s) + } + return wuo +} + +// Mutation returns the WorkspaceMutation object of the builder. +func (wuo *WorkspaceUpdateOne) Mutation() *WorkspaceMutation { + return wuo.mutation +} + +// Where appends a list predicates to the WorkspaceUpdate builder. +func (wuo *WorkspaceUpdateOne) Where(ps ...predicate.Workspace) *WorkspaceUpdateOne { + wuo.mutation.Where(ps...) + return wuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (wuo *WorkspaceUpdateOne) Select(field string, fields ...string) *WorkspaceUpdateOne { + wuo.fields = append([]string{field}, fields...) + return wuo +} + +// Save executes the query and returns the updated Workspace entity. +func (wuo *WorkspaceUpdateOne) Save(ctx context.Context) (*Workspace, error) { + return withHooks(ctx, wuo.sqlSave, wuo.mutation, wuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (wuo *WorkspaceUpdateOne) SaveX(ctx context.Context) *Workspace { + node, err := wuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (wuo *WorkspaceUpdateOne) Exec(ctx context.Context) error { + _, err := wuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wuo *WorkspaceUpdateOne) ExecX(ctx context.Context) { + if err := wuo.Exec(ctx); err != nil { + panic(err) + } +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (wuo *WorkspaceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WorkspaceUpdateOne { + wuo.modifiers = append(wuo.modifiers, modifiers...) + return wuo +} + +func (wuo *WorkspaceUpdateOne) sqlSave(ctx context.Context) (_node *Workspace, err error) { + _spec := sqlgraph.NewUpdateSpec(workspace.Table, workspace.Columns, sqlgraph.NewFieldSpec(workspace.FieldID, field.TypeInt)) + id, ok := wuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Workspace.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := wuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, workspace.FieldID) + for _, f := range fields { + if !workspace.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != workspace.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := wuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := wuo.mutation.Name(); ok { + _spec.SetField(workspace.FieldName, field.TypeString, value) + } + _spec.AddModifiers(wuo.modifiers...) + _node = &Workspace{config: wuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, wuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{workspace.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + wuo.mutation.done = true + return _node, nil +} diff --git a/entgql/internal/todo/generated.go b/entgql/internal/todo/generated.go index 775b29430..9d57eef50 100644 --- a/entgql/internal/todo/generated.go +++ b/entgql/internal/todo/generated.go @@ -5,6 +5,7 @@ package todo import ( "bytes" "context" + "embed" "errors" "fmt" "strconv" @@ -32,6 +33,7 @@ import ( // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ + schema: cfg.Schema, resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, @@ -39,6 +41,7 @@ func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { } type Config struct { + Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot @@ -74,8 +77,9 @@ type ComplexityRoot struct { Strings func(childComplexity int) int SubCategories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int Text func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int TodosCount func(childComplexity int) int + Types func(childComplexity int) int } CategoryConfig struct { @@ -87,6 +91,10 @@ type ComplexityRoot struct { TotalCount func(childComplexity int) int } + CategoryTypes struct { + Public func(childComplexity int) int + } + Custom struct { Info func(childComplexity int) int } @@ -137,6 +145,11 @@ type ComplexityRoot struct { TotalCount func(childComplexity int) int } + Organization struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int @@ -146,25 +159,26 @@ type ComplexityRoot struct { Project struct { ID func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int } Query struct { - BillProducts func(childComplexity int) int - Categories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int - Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int - Node func(childComplexity int, id int) int - Nodes func(childComplexity int, ids []int) int - OneToMany func(childComplexity int, limit *int, offset *int, orderBy *ent.OneToManyOrder, where *ent.OneToManyWhereInput) int - Ping func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int - Users func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int + BillProducts func(childComplexity int) int + Categories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int + Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int + Node func(childComplexity int, id int) int + Nodes func(childComplexity int, ids []int) int + OneToMany func(childComplexity int, limit *int, offset *int, orderBy *ent.OneToManyOrder, where *ent.OneToManyWhereInput) int + Ping func(childComplexity int) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int + TodosWithJoins func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int + Users func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int } Todo struct { Category func(childComplexity int) int CategoryID func(childComplexity int) int - Children func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Children func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int CreatedAt func(childComplexity int) int Custom func(childComplexity int) int Customp func(childComplexity int) int @@ -183,13 +197,14 @@ type ComplexityRoot struct { } User struct { - Friends func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int - Friendships func(childComplexity int, limit *int, offset *int, where *ent.FriendshipWhereInput) int - Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int - ID func(childComplexity int) int - Metadata func(childComplexity int) int - Name func(childComplexity int) int - Username func(childComplexity int) int + Friends func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int + Friendships func(childComplexity int, limit *int, offset *int, where *ent.FriendshipWhereInput) int + Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int + ID func(childComplexity int) int + Metadata func(childComplexity int) int + Name func(childComplexity int) int + RequiredMetadata func(childComplexity int) int + Username func(childComplexity int) int } UserList struct { @@ -215,9 +230,10 @@ type QueryResolver interface { Categories(ctx context.Context, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryList, error) Groups(ctx context.Context, limit *int, offset *int, where *ent.GroupWhereInput) (*ent.GroupList, error) OneToMany(ctx context.Context, limit *int, offset *int, orderBy *ent.OneToManyOrder, where *ent.OneToManyWhereInput) (*ent.OneToManyList, error) - Todos(ctx context.Context, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) + Todos(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) Users(ctx context.Context, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) Ping(ctx context.Context) (string, error) + TodosWithJoins(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) } type TodoResolver interface { ExtendedField(ctx context.Context, obj *ent.Todo) (*string, error) @@ -231,17 +247,21 @@ type TodoWhereInputResolver interface { } type executableSchema struct { + schema *ast.Schema resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} + ec := executionContext{nil, e, 0, 0, nil} _ = ec switch typeName + "." + field { @@ -344,7 +364,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Category.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Category.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Category.todosCount": if e.complexity.Category.TodosCount == nil { @@ -353,6 +373,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Category.TodosCount(childComplexity), true + case "Category.types": + if e.complexity.Category.Types == nil { + break + } + + return e.complexity.Category.Types(childComplexity), true + case "CategoryConfig.maxMembers": if e.complexity.CategoryConfig.MaxMembers == nil { break @@ -374,6 +401,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CategoryList.TotalCount(childComplexity), true + case "CategoryTypes.public": + if e.complexity.CategoryTypes.Public == nil { + break + } + + return e.complexity.CategoryTypes.Public(childComplexity), true + case "Custom.info": if e.complexity.Custom.Info == nil { break @@ -581,6 +615,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OneToManyList.TotalCount(childComplexity), true + case "Organization.id": + if e.complexity.Organization.ID == nil { + break + } + + return e.complexity.Organization.ID(childComplexity), true + + case "Organization.name": + if e.complexity.Organization.Name == nil { + break + } + + return e.complexity.Organization.Name(childComplexity), true + case "PageInfo.endCursor": if e.complexity.PageInfo.EndCursor == nil { break @@ -626,7 +674,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Project.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Project.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Query.billProducts": if e.complexity.Query.BillProducts == nil { @@ -712,7 +760,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Query.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + + case "Query.todosWithJoins": + if e.complexity.Query.TodosWithJoins == nil { + break + } + + args, err := ec.field_Query_todosWithJoins_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.TodosWithJoins(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Query.users": if e.complexity.Query.Users == nil { @@ -750,7 +810,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Todo.Children(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Todo.Children(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Todo.createdAt": if e.complexity.Todo.CreatedAt == nil { @@ -893,6 +953,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Name(childComplexity), true + case "User.requiredMetadata": + if e.complexity.User.RequiredMetadata == nil { + break + } + + return e.complexity.User.RequiredMetadata(childComplexity), true + case "User.username": if e.complexity.User.Username == nil { break @@ -920,11 +987,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputBillProductWhereInput, ec.unmarshalInputCategoryConfigInput, ec.unmarshalInputCategoryOrder, + ec.unmarshalInputCategoryTypesInput, ec.unmarshalInputCategoryWhereInput, ec.unmarshalInputCreateCategoryInput, ec.unmarshalInputCreateTodoInput, @@ -933,6 +1001,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputGroupWhereInput, ec.unmarshalInputOneToManyOrder, ec.unmarshalInputOneToManyWhereInput, + ec.unmarshalInputOrganizationWhereInput, ec.unmarshalInputProjectWhereInput, ec.unmarshalInputTodoOrder, ec.unmarshalInputTodoWhereInput, @@ -948,18 +1017,33 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { - if !first { - return nil + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext } + + return &response } case ast.Mutation: return func(ctx context.Context) *graphql.Response { @@ -985,913 +1069,58 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { type executionContext struct { *graphql.OperationContext *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "todo.graphql" "ent.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) } var sources = []*ast.Source{ - {Name: "todo.graphql", Input: `directive @hasPermissions(permissions: [String!]!) on OBJECT | FIELD_DEFINITION - -type CategoryConfig { - maxMembers: Int -} - -input CategoryConfigInput { - maxMembers: Int -} - -scalar Duration -scalar UUID - -extend input TodoWhereInput { - createdToday: Boolean -} - -extend type Category { - """ - Expose the TODOS_COUNT order field in case it was added in orderBy. - """ - todosCount: Int -} - -extend type Todo { - extendedField: String -} - -extend type Query { - """ - This field is an example of extending the built-in Query type from Ent. - """ - ping: String! -} - -type Mutation { - createCategory(input: CreateCategoryInput!): Category! - createTodo(input: CreateTodoInput!): Todo! - updateTodo(id: ID!, input: UpdateTodoInput!): Todo! - clearTodos: Int! - updateFriendship(id: ID!, input: UpdateFriendshipInput!): Friendship! -} - -type Custom { - info: String! -} - -extend input CreateCategoryInput { - createTodos: [CreateTodoInput!] -} -`, BuiltIn: false}, - {Name: "ent.graphql", Input: `directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -"""Represents BillProduct object""" -type BillProduct implements Node { - id: ID! - name: String! - sku: String! - quantity: Uint64! -} -"""BillProductWhereInput is used for filtering BillProduct objects.""" -input BillProductWhereInput { - not: BillProductWhereInput - and: [BillProductWhereInput!] - or: [BillProductWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """name field predicates""" - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """sku field predicates""" - sku: String - skuNEQ: String - skuIn: [String!] - skuNotIn: [String!] - skuGT: String - skuGTE: String - skuLT: String - skuLTE: String - skuContains: String - skuHasPrefix: String - skuHasSuffix: String - skuEqualFold: String - skuContainsFold: String - """quantity field predicates""" - quantity: Uint64 - quantityNEQ: Uint64 - quantityIn: [Uint64!] - quantityNotIn: [Uint64!] - quantityGT: Uint64 - quantityGTE: Uint64 - quantityLT: Uint64 - quantityLTE: Uint64 -} -"""Represents Category object""" -type Category implements Node { - id: ID! - text: String! - status: CategoryStatus! - config: CategoryConfig - duration: Duration - count: Uint64 - strings: [String!] - todos( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder - - """Filtering options for Todos returned from the connection.""" - where: TodoWhereInput - ): TodoList - subCategories( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Categories returned from the connection.""" - orderBy: [CategoryOrder!] - - """Filtering options for Categories returned from the connection.""" - where: CategoryWhereInput - ): CategoryList -} -"""A connection to a list of items.""" -type CategoryList { - """Identifies the total count of data items.""" - totalCount: Int! - """The list of data items.""" - items: [Category]! -} -"""Ordering options for Category connections""" -input CategoryOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Categories.""" - field: CategoryOrderField! -} -"""Properties by which Category connections can be ordered.""" -enum CategoryOrderField { - ID - TEXT - DURATION - COUNT - TODOS_COUNT -} -"""CategoryStatus is enum for the field status""" -enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { - ENABLED - DISABLED -} -"""CategoryWhereInput is used for filtering Category objects.""" -input CategoryWhereInput { - not: CategoryWhereInput - and: [CategoryWhereInput!] - or: [CategoryWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """text field predicates""" - text: String - textNEQ: String - textIn: [String!] - textNotIn: [String!] - textGT: String - textGTE: String - textLT: String - textLTE: String - textContains: String - textHasPrefix: String - textHasSuffix: String - textEqualFold: String - textContainsFold: String - """status field predicates""" - status: CategoryStatus - statusNEQ: CategoryStatus - statusIn: [CategoryStatus!] - statusNotIn: [CategoryStatus!] - """config field predicates""" - config: CategoryConfigInput - configNEQ: CategoryConfigInput - configIn: [CategoryConfigInput!] - configNotIn: [CategoryConfigInput!] - configGT: CategoryConfigInput - configGTE: CategoryConfigInput - configLT: CategoryConfigInput - configLTE: CategoryConfigInput - configIsNil: Boolean - configNotNil: Boolean - """duration field predicates""" - duration: Duration - durationNEQ: Duration - durationIn: [Duration!] - durationNotIn: [Duration!] - durationGT: Duration - durationGTE: Duration - durationLT: Duration - durationLTE: Duration - durationIsNil: Boolean - durationNotNil: Boolean - """count field predicates""" - count: Uint64 - countNEQ: Uint64 - countIn: [Uint64!] - countNotIn: [Uint64!] - countGT: Uint64 - countGTE: Uint64 - countLT: Uint64 - countLTE: Uint64 - countIsNil: Boolean - countNotNil: Boolean - """todos edge predicates""" - hasTodos: Boolean - hasTodosWith: [TodoWhereInput!] - """sub_categories edge predicates""" - hasSubCategories: Boolean - hasSubCategoriesWith: [CategoryWhereInput!] -} -"""CreateCategoryInput is used for create Category object.""" -input CreateCategoryInput { - text: String! - status: CategoryStatus! - config: CategoryConfigInput - duration: Duration - count: Uint64 - strings: [String!] - todoIDs: [ID!] - subCategoryIDs: [ID!] -} -"""CreateTodoInput is used for create Todo object.""" -input CreateTodoInput { - status: TodoStatus! - priority: Int - text: String! - init: Map - parentID: ID - childIDs: [ID!] - categoryID: ID - secretID: ID -} -"""CreateUserInput is used for create User object.""" -input CreateUserInput { - name: String - username: UUID - password: String - metadata: Map - groupIDs: [ID!] - friendIDs: [ID!] -} -""" -Define a Relay Cursor type: -https://relay.dev/graphql/connections.htm#sec-Cursor -""" -scalar Cursor -type Friendship implements Node { - id: ID! - createdAt: Time! - userID: ID! - friendID: ID! - user: User! - friend: User! -} -"""A connection to a list of items.""" -type FriendshipList { - """Identifies the total count of data items.""" - totalCount: Int! - """The list of data items.""" - items: [Friendship]! -} -"""FriendshipWhereInput is used for filtering Friendship objects.""" -input FriendshipWhereInput { - not: FriendshipWhereInput - and: [FriendshipWhereInput!] - or: [FriendshipWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """created_at field predicates""" - createdAt: Time - createdAtNEQ: Time - createdAtIn: [Time!] - createdAtNotIn: [Time!] - createdAtGT: Time - createdAtGTE: Time - createdAtLT: Time - createdAtLTE: Time -} -type Group implements Node @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { - id: ID! - name: String! - users( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Users returned from the connection.""" - orderBy: UserOrder - - """Filtering options for Users returned from the connection.""" - where: UserWhereInput - ): UserList -} -"""A connection to a list of items.""" -type GroupList { - """Identifies the total count of data items.""" - totalCount: Int! - """The list of data items.""" - items: [Group]! -} -"""GroupWhereInput is used for filtering Group objects.""" -input GroupWhereInput { - not: GroupWhereInput - and: [GroupWhereInput!] - or: [GroupWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """name field predicates""" - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """users edge predicates""" - hasUsers: Boolean - hasUsersWith: [UserWhereInput!] -} -"""The builtin Map type""" -scalar Map -""" -An object with an ID. -Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) -""" -interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder") { - """The id of the object.""" - id: ID! -} -type OneToMany implements Node { - id: ID! - name: String! - field2: String - parent: OneToMany - children: [OneToMany!] -} -"""A connection to a list of items.""" -type OneToManyList { - """Identifies the total count of data items.""" - totalCount: Int! - """The list of data items.""" - items: [OneToMany]! -} -"""Ordering options for OneToMany connections""" -input OneToManyOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" - field: OneToManyOrderField! -} -"""Properties by which OneToMany connections can be ordered.""" -enum OneToManyOrderField { - NAME -} -"""OneToManyWhereInput is used for filtering OneToMany objects.""" -input OneToManyWhereInput { - not: OneToManyWhereInput - and: [OneToManyWhereInput!] - or: [OneToManyWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """name field predicates""" - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """field2 field predicates""" - field2: String - field2NEQ: String - field2In: [String!] - field2NotIn: [String!] - field2GT: String - field2GTE: String - field2LT: String - field2LTE: String - field2Contains: String - field2HasPrefix: String - field2HasSuffix: String - field2IsNil: Boolean - field2NotNil: Boolean - field2EqualFold: String - field2ContainsFold: String - """parent edge predicates""" - hasParent: Boolean - hasParentWith: [OneToManyWhereInput!] - """children edge predicates""" - hasChildren: Boolean - hasChildrenWith: [OneToManyWhereInput!] -} -"""Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument.""" -enum OrderDirection { - """Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument.""" - ASC - """Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument.""" - DESC -} -""" -Information about pagination in a connection. -https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo -""" -type PageInfo { - """When paginating forwards, are there more items?""" - hasNextPage: Boolean! - """When paginating backwards, are there more items?""" - hasPreviousPage: Boolean! - """When paginating backwards, the cursor to continue.""" - startCursor: Cursor - """When paginating forwards, the cursor to continue.""" - endCursor: Cursor -} -type Project implements Node { - id: ID! - todos( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder - - """Filtering options for Todos returned from the connection.""" - where: TodoWhereInput - ): TodoList -} -"""ProjectWhereInput is used for filtering Project objects.""" -input ProjectWhereInput { - not: ProjectWhereInput - and: [ProjectWhereInput!] - or: [ProjectWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """todos edge predicates""" - hasTodos: Boolean - hasTodosWith: [TodoWhereInput!] -} -type Query { - """Fetches an object given its ID.""" - node( - """ID of the object.""" - id: ID! - ): Node - """Lookup nodes by a list of IDs.""" - nodes( - """The list of node IDs.""" - ids: [ID!]! - ): [Node]! - billProducts: [BillProduct!]! - categories( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Categories returned from the connection.""" - orderBy: [CategoryOrder!] - - """Filtering options for Categories returned from the connection.""" - where: CategoryWhereInput - ): CategoryList - groups( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Filtering options for Groups returned from the connection.""" - where: GroupWhereInput - ): GroupList - oneToMany( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for OneToManies returned from the connection.""" - orderBy: OneToManyOrder - - """Filtering options for OneToManies returned from the connection.""" - where: OneToManyWhereInput - ): OneToManyList - """This is the todo item""" - todos( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder - - """Filtering options for Todos returned from the connection.""" - where: TodoWhereInput - ): TodoList - users( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Users returned from the connection.""" - orderBy: UserOrder - - """Filtering options for Users returned from the connection.""" - where: UserWhereInput - ): UserList -} -"""The builtin Time type""" -scalar Time -type Todo implements Node { - id: ID! - createdAt: Time! - status: TodoStatus! - priorityOrder: Int! @goField(name: "Priority", forceResolver: false) - text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] - """Todo parent""" - parent: Todo - """Todo children""" - children( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder - - """Filtering options for Todos returned from the connection.""" - where: TodoWhereInput - ): TodoList - category: Category -} -"""A connection to a list of items.""" -type TodoList { - """Identifies the total count of data items.""" - totalCount: Int! - """The list of data items.""" - items: [Todo]! -} -"""Ordering options for Todo connections""" -input TodoOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Todos.""" - field: TodoOrderField! -} -"""Properties by which Todo connections can be ordered.""" -enum TodoOrderField { - CREATED_AT - STATUS - PRIORITY_ORDER - TEXT - PARENT_STATUS - CHILDREN_COUNT - CATEGORY_TEXT -} -"""TodoStatus is enum for the field status""" -enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { - IN_PROGRESS - COMPLETED - PENDING -} -"""TodoWhereInput is used for filtering Todo objects.""" -input TodoWhereInput { - not: TodoWhereInput - and: [TodoWhereInput!] - or: [TodoWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """created_at field predicates""" - createdAt: Time - createdAtNEQ: Time - createdAtIn: [Time!] - createdAtNotIn: [Time!] - createdAtGT: Time - createdAtGTE: Time - createdAtLT: Time - createdAtLTE: Time - """status field predicates""" - status: TodoStatus - statusNEQ: TodoStatus - statusIn: [TodoStatus!] - statusNotIn: [TodoStatus!] - """priority field predicates""" - priority: Int - priorityNEQ: Int - priorityIn: [Int!] - priorityNotIn: [Int!] - priorityGT: Int - priorityGTE: Int - priorityLT: Int - priorityLTE: Int - """text field predicates""" - text: String - textNEQ: String - textIn: [String!] - textNotIn: [String!] - textGT: String - textGTE: String - textLT: String - textLTE: String - textContains: String - textHasPrefix: String - textHasSuffix: String - textEqualFold: String - textContainsFold: String - """category_id field predicates""" - categoryID: ID - categoryIDNEQ: ID - categoryIDIn: [ID!] - categoryIDNotIn: [ID!] - categoryIDIsNil: Boolean - categoryIDNotNil: Boolean - """parent edge predicates""" - hasParent: Boolean - hasParentWith: [TodoWhereInput!] - """children edge predicates""" - hasChildren: Boolean - hasChildrenWith: [TodoWhereInput!] - """category edge predicates""" - hasCategory: Boolean - hasCategoryWith: [CategoryWhereInput!] -} -"""The builtin Uint64 type""" -scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" -input UpdateCategoryInput { - text: String - status: CategoryStatus - config: CategoryConfigInput - clearConfig: Boolean - duration: Duration - clearDuration: Boolean - count: Uint64 - clearCount: Boolean - strings: [String!] - appendStrings: [String!] - clearStrings: Boolean - addTodoIDs: [ID!] - removeTodoIDs: [ID!] - clearTodos: Boolean - addSubCategoryIDs: [ID!] - removeSubCategoryIDs: [ID!] - clearSubCategories: Boolean -} -"""UpdateFriendshipInput is used for update Friendship object.""" -input UpdateFriendshipInput { - createdAt: Time - userID: ID - friendID: ID -} -"""UpdateTodoInput is used for update Todo object.""" -input UpdateTodoInput { - status: TodoStatus - priority: Int - text: String - init: Map - clearInit: Boolean - parentID: ID - clearParent: Boolean - addChildIDs: [ID!] - removeChildIDs: [ID!] - clearChildren: Boolean - secretID: ID - clearSecret: Boolean -} -"""UpdateUserInput is used for update User object.""" -input UpdateUserInput { - name: String - username: UUID - password: String - clearPassword: Boolean - metadata: Map - clearMetadata: Boolean - addGroupIDs: [ID!] - removeGroupIDs: [ID!] - clearGroups: Boolean - addFriendIDs: [ID!] - removeFriendIDs: [ID!] - clearFriends: Boolean -} -type User implements Node { - id: ID! - name: String! - username: UUID! - metadata: Map - """The groups of the user""" - groups( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Filtering options for Groups returned from the connection.""" - where: GroupWhereInput - ): GroupList - friends( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Ordering options for Users returned from the connection.""" - orderBy: UserOrder - - """Filtering options for Users returned from the connection.""" - where: UserWhereInput - ): UserList - friendships( - """Pagination limit.""" - limit: Int = 100 - - """Pagination offset.""" - offset: Int = 0 - - """Filtering options for Friendships returned from the connection.""" - where: FriendshipWhereInput - ): FriendshipList -} -"""A connection to a list of items.""" -type UserList { - """Identifies the total count of data items.""" - totalCount: Int! - """The list of data items.""" - items: [User]! -} -"""Ordering options for User connections""" -input UserOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Users.""" - field: UserOrderField! -} -"""Properties by which User connections can be ordered.""" -enum UserOrderField { - GROUPS_COUNT -} -"""UserWhereInput is used for filtering User objects.""" -input UserWhereInput { - not: UserWhereInput - and: [UserWhereInput!] - or: [UserWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """name field predicates""" - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """username field predicates""" - username: UUID - usernameNEQ: UUID - usernameIn: [UUID!] - usernameNotIn: [UUID!] - usernameGT: UUID - usernameGTE: UUID - usernameLT: UUID - usernameLTE: UUID - """groups edge predicates""" - hasGroups: Boolean - hasGroupsWith: [GroupWhereInput!] - """friends edge predicates""" - hasFriends: Boolean - hasFriendsWith: [UserWhereInput!] - """friendships edge predicates""" - hasFriendships: Boolean - hasFriendshipsWith: [FriendshipWhereInput!] -} -`, BuiltIn: false}, + {Name: "todo.graphql", Input: sourceData("todo.graphql"), BuiltIn: false}, + {Name: "ent.graphql", Input: sourceData("ent.graphql"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) @@ -1977,10 +1206,10 @@ func (ec *executionContext) field_Category_todos_args(ctx context.Context, rawAr } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2139,10 +1368,10 @@ func (ec *executionContext) field_Project_todos_args(ctx context.Context, rawArg } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2322,6 +1551,48 @@ func (ec *executionContext) field_Query_oneToMany_args(ctx context.Context, rawA return args, nil } +func (ec *executionContext) field_Query_todosWithJoins_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["offset"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset")) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["offset"] = arg1 + var arg2 []*ent.TodoOrder + if tmp, ok := rawArgs["orderBy"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["orderBy"] = arg2 + var arg3 *ent.TodoWhereInput + if tmp, ok := rawArgs["where"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) + arg3, err = ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["where"] = arg3 + return args, nil +} + func (ec *executionContext) field_Query_todos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2343,10 +1614,10 @@ func (ec *executionContext) field_Query_todos_args(ctx context.Context, rawArgs } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2427,10 +1698,10 @@ func (ec *executionContext) field_Todo_children_args(ctx context.Context, rawArg } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2947,6 +2218,51 @@ func (ec *executionContext) fieldContext_Category_config(ctx context.Context, fi return fc, nil } +func (ec *executionContext) _Category_types(ctx context.Context, field graphql.CollectedField, obj *ent.Category) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Category_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*schematype.CategoryTypes) + fc.Result = res + return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Category_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Category", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "public": + return ec.fieldContext_CategoryTypes_public(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CategoryTypes", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Category_duration(ctx context.Context, field graphql.CollectedField, obj *ent.Category) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Category_duration(ctx, field) if err != nil { @@ -3084,7 +2400,7 @@ func (ec *executionContext) _Category_todos(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -3123,7 +2439,7 @@ func (ec *executionContext) fieldContext_Category_todos(ctx context.Context, fie ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Category_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3181,7 +2497,7 @@ func (ec *executionContext) fieldContext_Category_subCategories(ctx context.Cont ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Category_subCategories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3359,6 +2675,8 @@ func (ec *executionContext) fieldContext_CategoryList_items(ctx context.Context, return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -3378,6 +2696,47 @@ func (ec *executionContext) fieldContext_CategoryList_items(ctx context.Context, return fc, nil } +func (ec *executionContext) _CategoryTypes_public(ctx context.Context, field graphql.CollectedField, obj *schematype.CategoryTypes) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CategoryTypes_public(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Public, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalOBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CategoryTypes_public(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CategoryTypes", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Custom_info(ctx context.Context, field graphql.CollectedField, obj *customstruct.Custom) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Custom_info(ctx, field) if err != nil { @@ -3643,6 +3002,8 @@ func (ec *executionContext) fieldContext_Friendship_user(ctx context.Context, fi return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -3703,6 +3064,8 @@ func (ec *executionContext) fieldContext_Friendship_friend(ctx context.Context, return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -3961,7 +3324,7 @@ func (ec *executionContext) fieldContext_Group_users(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Group_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4133,6 +3496,8 @@ func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Con return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -4158,7 +3523,7 @@ func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Con ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createCategory_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4245,7 +3610,7 @@ func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4332,7 +3697,7 @@ func (ec *executionContext) fieldContext_Mutation_updateTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4445,7 +3810,7 @@ func (ec *executionContext) fieldContext_Mutation_updateFriendship(ctx context.C ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateFriendship_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4785,6 +4150,94 @@ func (ec *executionContext) fieldContext_OneToManyList_items(ctx context.Context return fc, nil } +func (ec *executionContext) _Organization_id(ctx context.Context, field graphql.CollectedField, obj *ent.Workspace) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNID2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Organization_name(ctx context.Context, field graphql.CollectedField, obj *ent.Workspace) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { @@ -5013,7 +4466,7 @@ func (ec *executionContext) _Project_todos(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5052,7 +4505,7 @@ func (ec *executionContext) fieldContext_Project_todos(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Project_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5104,7 +4557,7 @@ func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5159,7 +4612,7 @@ func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5271,7 +4724,7 @@ func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_categories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5329,7 +4782,7 @@ func (ec *executionContext) fieldContext_Query_groups(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_groups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5387,7 +4840,7 @@ func (ec *executionContext) fieldContext_Query_oneToMany(ctx context.Context, fi ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_oneToMany_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5406,7 +4859,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Todos(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return ec.resolvers.Query().Todos(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5445,7 +4898,7 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5503,7 +4956,7 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5552,8 +5005,8 @@ func (ec *executionContext) fieldContext_Query_ping(ctx context.Context, field g return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _Query_todosWithJoins(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_todosWithJoins(ctx, field) if err != nil { return graphql.Null } @@ -5566,7 +5019,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return ec.resolvers.Query().TodosWithJoins(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5575,21 +5028,79 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*ent.TodoList) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOTodoList2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoList(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_todosWithJoins(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) + case "totalCount": + return ec.fieldContext_TodoList_totalCount(ctx, field) + case "items": + return ec.fieldContext_TodoList_items(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TodoList", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_todosWithJoins_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) case "name": return ec.fieldContext___Type_name(ctx, field) case "description": @@ -5621,7 +5132,7 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6242,7 +5753,7 @@ func (ec *executionContext) _Todo_children(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Children(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Children(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -6281,7 +5792,7 @@ func (ec *executionContext) fieldContext_Todo_children(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Todo_children_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6330,6 +5841,8 @@ func (ec *executionContext) fieldContext_Todo_category(ctx context.Context, fiel return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -6642,6 +6155,50 @@ func (ec *executionContext) fieldContext_User_username(ctx context.Context, fiel return fc, nil } +func (ec *executionContext) _User_requiredMetadata(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_requiredMetadata(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RequiredMetadata, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(map[string]interface{}) + fc.Result = res + return ec.marshalNMap2map(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_requiredMetadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Map does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_metadata(ctx, field) if err != nil { @@ -6736,7 +6293,7 @@ func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_groups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6794,7 +6351,7 @@ func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_friends_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6852,7 +6409,7 @@ func (ec *executionContext) fieldContext_User_friendships(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_friendships_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6946,6 +6503,8 @@ func (ec *executionContext) fieldContext_UserList_items(ctx context.Context, fie return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -8382,7 +7941,7 @@ func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -8570,7 +8129,7 @@ func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -8741,368 +8300,328 @@ func (ec *executionContext) unmarshalInputBillProductWhereInput(ctx context.Cont asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "sku", "skuNEQ", "skuIn", "skuNotIn", "skuGT", "skuGTE", "skuLT", "skuLTE", "skuContains", "skuHasPrefix", "skuHasSuffix", "skuEqualFold", "skuContainsFold", "quantity", "quantityNEQ", "quantityIn", "quantityNotIn", "quantityGT", "quantityGTE", "quantityLT", "quantityLTE"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOBillProductWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐBillProductWhereInput(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐBillProductWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐBillProductWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐBillProductWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐBillProductWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐBillProductWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "sku": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sku")) - it.Sku, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Sku = data case "skuNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuNEQ")) - it.SkuNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuNEQ = data case "skuIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuIn")) - it.SkuIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.SkuIn = data case "skuNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuNotIn")) - it.SkuNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.SkuNotIn = data case "skuGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuGT")) - it.SkuGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuGT = data case "skuGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuGTE")) - it.SkuGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuGTE = data case "skuLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuLT")) - it.SkuLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuLT = data case "skuLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuLTE")) - it.SkuLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuLTE = data case "skuContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuContains")) - it.SkuContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuContains = data case "skuHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuHasPrefix")) - it.SkuHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuHasPrefix = data case "skuHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuHasSuffix")) - it.SkuHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuHasSuffix = data case "skuEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuEqualFold")) - it.SkuEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuEqualFold = data case "skuContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuContainsFold")) - it.SkuContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuContainsFold = data case "quantity": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantity")) - it.Quantity, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Quantity = data case "quantityNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityNEQ")) - it.QuantityNEQ, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityNEQ = data case "quantityIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityIn")) - it.QuantityIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.QuantityIn = data case "quantityNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityNotIn")) - it.QuantityNotIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.QuantityNotIn = data case "quantityGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityGT")) - it.QuantityGT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityGT = data case "quantityGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityGTE")) - it.QuantityGTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityGTE = data case "quantityLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityLT")) - it.QuantityLT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityLT = data case "quantityLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityLTE")) - it.QuantityLTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityLTE = data } } @@ -9116,16 +8635,20 @@ func (ec *executionContext) unmarshalInputCategoryConfigInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"maxMembers"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "maxMembers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("maxMembers")) - it.MaxMembers, err = ec.unmarshalOInt2int(ctx, v) + data, err := ec.unmarshalOInt2int(ctx, v) if err != nil { return it, err } + it.MaxMembers = data } } @@ -9143,24 +8666,54 @@ func (ec *executionContext) unmarshalInputCategoryOrder(ctx context.Context, obj asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNCategoryOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryOrderField(ctx, v) + data, err := ec.unmarshalNCategoryOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCategoryTypesInput(ctx context.Context, obj interface{}) (schematype.CategoryTypes, error) { + var it schematype.CategoryTypes + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"public"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.Public = data } } @@ -9174,504 +8727,447 @@ func (ec *executionContext) unmarshalInputCategoryWhereInput(ctx context.Context asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "text", "textNEQ", "textIn", "textNotIn", "textGT", "textGTE", "textLT", "textLTE", "textContains", "textHasPrefix", "textHasSuffix", "textEqualFold", "textContainsFold", "status", "statusNEQ", "statusIn", "statusNotIn", "config", "configNEQ", "configIn", "configNotIn", "configGT", "configGTE", "configLT", "configLTE", "configIsNil", "configNotNil", "duration", "durationNEQ", "durationIn", "durationNotIn", "durationGT", "durationGTE", "durationLT", "durationLTE", "durationIsNil", "durationNotNil", "count", "countNEQ", "countIn", "countNotIn", "countGT", "countGTE", "countLT", "countLTE", "countIsNil", "countNotNil", "hasTodos", "hasTodosWith", "hasSubCategories", "hasSubCategoriesWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInput(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "textNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNEQ")) - it.TextNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextNEQ = data case "textIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textIn")) - it.TextIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextIn = data case "textNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNotIn")) - it.TextNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextNotIn = data case "textGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGT")) - it.TextGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGT = data case "textGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGTE")) - it.TextGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGTE = data case "textLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLT")) - it.TextLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLT = data case "textLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLTE")) - it.TextLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLTE = data case "textContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContains")) - it.TextContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContains = data case "textHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasPrefix")) - it.TextHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasPrefix = data case "textHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasSuffix")) - it.TextHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasSuffix = data case "textEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textEqualFold")) - it.TextEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextEqualFold = data case "textContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContainsFold")) - it.TextContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContainsFold = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "statusNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) - it.StatusNEQ, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.StatusNEQ = data case "statusIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) - it.StatusIn, err = ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusIn = data case "statusNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) - it.StatusNotIn, err = ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusNotIn = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.Config = data case "configNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNEQ")) - it.ConfigNEQ, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigNEQ = data case "configIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configIn")) - it.ConfigIn, err = ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) if err != nil { return it, err } + it.ConfigIn = data case "configNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNotIn")) - it.ConfigNotIn, err = ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) if err != nil { return it, err } + it.ConfigNotIn = data case "configGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configGT")) - it.ConfigGT, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigGT = data case "configGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configGTE")) - it.ConfigGTE, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigGTE = data case "configLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configLT")) - it.ConfigLT, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigLT = data case "configLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configLTE")) - it.ConfigLTE, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigLTE = data case "configIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configIsNil")) - it.ConfigIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ConfigIsNil = data case "configNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNotNil")) - it.ConfigNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ConfigNotNil = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "durationNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNEQ")) - it.DurationNEQ, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationNEQ = data case "durationIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationIn")) - it.DurationIn, err = ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) + data, err := ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) if err != nil { return it, err } + it.DurationIn = data case "durationNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNotIn")) - it.DurationNotIn, err = ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) + data, err := ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) if err != nil { return it, err } + it.DurationNotIn = data case "durationGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationGT")) - it.DurationGT, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationGT = data case "durationGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationGTE")) - it.DurationGTE, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationGTE = data case "durationLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationLT")) - it.DurationLT, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationLT = data case "durationLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationLTE")) - it.DurationLTE, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationLTE = data case "durationIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationIsNil")) - it.DurationIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.DurationIsNil = data case "durationNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNotNil")) - it.DurationNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.DurationNotNil = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "countNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNEQ")) - it.CountNEQ, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountNEQ = data case "countIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countIn")) - it.CountIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.CountIn = data case "countNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNotIn")) - it.CountNotIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.CountNotIn = data case "countGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countGT")) - it.CountGT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountGT = data case "countGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countGTE")) - it.CountGTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountGTE = data case "countLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countLT")) - it.CountLT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountLT = data case "countLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countLTE")) - it.CountLTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountLTE = data case "countIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countIsNil")) - it.CountIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CountIsNil = data case "countNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNotNil")) - it.CountNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CountNotNil = data case "hasTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) - it.HasTodos, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasTodos = data case "hasTodosWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) - it.HasTodosWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasTodosWith = data case "hasSubCategories": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSubCategories")) - it.HasSubCategories, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasSubCategories = data case "hasSubCategoriesWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSubCategoriesWith")) - it.HasSubCategoriesWith, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasSubCategoriesWith = data } } @@ -9685,75 +9181,77 @@ func (ec *executionContext) unmarshalInputCreateCategoryInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"text", "status", "config", "types", "duration", "count", "strings", "todoIDs", "subCategoryIDs", "createTodos"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalNCategoryStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalNCategoryStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + if err != nil { + return it, err + } + it.Config = data + case "types": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("types")) + data, err := ec.unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx, v) if err != nil { return it, err } + it.Types = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "strings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strings")) - it.Strings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Strings = data case "todoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("todoIDs")) - it.TodoIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.TodoIDs = data case "subCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subCategoryIDs")) - it.SubCategoryIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.SubCategoryIDs = data case "createTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTodos")) data, err := ec.unmarshalOCreateTodoInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCreateTodoInputᚄ(ctx, v) if err != nil { @@ -9775,72 +9273,69 @@ func (ec *executionContext) unmarshalInputCreateTodoInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "init", "parentID", "childIDs", "categoryID", "secretID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalNTodoStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) + data, err := ec.unmarshalNTodoStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "init": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("init")) - it.Init, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Init = data case "parentID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) - it.ParentID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ParentID = data case "childIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("childIDs")) - it.ChildIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.ChildIDs = data case "categoryID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryID")) - it.CategoryID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.CategoryID = data case "secretID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretID")) - it.SecretID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.SecretID = data } } @@ -9854,56 +9349,62 @@ func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "username", "password", "requiredMetadata", "metadata", "groupIDs", "friendIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - it.Username, err = ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.Username = data case "password": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Password = data + case "requiredMetadata": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requiredMetadata")) + data, err := ec.unmarshalNMap2map(ctx, v) if err != nil { return it, err } + it.RequiredMetadata = data case "metadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadata")) - it.Metadata, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Metadata = data case "groupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIDs")) - it.GroupIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.GroupIDs = data case "friendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("friendIDs")) - it.FriendIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.FriendIDs = data } } @@ -9917,160 +9418,146 @@ func (ec *executionContext) unmarshalInputFriendshipWhereInput(ctx context.Conte asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendshipWhereInput(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendshipWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "createdAt": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAt = data case "createdAtNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtNEQ = data case "createdAtIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtIn = data case "createdAtNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtNotIn = data case "createdAtGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGT = data case "createdAtGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGTE = data case "createdAtLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLT = data case "createdAtLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLTE = data } } @@ -10084,216 +9571,195 @@ func (ec *executionContext) unmarshalInputGroupWhereInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasUsers", "hasUsersWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroupWhereInput(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroupWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "hasUsers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUsers")) - it.HasUsers, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasUsers = data case "hasUsersWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUsersWith")) - it.HasUsersWith, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasUsersWith = data } } @@ -10311,24 +9777,27 @@ func (ec *executionContext) unmarshalInputOneToManyOrder(ctx context.Context, ob asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNOneToManyOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyOrderField(ctx, v) + data, err := ec.unmarshalNOneToManyOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -10342,972 +9811,1064 @@ func (ec *executionContext) unmarshalInputOneToManyWhereInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "field2", "field2NEQ", "field2In", "field2NotIn", "field2GT", "field2GTE", "field2LT", "field2LTE", "field2Contains", "field2HasPrefix", "field2HasSuffix", "field2IsNil", "field2NotNil", "field2EqualFold", "field2ContainsFold", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInput(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "field2": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2")) - it.Field2, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2 = data case "field2NEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NEQ")) - it.Field2NEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2NEQ = data case "field2In": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2In")) - it.Field2In, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Field2In = data case "field2NotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NotIn")) - it.Field2NotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Field2NotIn = data case "field2GT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2GT")) - it.Field2GT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2GT = data case "field2GTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2GTE")) - it.Field2GTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2GTE = data case "field2LT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2LT")) - it.Field2LT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2LT = data case "field2LTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2LTE")) - it.Field2LTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2LTE = data case "field2Contains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2Contains")) - it.Field2Contains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2Contains = data case "field2HasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2HasPrefix")) - it.Field2HasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2HasPrefix = data case "field2HasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2HasSuffix")) - it.Field2HasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2HasSuffix = data case "field2IsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2IsNil")) - it.Field2IsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.Field2IsNil = data case "field2NotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NotNil")) - it.Field2NotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.Field2NotNil = data case "field2EqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2EqualFold")) - it.Field2EqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2EqualFold = data case "field2ContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2ContainsFold")) - it.Field2ContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2ContainsFold = data case "hasParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParent")) - it.HasParent, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasParent = data case "hasParentWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParentWith")) - it.HasParentWith, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasParentWith = data case "hasChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildren")) - it.HasChildren, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasChildren = data case "hasChildrenWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildrenWith")) - it.HasChildrenWith, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasChildrenWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputProjectWhereInput(ctx context.Context, obj interface{}) (ent.ProjectWhereInput, error) { - var it ent.ProjectWhereInput +func (ec *executionContext) unmarshalInputOrganizationWhereInput(ctx context.Context, obj interface{}) (ent.OrganizationWhereInput, error) { + var it ent.OrganizationWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐProjectWhereInput(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOrganizationWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐProjectWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOrganizationWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐProjectWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOrganizationWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "hasTodos": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) - it.HasTodos, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.IDLTE = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hasTodosWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) - it.HasTodosWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj interface{}) (ent.TodoOrder, error) { - var it ent.TodoOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - for k, v := range asMap { - switch k { - case "direction": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "field": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderField(ctx, v) + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data } } return it, nil } -func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, obj interface{}) (ent.TodoWhereInput, error) { - var it ent.TodoWhereInput +func (ec *executionContext) unmarshalInputProjectWhereInput(ctx context.Context, obj interface{}) (ent.ProjectWhereInput, error) { + var it ent.ProjectWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "hasTodos", "hasTodosWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInput(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐProjectWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐProjectWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐProjectWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } - case "createdAt": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IDLTE = data + case "hasTodos": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "createdAtNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.HasTodos = data + case "hasTodosWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "createdAtIn": - var err error + it.HasTodosWith = data + } + } - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + return it, nil +} + +func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj interface{}) (ent.TodoOrder, error) { + var it ent.TodoOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - case "createdAtNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderField(ctx, v) if err != nil { return it, err } - case "createdAtGT": - var err error + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, obj interface{}) (ent.TodoWhereInput, error) { + var it ent.TodoWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "status", "statusNEQ", "statusIn", "statusNotIn", "priority", "priorityNEQ", "priorityIn", "priorityNotIn", "priorityGT", "priorityGTE", "priorityLT", "priorityLTE", "text", "textNEQ", "textIn", "textNotIn", "textGT", "textGTE", "textLT", "textLTE", "textContains", "textHasPrefix", "textHasSuffix", "textEqualFold", "textContainsFold", "categoryID", "categoryIDNEQ", "categoryIDIn", "categoryIDNotIn", "categoryIDIsNil", "categoryIDNotNil", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith", "hasCategory", "hasCategoryWith", "createdToday"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGT = data case "createdAtGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGTE = data case "createdAtLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLT = data case "createdAtLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLTE = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) + data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "statusNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) - it.StatusNEQ, err = ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) + data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { return it, err } + it.StatusNEQ = data case "statusIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) - it.StatusIn, err = ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusIn = data case "statusNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) - it.StatusNotIn, err = ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusNotIn = data case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "priorityNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityNEQ")) - it.PriorityNEQ, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityNEQ = data case "priorityIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityIn")) - it.PriorityIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.PriorityIn = data case "priorityNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityNotIn")) - it.PriorityNotIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.PriorityNotIn = data case "priorityGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityGT")) - it.PriorityGT, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityGT = data case "priorityGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityGTE")) - it.PriorityGTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityGTE = data case "priorityLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityLT")) - it.PriorityLT, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityLT = data case "priorityLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityLTE")) - it.PriorityLTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityLTE = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "textNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNEQ")) - it.TextNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextNEQ = data case "textIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textIn")) - it.TextIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextIn = data case "textNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNotIn")) - it.TextNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextNotIn = data case "textGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGT")) - it.TextGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGT = data case "textGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGTE")) - it.TextGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGTE = data case "textLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLT")) - it.TextLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLT = data case "textLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLTE")) - it.TextLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLTE = data case "textContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContains")) - it.TextContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContains = data case "textHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasPrefix")) - it.TextHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasPrefix = data case "textHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasSuffix")) - it.TextHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasSuffix = data case "textEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textEqualFold")) - it.TextEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextEqualFold = data case "textContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContainsFold")) - it.TextContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContainsFold = data case "categoryID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryID")) - it.CategoryID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.CategoryID = data case "categoryIDNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNEQ")) - it.CategoryIDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.CategoryIDNEQ = data case "categoryIDIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDIn")) - it.CategoryIDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.CategoryIDIn = data case "categoryIDNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNotIn")) - it.CategoryIDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.CategoryIDNotIn = data case "categoryIDIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDIsNil")) - it.CategoryIDIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CategoryIDIsNil = data case "categoryIDNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNotNil")) - it.CategoryIDNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CategoryIDNotNil = data case "hasParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParent")) - it.HasParent, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasParent = data case "hasParentWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParentWith")) - it.HasParentWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasParentWith = data case "hasChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildren")) - it.HasChildren, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasChildren = data case "hasChildrenWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildrenWith")) - it.HasChildrenWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasChildrenWith = data case "hasCategory": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCategory")) - it.HasCategory, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasCategory = data case "hasCategoryWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCategoryWith")) - it.HasCategoryWith, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasCategoryWith = data case "createdToday": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdToday")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { @@ -11329,144 +10890,146 @@ func (ec *executionContext) unmarshalInputUpdateCategoryInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"text", "status", "config", "clearConfig", "types", "clearTypes", "duration", "clearDuration", "count", "clearCount", "strings", "appendStrings", "clearStrings", "addTodoIDs", "removeTodoIDs", "clearTodos", "addSubCategoryIDs", "removeSubCategoryIDs", "clearSubCategories"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.Config = data case "clearConfig": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearConfig")) - it.ClearConfig, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearConfig = data + case "types": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("types")) + data, err := ec.unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx, v) + if err != nil { + return it, err + } + it.Types = data + case "clearTypes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTypes")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearTypes = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "clearDuration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearDuration")) - it.ClearDuration, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearDuration = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "clearCount": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearCount")) - it.ClearCount, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearCount = data case "strings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strings")) - it.Strings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Strings = data case "appendStrings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("appendStrings")) - it.AppendStrings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.AppendStrings = data case "clearStrings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearStrings")) - it.ClearStrings, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearStrings = data case "addTodoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addTodoIDs")) - it.AddTodoIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.AddTodoIDs = data case "removeTodoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeTodoIDs")) - it.RemoveTodoIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.RemoveTodoIDs = data case "clearTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTodos")) - it.ClearTodos, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearTodos = data case "addSubCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addSubCategoryIDs")) - it.AddSubCategoryIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.AddSubCategoryIDs = data case "removeSubCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeSubCategoryIDs")) - it.RemoveSubCategoryIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.RemoveSubCategoryIDs = data case "clearSubCategories": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSubCategories")) - it.ClearSubCategories, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearSubCategories = data } } @@ -11480,32 +11043,34 @@ func (ec *executionContext) unmarshalInputUpdateFriendshipInput(ctx context.Cont asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"createdAt", "userID", "friendID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "createdAt": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAt = data case "userID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - it.UserID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.UserID = data case "friendID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("friendID")) - it.FriendID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.FriendID = data } } @@ -11519,104 +11084,97 @@ func (ec *executionContext) unmarshalInputUpdateTodoInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "init", "clearInit", "parentID", "clearParent", "addChildIDs", "removeChildIDs", "clearChildren", "secretID", "clearSecret"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) + data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "init": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("init")) - it.Init, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Init = data case "clearInit": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearInit")) - it.ClearInit, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearInit = data case "parentID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) - it.ParentID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ParentID = data case "clearParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearParent")) - it.ClearParent, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearParent = data case "addChildIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addChildIDs")) - it.AddChildIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.AddChildIDs = data case "removeChildIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeChildIDs")) - it.RemoveChildIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.RemoveChildIDs = data case "clearChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearChildren")) - it.ClearChildren, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearChildren = data case "secretID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretID")) - it.SecretID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.SecretID = data case "clearSecret": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSecret")) - it.ClearSecret, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearSecret = data } } @@ -11630,104 +11188,104 @@ func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "username", "password", "clearPassword", "requiredMetadata", "metadata", "clearMetadata", "addGroupIDs", "removeGroupIDs", "clearGroups", "addFriendIDs", "removeFriendIDs", "clearFriends"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - it.Username, err = ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.Username = data case "password": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Password = data case "clearPassword": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearPassword")) - it.ClearPassword, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearPassword = data + case "requiredMetadata": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requiredMetadata")) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.RequiredMetadata = data case "metadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadata")) - it.Metadata, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Metadata = data case "clearMetadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearMetadata")) - it.ClearMetadata, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearMetadata = data case "addGroupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addGroupIDs")) - it.AddGroupIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.AddGroupIDs = data case "removeGroupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeGroupIDs")) - it.RemoveGroupIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.RemoveGroupIDs = data case "clearGroups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearGroups")) - it.ClearGroups, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearGroups = data case "addFriendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addFriendIDs")) - it.AddFriendIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.AddFriendIDs = data case "removeFriendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeFriendIDs")) - it.RemoveFriendIDs, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.RemoveFriendIDs = data case "clearFriends": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearFriends")) - it.ClearFriends, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearFriends = data } } @@ -11745,24 +11303,27 @@ func (ec *executionContext) unmarshalInputUserOrder(ctx context.Context, obj int asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNUserOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserOrderField(ctx, v) + data, err := ec.unmarshalNUserOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -11776,312 +11337,279 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "username", "usernameNEQ", "usernameIn", "usernameNotIn", "usernameGT", "usernameGTE", "usernameLT", "usernameLTE", "hasGroups", "hasGroupsWith", "hasFriends", "hasFriendsWith", "hasFriendships", "hasFriendshipsWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOUserWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInput(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - it.Username, err = ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.Username = data case "usernameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameNEQ")) - it.UsernameNEQ, err = ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.UsernameNEQ = data case "usernameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameIn")) - it.UsernameIn, err = ec.unmarshalOUUID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOUUID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.UsernameIn = data case "usernameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameNotIn")) - it.UsernameNotIn, err = ec.unmarshalOUUID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOUUID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.UsernameNotIn = data case "usernameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameGT")) - it.UsernameGT, err = ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.UsernameGT = data case "usernameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameGTE")) - it.UsernameGTE, err = ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.UsernameGTE = data case "usernameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameLT")) - it.UsernameLT, err = ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.UsernameLT = data case "usernameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameLTE")) - it.UsernameLTE, err = ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.UsernameLTE = data case "hasGroups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasGroups")) - it.HasGroups, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasGroups = data case "hasGroupsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasGroupsWith")) - it.HasGroupsWith, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasGroupsWith = data case "hasFriends": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriends")) - it.HasFriends, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasFriends = data case "hasFriendsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendsWith")) - it.HasFriendsWith, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasFriendsWith = data case "hasFriendships": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendships")) - it.HasFriendships, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasFriendships = data case "hasFriendshipsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendshipsWith")) - it.HasFriendshipsWith, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasFriendshipsWith = data } } @@ -12092,10 +11620,29 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob // region ************************** interface.gotpl *************************** +func (ec *executionContext) _NamedNode(ctx context.Context, sel ast.SelectionSet, obj NamedNode) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case *ent.Group: + if obj == nil { + return graphql.Null + } + return ec._Group(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null + case *ent.Group: + if obj == nil { + return graphql.Null + } + return ec._Group(ctx, sel, obj) case *ent.BillProduct: if obj == nil { return graphql.Null @@ -12111,16 +11658,16 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Friendship(ctx, sel, obj) - case *ent.Group: + case *ent.OneToMany: if obj == nil { return graphql.Null } - return ec._Group(ctx, sel, obj) - case *ent.OneToMany: + return ec._OneToMany(ctx, sel, obj) + case *ent.Workspace: if obj == nil { return graphql.Null } - return ec._OneToMany(ctx, sel, obj) + return ec._Organization(ctx, sel, obj) case *ent.Project: if obj == nil { return graphql.Null @@ -12149,48 +11696,53 @@ var billProductImplementors = []string{"BillProduct", "Node"} func (ec *executionContext) _BillProduct(ctx context.Context, sel ast.SelectionSet, obj *ent.BillProduct) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, billProductImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("BillProduct") case "id": - out.Values[i] = ec._BillProduct_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec._BillProduct_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "sku": - out.Values[i] = ec._BillProduct_sku(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "quantity": - out.Values[i] = ec._BillProduct_quantity(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12198,53 +11750,42 @@ var categoryImplementors = []string{"Category", "Node"} func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, obj *ent.Category) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Category") case "id": - out.Values[i] = ec._Category_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Category_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "status": - out.Values[i] = ec._Category_status(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "config": - out.Values[i] = ec._Category_config(ctx, field, obj) - + case "types": + out.Values[i] = ec._Category_types(ctx, field, obj) case "duration": - out.Values[i] = ec._Category_duration(ctx, field, obj) - case "count": - out.Values[i] = ec._Category_count(ctx, field, obj) - case "strings": - out.Values[i] = ec._Category_strings(ctx, field, obj) - case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12254,14 +11795,30 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "subCategories": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12271,14 +11828,30 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "todosCount": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12288,18 +11861,46 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12307,24 +11908,35 @@ var categoryConfigImplementors = []string{"CategoryConfig"} func (ec *executionContext) _CategoryConfig(ctx context.Context, sel ast.SelectionSet, obj *schematype.CategoryConfig) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryConfigImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryConfig") case "maxMembers": - out.Values[i] = ec._CategoryConfig_maxMembers(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12332,34 +11944,79 @@ var categoryListImplementors = []string{"CategoryList"} func (ec *executionContext) _CategoryList(ctx context.Context, sel ast.SelectionSet, obj *ent.CategoryList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryList") case "totalCount": - out.Values[i] = ec._CategoryList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._CategoryList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var categoryTypesImplementors = []string{"CategoryTypes"} + +func (ec *executionContext) _CategoryTypes(ctx context.Context, sel ast.SelectionSet, obj *schematype.CategoryTypes) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, categoryTypesImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CategoryTypes") + case "public": + out.Values[i] = ec._CategoryTypes_public(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12367,27 +12024,38 @@ var customImplementors = []string{"Custom"} func (ec *executionContext) _Custom(ctx context.Context, sel ast.SelectionSet, obj *customstruct.Custom) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, customImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Custom") case "info": - out.Values[i] = ec._Custom_info(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12395,44 +12063,37 @@ var friendshipImplementors = []string{"Friendship", "Node"} func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSet, obj *ent.Friendship) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendshipImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Friendship") case "id": - out.Values[i] = ec._Friendship_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Friendship_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "userID": - out.Values[i] = ec._Friendship_userID(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "friendID": - out.Values[i] = ec._Friendship_friendID(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "user": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12440,19 +12101,35 @@ func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSe }() res = ec._Friendship_user(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friend": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12460,23 +12137,51 @@ func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSe }() res = ec._Friendship_friend(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12484,65 +12189,71 @@ var friendshipListImplementors = []string{"FriendshipList"} func (ec *executionContext) _FriendshipList(ctx context.Context, sel ast.SelectionSet, obj *ent.FriendshipList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendshipListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FriendshipList") case "totalCount": - out.Values[i] = ec._FriendshipList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._FriendshipList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } -var groupImplementors = []string{"Group", "Node"} +var groupImplementors = []string{"Group", "Node", "NamedNode"} func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, obj *ent.Group) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, groupImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Group") case "id": - out.Values[i] = ec._Group_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._Group_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "users": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12552,18 +12263,46 @@ func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, ob return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12571,34 +12310,43 @@ var groupListImplementors = []string{"GroupList"} func (ec *executionContext) _GroupList(ctx context.Context, sel ast.SelectionSet, obj *ent.GroupList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, groupListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("GroupList") case "totalCount": - out.Values[i] = ec._GroupList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._GroupList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12611,7 +12359,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -12622,58 +12370,60 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createCategory": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createCategory(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "createTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "updateTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "clearTodos": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_clearTodos(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "updateFriendship": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateFriendship(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12681,34 +12431,29 @@ var oneToManyImplementors = []string{"OneToMany", "Node"} func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet, obj *ent.OneToMany) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, oneToManyImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OneToMany") case "id": - out.Values[i] = ec._OneToMany_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._OneToMany_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "field2": - out.Values[i] = ec._OneToMany_field2(ctx, field, obj) - case "parent": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12718,14 +12463,30 @@ func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "children": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12735,18 +12496,46 @@ func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12754,34 +12543,87 @@ var oneToManyListImplementors = []string{"OneToManyList"} func (ec *executionContext) _OneToManyList(ctx context.Context, sel ast.SelectionSet, obj *ent.OneToManyList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, oneToManyListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OneToManyList") case "totalCount": - out.Values[i] = ec._OneToManyList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._OneToManyList_items(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var organizationImplementors = []string{"Organization", "Node"} + +func (ec *executionContext) _Organization(ctx context.Context, sel ast.SelectionSet, obj *ent.Workspace) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, organizationImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Organization") + case "id": + out.Values[i] = ec._Organization_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._Organization_name(ctx, field, obj) if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12789,42 +12631,47 @@ var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12832,23 +12679,22 @@ var projectImplementors = []string{"Project", "Node"} func (ec *executionContext) _Project(ctx context.Context, sel ast.SelectionSet, obj *ent.Project) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, projectImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Project") case "id": - out.Values[i] = ec._Project_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12858,18 +12704,46 @@ func (ec *executionContext) _Project(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12882,7 +12756,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -12895,7 +12769,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "node": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12906,16 +12780,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nodes": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12923,22 +12796,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_nodes(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "billProducts": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12946,22 +12818,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_billProducts(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "categories": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12972,16 +12843,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "groups": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12992,16 +12862,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "oneToMany": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13012,16 +12881,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13032,16 +12900,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "users": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13052,16 +12919,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "ping": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13069,38 +12935,64 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_ping(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "__type": + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "todosWithJoins": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_todosWithJoins(ctx, field) + return res + } + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) - case "__schema": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13108,75 +13000,54 @@ var todoImplementors = []string{"Todo", "Node"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *ent.Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Todo_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "status": - out.Values[i] = ec._Todo_status(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "priorityOrder": - out.Values[i] = ec._Todo_priorityOrder(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "categoryID": - out.Values[i] = ec._Todo_categoryID(ctx, field, obj) - case "category_id": - out.Values[i] = ec._Todo_category_id(ctx, field, obj) - case "categoryX": - out.Values[i] = ec._Todo_categoryX(ctx, field, obj) - case "init": - out.Values[i] = ec._Todo_init(ctx, field, obj) - case "custom": - out.Values[i] = ec._Todo_custom(ctx, field, obj) - case "customp": - out.Values[i] = ec._Todo_customp(ctx, field, obj) - case "parent": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13186,14 +13057,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "children": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13203,14 +13090,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "category": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13220,14 +13123,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "extendedField": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13237,18 +13156,46 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13256,34 +13203,43 @@ var todoListImplementors = []string{"TodoList"} func (ec *executionContext) _TodoList(ctx context.Context, sel ast.SelectionSet, obj *ent.TodoList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("TodoList") case "totalCount": - out.Values[i] = ec._TodoList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._TodoList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13291,41 +13247,39 @@ var userImplementors = []string{"User", "Node"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *ent.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "username": - out.Values[i] = ec._User_username(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) + } + case "requiredMetadata": + out.Values[i] = ec._User_requiredMetadata(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) } case "metadata": - out.Values[i] = ec._User_metadata(ctx, field, obj) - case "groups": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13335,14 +13289,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friends": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13352,14 +13322,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friendships": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13369,18 +13355,46 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13388,34 +13402,43 @@ var userListImplementors = []string{"UserList"} func (ec *executionContext) _UserList(ctx context.Context, sel ast.SelectionSet, obj *ent.UserList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("UserList") case "totalCount": - out.Values[i] = ec._UserList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._UserList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13423,52 +13446,55 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isRepeatable": - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13476,42 +13502,47 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13519,56 +13550,57 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13576,42 +13608,47 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13619,53 +13656,54 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "description": - out.Values[i] = ec.___Schema_description(ctx, field, obj) - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13673,63 +13711,56 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - case "specifiedByURL": - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -14100,6 +14131,27 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } +func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + func (ec *executionContext) marshalNNode2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v []ent.Noder) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -14217,6 +14269,11 @@ func (ec *executionContext) marshalNOrderDirection2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) unmarshalNOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOrganizationWhereInput(ctx context.Context, v interface{}) (*ent.OrganizationWhereInput, error) { + res, err := ec.unmarshalInputOrganizationWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐProjectWhereInput(ctx context.Context, v interface{}) (*ent.ProjectWhereInput, error) { res, err := ec.unmarshalInputProjectWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -14336,6 +14393,11 @@ func (ec *executionContext) marshalNTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinte return ec._Todo(ctx, sel, v) } +func (ec *executionContext) unmarshalNTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrder(ctx context.Context, v interface{}) (*ent.TodoOrder, error) { + res, err := ec.unmarshalInputTodoOrder(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderField(ctx context.Context, v interface{}) (*ent.TodoOrderField, error) { var res = new(ent.TodoOrderField) err := res.UnmarshalGQL(v) @@ -14935,6 +14997,21 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } +func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryTypes) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx context.Context, v interface{}) (*schematype.CategoryTypes, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputCategoryTypesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.CategoryWhereInput, error) { if v == nil { return nil, nil @@ -15490,6 +15567,34 @@ func (ec *executionContext) unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontri return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOrganizationWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.OrganizationWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.OrganizationWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOrganizationWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOrganizationWhereInput(ctx context.Context, v interface{}) (*ent.OrganizationWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputOrganizationWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐProjectWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.ProjectWhereInput, error) { if v == nil { return nil, nil @@ -15650,12 +15755,24 @@ func (ec *executionContext) marshalOTodoList2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._TodoList(ctx, sel, v) } -func (ec *executionContext) unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrder(ctx context.Context, v interface{}) (*ent.TodoOrder, error) { +func (ec *executionContext) unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrderᚄ(ctx context.Context, v interface{}) ([]*ent.TodoOrder, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalInputTodoOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.TodoOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodoOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil } func (ec *executionContext) unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx context.Context, v interface{}) ([]todo.Status, error) { diff --git a/entgql/internal/todo/gqlgen.yml b/entgql/internal/todo/gqlgen.yml index f3544aba6..293898ae5 100644 --- a/entgql/internal/todo/gqlgen.yml +++ b/entgql/internal/todo/gqlgen.yml @@ -12,11 +12,15 @@ resolver: dir: . autobind: + # Fix binding for the `Field` interface. + - github.com/99designs/gqlgen/graphql/introspection - entgo.io/contrib/entgql/internal/todo/ent # Auto-bind the generated `Status` enum to GraphQL. - entgo.io/contrib/entgql/internal/todo/ent/todo - entgo.io/contrib/entgql/internal/todo/ent/schema/customstruct +# Disable the generated getters for all models and interfaces. +omit_getters: true models: ID: model: @@ -41,6 +45,12 @@ models: CategoryConfigInput: model: - entgo.io/contrib/entgql/internal/todo/ent/schema/schematype.CategoryConfig + CategoryTypes: + model: + - entgo.io/contrib/entgql/internal/todo/ent/schema/schematype.CategoryTypes + CategoryTypesInput: + model: + - entgo.io/contrib/entgql/internal/todo/ent/schema/schematype.CategoryTypes UUID: model: - - entgo.io/contrib/entgql/internal/todouuid/ent/schema/uuidgql.UUID \ No newline at end of file + - entgo.io/contrib/entgql/internal/todouuid/ent/schema/uuidgql.UUID diff --git a/entgql/internal/todo/models_gen.go b/entgql/internal/todo/models_gen.go new file mode 100644 index 000000000..f7072f773 --- /dev/null +++ b/entgql/internal/todo/models_gen.go @@ -0,0 +1,7 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package todo + +type NamedNode interface { + IsNamedNode() +} diff --git a/entgql/internal/todo/server/server.go b/entgql/internal/todo/server/server.go index 5d74013d5..bac09a742 100644 --- a/entgql/internal/todo/server/server.go +++ b/entgql/internal/todo/server/server.go @@ -11,11 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package main import ( "context" "net/http" + "time" "entgo.io/contrib/entgql" "entgo.io/contrib/entgql/internal/todo" @@ -65,7 +67,11 @@ func main() { http.Handle("/query", srv) log.Info("listening on", zap.String("address", cli.Addr)) - if err := http.ListenAndServe(cli.Addr, nil); err != nil { + server := &http.Server{ + Addr: cli.Addr, + ReadHeaderTimeout: 30 * time.Second, + } + if err := server.ListenAndServe(); err != nil { log.Error("http server terminated", zap.Error(err)) } } diff --git a/entgql/internal/todo/todo.graphql b/entgql/internal/todo/todo.graphql index 58f0091f7..a6022f97d 100644 --- a/entgql/internal/todo/todo.graphql +++ b/entgql/internal/todo/todo.graphql @@ -8,6 +8,14 @@ input CategoryConfigInput { maxMembers: Int } +type CategoryTypes { + public: Boolean +} + +input CategoryTypesInput { + public: Boolean +} + scalar Duration scalar UUID @@ -31,6 +39,21 @@ extend type Query { This field is an example of extending the built-in Query type from Ent. """ ping: String! + + """This is the todo item""" + todosWithJoins( + """Pagination limit.""" + limit: Int = 100 + + """Pagination offset.""" + offset: Int = 0 + + """Ordering options for Todos returned from the connection.""" + orderBy: [TodoOrder!] + + """Filtering options for Todos returned from the connection.""" + where: TodoWhereInput +): TodoList } type Mutation { @@ -48,3 +71,7 @@ type Custom { extend input CreateCategoryInput { createTodos: [CreateTodoInput!] } + +interface NamedNode { + name: String! +} \ No newline at end of file diff --git a/entgql/internal/todo/todo.resolvers.go b/entgql/internal/todo/todo.resolvers.go index 1d8aa04dd..78c1b2790 100644 --- a/entgql/internal/todo/todo.resolvers.go +++ b/entgql/internal/todo/todo.resolvers.go @@ -16,15 +16,19 @@ package todo // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" "time" "entgo.io/contrib/entgql/internal/todo/ent" + "entgo.io/contrib/entgql/internal/todo/ent/category" "entgo.io/contrib/entgql/internal/todo/ent/todo" + "entgo.io/ent/dialect/sql" ) +// TodosCount is the resolver for the todosCount field. func (r *categoryResolver) TodosCount(ctx context.Context, obj *ent.Category) (*int, error) { v, err := ent.CategoryOrderFieldTodosCount.Value(obj) if err != nil { @@ -39,10 +43,12 @@ func (r *categoryResolver) TodosCount(ctx context.Context, obj *ent.Category) (* return &vi, nil } +// CreateCategory is the resolver for the createCategory field. func (r *mutationResolver) CreateCategory(ctx context.Context, input ent.CreateCategoryInput) (*ent.Category, error) { return ent.FromContext(ctx).Category.Create().SetInput(input).Save(ctx) } +// CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo(ctx context.Context, input ent.CreateTodoInput) (*ent.Todo, error) { return ent.FromContext(ctx).Todo. Create(). @@ -50,6 +56,7 @@ func (r *mutationResolver) CreateTodo(ctx context.Context, input ent.CreateTodoI Save(ctx) } +// UpdateTodo is the resolver for the updateTodo field. func (r *mutationResolver) UpdateTodo(ctx context.Context, id int, input ent.UpdateTodoInput) (*ent.Todo, error) { return ent.FromContext(ctx).Todo. UpdateOneID(id). @@ -57,6 +64,7 @@ func (r *mutationResolver) UpdateTodo(ctx context.Context, id int, input ent.Upd Save(ctx) } +// ClearTodos is the resolver for the clearTodos field. func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { client := ent.FromContext(ctx) return client.Todo. @@ -64,6 +72,7 @@ func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { Exec(ctx) } +// UpdateFriendship is the resolver for the updateFriendship field. func (r *mutationResolver) UpdateFriendship(ctx context.Context, id int, input ent.UpdateFriendshipInput) (*ent.Friendship, error) { return r.client.Friendship. UpdateOneID(id). @@ -71,14 +80,33 @@ func (r *mutationResolver) UpdateFriendship(ctx context.Context, id int, input e Save(ctx) } +// Ping is the resolver for the ping field. func (r *queryResolver) Ping(ctx context.Context) (string, error) { return "pong", nil } +// TodosWithJoins is the resolver for the todosWithJoins field. +func (r *queryResolver) TodosWithJoins(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { + return r.client.Todo.Query(). + Modify(func(s *sql.Selector) { + cats := sql.Table(category.Table) + s. + LeftJoin(cats). + On(s.C(todo.FieldCategoryID), cats.C(category.FieldID)). + GroupBy(s.C(category.FieldID)) + }). + PaginateLimitOffset(ctx, limit, offset, + ent.WithTodoOrder(orderBy), + ent.WithTodoFilter(where.Filter), + ) +} + +// ExtendedField is the resolver for the extendedField field. func (r *todoResolver) ExtendedField(ctx context.Context, obj *ent.Todo) (*string, error) { return &obj.Text, nil } +// CreateTodos is the resolver for the createTodos field. func (r *createCategoryInputResolver) CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error { e := ent.FromContext(ctx) builders := make([]*ent.TodoCreate, len(data)) @@ -97,6 +125,7 @@ func (r *createCategoryInputResolver) CreateTodos(ctx context.Context, obj *ent. return nil } +// CreatedToday is the resolver for the createdToday field. func (r *todoWhereInputResolver) CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error { if data == nil { return nil diff --git a/entgql/internal/todo/todo_test.go b/entgql/internal/todo/todo_test.go index cdc7cc233..a573efd7e 100644 --- a/entgql/internal/todo/todo_test.go +++ b/entgql/internal/todo/todo_test.go @@ -2260,6 +2260,168 @@ func (r *queryRecorder) Query(ctx context.Context, query string, args, v interfa return r.Driver.Query(ctx, query, args, v) } +func TestReduceQueryComplexity(t *testing.T) { + ctx := context.Background() + drv, err := sql.Open(dialect.SQLite, fmt.Sprintf("file:%s?mode=memory&cache=shared&_fk=1", t.Name())) + require.NoError(t, err) + rec := &queryRecorder{Driver: drv} + ec := enttest.NewClient(t, + enttest.WithOptions(ent.Driver(rec)), + enttest.WithMigrateOptions(migrate.WithGlobalUniqueID(true)), + ) + var ( + // language=GraphQL + query = `query Todo($id: ID!) { + node(id: $id) { + ... on Todo { + text + children (first: 10) { + edges { + node { + text + } + } + } + } + } + }` + gqlc = client.New(handler.NewDefaultServer(gen.NewSchema(ec))) + ) + t1 := ec.Todo.Create().SetText("t1").SetStatus(todo.StatusInProgress).SaveX(ctx) + rec.reset() + require.NoError(t, gqlc.Post(query, new(any), client.Var("id", t1.ID))) + require.Equal(t, []string{ + // Node mapping (cached). + "SELECT `type` FROM `ent_types` ORDER BY `id` ASC", + // Top-level todo. + "SELECT `todos`.`id`, `todos`.`text` FROM `todos` WHERE `todos`.`id` = ? LIMIT 2", + // Children todos (without CTE). + "SELECT `todos`.`id`, `todos`.`text`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`todo_children` IN (?) ORDER BY `todos`.`id` LIMIT 11", + }, rec.queries) + + // language=GraphQL + query = `query Todos($ids: [ID!]!) { + todos: nodes (ids: $ids) { + ... on Todo { + text + children (first: 10) { + edges { + node { + text + } + } + } + } + } + }` + rec.reset() + require.NoError(t, gqlc.Post(query, new(any), client.Var("ids", []int{t1.ID}))) + // A single ID is implemented by the `node` query. + require.Equal(t, []string{ + // Top-level todo. + "SELECT `todos`.`id`, `todos`.`text` FROM `todos` WHERE `todos`.`id` = ? LIMIT 2", + // Children todos (without CTE). + "SELECT `todos`.`id`, `todos`.`text`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`todo_children` IN (?) ORDER BY `todos`.`id` LIMIT 11", + }, rec.queries) + + rec.reset() + require.NoError(t, gqlc.Post(query, new(any), client.Var("ids", []int{t1.ID, t1.ID}))) + require.Equal(t, []string{ + // Top-level todo. + "SELECT `todos`.`id`, `todos`.`text` FROM `todos` WHERE `todos`.`id` IN (?, ?)", + // Children todos (with CTE). + "WITH `src_query` AS (SELECT `todos`.`id`, `todos`.`text`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`todo_children` IN (?)), `limited_query` AS (SELECT *, (ROW_NUMBER() OVER (PARTITION BY `todo_children` ORDER BY `id` ASC)) AS `row_number` FROM `src_query`) SELECT `id`, `text`, `project_todos`, `todo_children`, `todo_secret` FROM `limited_query` AS `todos` WHERE `todos`.`row_number` <= ?", + }, rec.queries) + + // Propagate uniqueness to one-child edges. + // language=GraphQL + query = `query Todo($id: ID!) { + node(id: $id) { + ... on Todo { + parent { + text + children (first: 5) { + edges { + node { + text + } + } + } + } + category { + text + todos (first: 10) { + edges { + node { + text + } + } + } + } + } + } + }` + ec.Todo.Create().SetText("t0").SetStatus(todo.StatusInProgress).AddChildren(t1).SaveX(ctx) + ec.Category.Create().AddTodos(t1).SetText("c0").SetStatus(category.StatusEnabled).SaveX(ctx) + rec.reset() + require.NoError(t, gqlc.Post(query, new(any), client.Var("id", t1.ID))) + require.Equal(t, []string{ + // Top-level todo. + "SELECT `todos`.`id`, `todos`.`category_id`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`id` = ? LIMIT 2", + // Parent todo. + "SELECT `todos`.`id`, `todos`.`text` FROM `todos` WHERE `todos`.`id` IN (?)", + // Parent children. + "SELECT `todos`.`id`, `todos`.`text`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`todo_children` IN (?) ORDER BY `todos`.`id` LIMIT 6", + // Category. + "SELECT `categories`.`id`, `categories`.`text` FROM `categories` WHERE `categories`.`id` IN (?)", + // Category todos. + "SELECT `todos`.`id`, `todos`.`text`, `todos`.`category_id`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`category_id` IN (?) ORDER BY `todos`.`id` LIMIT 11", + }, rec.queries) + + // Same as above, but with multiple IDs. + // language=GraphQL + query = `query Todo($id: ID!) { + nodes(ids: [$id, $id]) { + ... on Todo { + parent { + text + children (first: 5) { + edges { + node { + text + } + } + } + } + category { + text + todos (first: 10) { + edges { + node { + text + } + } + } + } + } + } + }` + rec.reset() + require.NoError(t, gqlc.Post(query, new(any), client.Var("id", t1.ID))) + require.Equal(t, []string{ + // Root nodes. + "SELECT `todos`.`id`, `todos`.`category_id`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`id` IN (?, ?)", + // Their parents (2 max). + "SELECT `todos`.`id`, `todos`.`text` FROM `todos` WHERE `todos`.`id` IN (?)", + // 5 children for each parent. + "WITH `src_query` AS (SELECT `todos`.`id`, `todos`.`text`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`todo_children` IN (?)), `limited_query` AS (SELECT *, (ROW_NUMBER() OVER (PARTITION BY `todo_children` ORDER BY `id` ASC)) AS `row_number` FROM `src_query`) SELECT `id`, `text`, `project_todos`, `todo_children`, `todo_secret` FROM `limited_query` AS `todos` WHERE `todos`.`row_number` <= ?", + // Category. + "SELECT `categories`.`id`, `categories`.`text` FROM `categories` WHERE `categories`.`id` IN (?)", + // 10 todos for each category. + "WITH `src_query` AS (SELECT `todos`.`id`, `todos`.`text`, `todos`.`category_id`, `todos`.`project_todos`, `todos`.`todo_children`, `todos`.`todo_secret` FROM `todos` WHERE `todos`.`category_id` IN (?)), `limited_query` AS (SELECT *, (ROW_NUMBER() OVER (PARTITION BY `category_id` ORDER BY `id` ASC)) AS `row_number` FROM `src_query`) SELECT `id`, `text`, `category_id`, `project_todos`, `todo_children`, `todo_secret` FROM `limited_query` AS `todos` WHERE `todos`.`row_number` <= ?", + }, rec.queries) +} + func TestFieldSelection(t *testing.T) { ctx := context.Background() drv, err := sql.Open(dialect.SQLite, fmt.Sprintf("file:%s?mode=memory&cache=shared&_fk=1", t.Name())) diff --git a/entgql/internal/todofed/ent/category/where.go b/entgql/internal/todofed/ent/category/where.go index 015f99487..3f9525288 100644 --- a/entgql/internal/todofed/ent/category/where.go +++ b/entgql/internal/todofed/ent/category/where.go @@ -375,32 +375,15 @@ func HasTodosWith(preds ...predicate.Todo) predicate.Category { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Category(sql.NotPredicates(p)) } diff --git a/entgql/internal/todofed/ent/category_create.go b/entgql/internal/todofed/ent/category_create.go index 7c4253f65..61e4b9735 100644 --- a/entgql/internal/todofed/ent/category_create.go +++ b/entgql/internal/todofed/ent/category_create.go @@ -110,7 +110,7 @@ func (cc *CategoryCreate) Mutation() *CategoryMutation { // Save creates the Category in the database. func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) + return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -225,11 +225,15 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { // CategoryCreateBulk is the builder for creating many Category entities in bulk. type CategoryCreateBulk struct { config + err error builders []*CategoryCreate } // Save creates the Category entities in the database. func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error) { + if ccb.err != nil { + return nil, ccb.err + } specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) nodes := make([]*Category, len(ccb.builders)) mutators := make([]Mutator, len(ccb.builders)) diff --git a/entgql/internal/todofed/ent/category_delete.go b/entgql/internal/todofed/ent/category_delete.go index ffafddbb2..75b7a41d6 100644 --- a/entgql/internal/todofed/ent/category_delete.go +++ b/entgql/internal/todofed/ent/category_delete.go @@ -41,7 +41,7 @@ func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (cd *CategoryDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) + return withHooks(ctx, cd.sqlExec, cd.mutation, cd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todofed/ent/category_update.go b/entgql/internal/todofed/ent/category_update.go index 9edf9a0a4..05d1c57c9 100644 --- a/entgql/internal/todofed/ent/category_update.go +++ b/entgql/internal/todofed/ent/category_update.go @@ -51,12 +51,28 @@ func (cu *CategoryUpdate) SetText(s string) *CategoryUpdate { return cu } +// SetNillableText sets the "text" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableText(s *string) *CategoryUpdate { + if s != nil { + cu.SetText(*s) + } + return cu +} + // SetStatus sets the "status" field. func (cu *CategoryUpdate) SetStatus(c category.Status) *CategoryUpdate { cu.mutation.SetStatus(c) return cu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableStatus(c *category.Status) *CategoryUpdate { + if c != nil { + cu.SetStatus(*c) + } + return cu +} + // SetConfig sets the "config" field. func (cu *CategoryUpdate) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdate { cu.mutation.SetConfig(sc) @@ -184,7 +200,7 @@ func (cu *CategoryUpdate) RemoveTodos(t ...*Todo) *CategoryUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) + return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -348,12 +364,28 @@ func (cuo *CategoryUpdateOne) SetText(s string) *CategoryUpdateOne { return cuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableText(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetText(*s) + } + return cuo +} + // SetStatus sets the "status" field. func (cuo *CategoryUpdateOne) SetStatus(c category.Status) *CategoryUpdateOne { cuo.mutation.SetStatus(c) return cuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableStatus(c *category.Status) *CategoryUpdateOne { + if c != nil { + cuo.SetStatus(*c) + } + return cuo +} + // SetConfig sets the "config" field. func (cuo *CategoryUpdateOne) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdateOne { cuo.mutation.SetConfig(sc) @@ -494,7 +526,7 @@ func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUp // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) + return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todofed/ent/client.go b/entgql/internal/todofed/ent/client.go index 076b18a88..23f049ec1 100644 --- a/entgql/internal/todofed/ent/client.go +++ b/entgql/internal/todofed/ent/client.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entgql/internal/todofed/ent/migrate" "entgo.io/ent" @@ -50,9 +51,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -82,6 +81,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -129,11 +135,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -257,6 +266,21 @@ func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreate return &CategoryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CategoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CategoryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Category. func (c *CategoryClient) Update() *CategoryUpdate { mutation := newCategoryMutation(c.config, OpUpdate) @@ -391,6 +415,21 @@ func (c *TodoClient) CreateBulk(builders ...*TodoCreate) *TodoCreateBulk { return &TodoCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TodoClient) MapCreateBulk(slice any, setFunc func(*TodoCreate, int)) *TodoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TodoCreateBulk{err: fmt.Errorf("calling to TodoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TodoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TodoCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Todo. func (c *TodoClient) Update() *TodoUpdate { mutation := newTodoMutation(c.config, OpUpdate) @@ -573,6 +612,21 @@ func (c *VerySecretClient) CreateBulk(builders ...*VerySecretCreate) *VerySecret return &VerySecretCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *VerySecretClient) MapCreateBulk(slice any, setFunc func(*VerySecretCreate, int)) *VerySecretCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VerySecretCreateBulk{err: fmt.Errorf("calling to VerySecretClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VerySecretCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VerySecretCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for VerySecret. func (c *VerySecretClient) Update() *VerySecretUpdate { mutation := newVerySecretMutation(c.config, OpUpdate) diff --git a/entgql/internal/todofed/ent/gql_collection.go b/entgql/internal/todofed/ent/gql_collection.go index c981be046..476afead9 100644 --- a/entgql/internal/todofed/ent/gql_collection.go +++ b/entgql/internal/todofed/ent/gql_collection.go @@ -22,7 +22,6 @@ import ( "entgo.io/contrib/entgql" "entgo.io/contrib/entgql/internal/todofed/ent/category" "entgo.io/contrib/entgql/internal/todofed/ent/todo" - "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" ) @@ -32,13 +31,13 @@ func (c *CategoryQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return c, nil } - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := c.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return c, nil } -func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (c *CategoryQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -47,13 +46,14 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "todos": var ( alias = field.Alias path = append(path, alias) query = (&TodoClient{config: c.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, todoImplementors)...); err != nil { return err } c.WithNamedTodos(alias, func(wq *TodoQuery) { @@ -106,7 +106,7 @@ type categoryPaginateArgs struct { opts []CategoryPaginateOption } -func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { +func newCategoryPaginateArgs(rv map[string]any) *categoryPaginateArgs { args := &categoryPaginateArgs{} if rv == nil { return args @@ -119,7 +119,7 @@ func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: + case map[string]any: var ( err1, err2 error order = &CategoryOrder{Field: &CategoryOrderField{}, Direction: entgql.OrderDirectionAsc} @@ -148,13 +148,13 @@ func (t *TodoQuery) CollectFields(ctx context.Context, satisfies ...string) (*To if fc == nil { return t, nil } - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := t.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return t, nil } -func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (t *TodoQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -163,35 +163,38 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "parent": var ( alias = field.Alias path = append(path, alias) query = (&TodoClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, todoImplementors)...); err != nil { return err } t.withParent = query + case "children": var ( alias = field.Alias path = append(path, alias) query = (&TodoClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, todoImplementors)...); err != nil { return err } t.WithNamedChildren(alias, func(wq *TodoQuery) { *wq = *query }) + case "category": var ( alias = field.Alias path = append(path, alias) query = (&CategoryClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, categoryImplementors)...); err != nil { return err } t.withCategory = query @@ -237,7 +240,7 @@ type todoPaginateArgs struct { opts []TodoPaginateOption } -func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { +func newTodoPaginateArgs(rv map[string]any) *todoPaginateArgs { args := &todoPaginateArgs{} if rv == nil { return args @@ -250,7 +253,7 @@ func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: + case map[string]any: var ( err1, err2 error order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} @@ -282,35 +285,18 @@ const ( whereField = "where" ) -func fieldArgs(ctx context.Context, whereInput interface{}, path ...string) map[string]interface{} { - fc := graphql.GetFieldContext(ctx) - if fc == nil { +func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { + field := collectedField(ctx, path...) + if field == nil || field.Arguments == nil { return nil } oc := graphql.GetOperationContext(ctx) - for _, name := range path { - var field *graphql.CollectedField - for _, f := range graphql.CollectFields(oc, fc.Field.Selections, nil) { - if f.Alias == name { - field = &f - break - } - } - if field == nil { - return nil - } - cf, err := fc.Child(ctx, *field) - if err != nil { - args := field.ArgumentMap(oc.Variables) - return unmarshalArgs(ctx, whereInput, args) - } - fc = cf - } - return fc.Args + args := field.ArgumentMap(oc.Variables) + return unmarshalArgs(ctx, whereInput, args) } // unmarshalArgs allows extracting the field arguments from their raw representation. -func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string]interface{}) map[string]interface{} { +func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{limitField, offsetField} { v, ok := args[k] if !ok { @@ -330,39 +316,17 @@ func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string] return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } diff --git a/entgql/internal/todofed/ent/gql_node.go b/entgql/internal/todofed/ent/gql_node.go index 3a2a75b6b..6d4cdbde6 100644 --- a/entgql/internal/todofed/ent/gql_node.go +++ b/entgql/internal/todofed/ent/gql_node.go @@ -38,11 +38,15 @@ type Noder interface { IsNode() } +var categoryImplementors = []string{"Category", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *Category) IsNode() {} +func (*Category) IsNode() {} + +var todoImplementors = []string{"Todo", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Todo) IsNode() {} +func (*Todo) IsNode() {} var errNodeInvalidID = &NotFoundError{"node"} @@ -105,27 +109,21 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) case category.Table: query := c.Category.Query(). Where(category.ID(id)) - query, err := query.CollectFields(ctx, "Category") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, categoryImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case todo.Table: query := c.Todo.Query(). Where(todo.ID(id)) - query, err := query.CollectFields(ctx, "Todo") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, todoImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) } @@ -202,7 +200,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case category.Table: query := c.Category.Query(). Where(category.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Category") + query, err := query.CollectFields(ctx, categoryImplementors...) if err != nil { return nil, err } @@ -218,7 +216,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case todo.Table: query := c.Todo.Query(). Where(todo.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Todo") + query, err := query.CollectFields(ctx, todoImplementors...) if err != nil { return nil, err } diff --git a/entgql/internal/todofed/ent/gql_pagination.go b/entgql/internal/todofed/ent/gql_pagination.go index e4ae78ebe..148a43958 100644 --- a/entgql/internal/todofed/ent/gql_pagination.go +++ b/entgql/internal/todofed/ent/gql_pagination.go @@ -332,12 +332,12 @@ func (c *CategoryQuery) PaginateLimitOffset( c.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -370,7 +370,9 @@ func (c *CategoryQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = c.Clone().Count(ctx); err != nil { + c := c.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -383,16 +385,17 @@ func (c *CategoryQuery) Paginate( if c, err = pager.applyCursors(c, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { c.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -713,12 +716,12 @@ func (t *TodoQuery) PaginateLimitOffset( t.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -751,7 +754,9 @@ func (t *TodoQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = t.Clone().Count(ctx); err != nil { + c := t.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -764,16 +769,17 @@ func (t *TodoQuery) Paginate( if t, err = pager.applyCursors(t, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { t.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } diff --git a/entgql/internal/todofed/ent/runtime/runtime.go b/entgql/internal/todofed/ent/runtime/runtime.go index 37df9b5f1..7619393b5 100644 --- a/entgql/internal/todofed/ent/runtime/runtime.go +++ b/entgql/internal/todofed/ent/runtime/runtime.go @@ -19,6 +19,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entgql/internal/todofed/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entgql/internal/todofed/ent/todo/where.go b/entgql/internal/todofed/ent/todo/where.go index b7a831a13..95e80ce42 100644 --- a/entgql/internal/todofed/ent/todo/where.go +++ b/entgql/internal/todofed/ent/todo/where.go @@ -398,32 +398,15 @@ func HasSecretWith(preds ...predicate.VerySecret) predicate.Todo { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Todo(sql.NotPredicates(p)) } diff --git a/entgql/internal/todofed/ent/todo_create.go b/entgql/internal/todofed/ent/todo_create.go index 787711b33..dfe9864b3 100644 --- a/entgql/internal/todofed/ent/todo_create.go +++ b/entgql/internal/todofed/ent/todo_create.go @@ -162,7 +162,7 @@ func (tc *TodoCreate) Mutation() *TodoMutation { // Save creates the Todo in the database. func (tc *TodoCreate) Save(ctx context.Context) (*Todo, error) { tc.defaults() - return withHooks[*Todo, TodoMutation](ctx, tc.sqlSave, tc.mutation, tc.hooks) + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -342,11 +342,15 @@ func (tc *TodoCreate) createSpec() (*Todo, *sqlgraph.CreateSpec) { // TodoCreateBulk is the builder for creating many Todo entities in bulk. type TodoCreateBulk struct { config + err error builders []*TodoCreate } // Save creates the Todo entities in the database. func (tcb *TodoCreateBulk) Save(ctx context.Context) ([]*Todo, error) { + if tcb.err != nil { + return nil, tcb.err + } specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) nodes := make([]*Todo, len(tcb.builders)) mutators := make([]Mutator, len(tcb.builders)) diff --git a/entgql/internal/todofed/ent/todo_delete.go b/entgql/internal/todofed/ent/todo_delete.go index d1441ca41..ed37209d2 100644 --- a/entgql/internal/todofed/ent/todo_delete.go +++ b/entgql/internal/todofed/ent/todo_delete.go @@ -41,7 +41,7 @@ func (td *TodoDelete) Where(ps ...predicate.Todo) *TodoDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (td *TodoDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, td.sqlExec, td.mutation, td.hooks) + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todofed/ent/todo_update.go b/entgql/internal/todofed/ent/todo_update.go index 5c507d243..148ec3f60 100644 --- a/entgql/internal/todofed/ent/todo_update.go +++ b/entgql/internal/todofed/ent/todo_update.go @@ -49,6 +49,14 @@ func (tu *TodoUpdate) SetStatus(t todo.Status) *TodoUpdate { return tu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableStatus(t *todo.Status) *TodoUpdate { + if t != nil { + tu.SetStatus(*t) + } + return tu +} + // SetPriority sets the "priority" field. func (tu *TodoUpdate) SetPriority(i int) *TodoUpdate { tu.mutation.ResetPriority() @@ -76,6 +84,14 @@ func (tu *TodoUpdate) SetText(s string) *TodoUpdate { return tu } +// SetNillableText sets the "text" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableText(s *string) *TodoUpdate { + if s != nil { + tu.SetText(*s) + } + return tu +} + // SetBlob sets the "blob" field. func (tu *TodoUpdate) SetBlob(b []byte) *TodoUpdate { tu.mutation.SetBlob(b) @@ -206,7 +222,7 @@ func (tu *TodoUpdate) ClearSecret() *TodoUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TodoUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, tu.sqlSave, tu.mutation, tu.hooks) + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -434,6 +450,14 @@ func (tuo *TodoUpdateOne) SetStatus(t todo.Status) *TodoUpdateOne { return tuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableStatus(t *todo.Status) *TodoUpdateOne { + if t != nil { + tuo.SetStatus(*t) + } + return tuo +} + // SetPriority sets the "priority" field. func (tuo *TodoUpdateOne) SetPriority(i int) *TodoUpdateOne { tuo.mutation.ResetPriority() @@ -461,6 +485,14 @@ func (tuo *TodoUpdateOne) SetText(s string) *TodoUpdateOne { return tuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableText(s *string) *TodoUpdateOne { + if s != nil { + tuo.SetText(*s) + } + return tuo +} + // SetBlob sets the "blob" field. func (tuo *TodoUpdateOne) SetBlob(b []byte) *TodoUpdateOne { tuo.mutation.SetBlob(b) @@ -604,7 +636,7 @@ func (tuo *TodoUpdateOne) Select(field string, fields ...string) *TodoUpdateOne // Save executes the query and returns the updated Todo entity. func (tuo *TodoUpdateOne) Save(ctx context.Context) (*Todo, error) { - return withHooks[*Todo, TodoMutation](ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todofed/ent/verysecret/where.go b/entgql/internal/todofed/ent/verysecret/where.go index 6db4bfabe..04d1441f7 100644 --- a/entgql/internal/todofed/ent/verysecret/where.go +++ b/entgql/internal/todofed/ent/verysecret/where.go @@ -138,32 +138,15 @@ func PasswordContainsFold(v string) predicate.VerySecret { // And groups predicates with the AND operator between them. func And(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.VerySecret(sql.NotPredicates(p)) } diff --git a/entgql/internal/todofed/ent/verysecret_create.go b/entgql/internal/todofed/ent/verysecret_create.go index cc8236027..ecb18239a 100644 --- a/entgql/internal/todofed/ent/verysecret_create.go +++ b/entgql/internal/todofed/ent/verysecret_create.go @@ -46,7 +46,7 @@ func (vsc *VerySecretCreate) Mutation() *VerySecretMutation { // Save creates the VerySecret in the database. func (vsc *VerySecretCreate) Save(ctx context.Context) (*VerySecret, error) { - return withHooks[*VerySecret, VerySecretMutation](ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) + return withHooks(ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -112,11 +112,15 @@ func (vsc *VerySecretCreate) createSpec() (*VerySecret, *sqlgraph.CreateSpec) { // VerySecretCreateBulk is the builder for creating many VerySecret entities in bulk. type VerySecretCreateBulk struct { config + err error builders []*VerySecretCreate } // Save creates the VerySecret entities in the database. func (vscb *VerySecretCreateBulk) Save(ctx context.Context) ([]*VerySecret, error) { + if vscb.err != nil { + return nil, vscb.err + } specs := make([]*sqlgraph.CreateSpec, len(vscb.builders)) nodes := make([]*VerySecret, len(vscb.builders)) mutators := make([]Mutator, len(vscb.builders)) diff --git a/entgql/internal/todofed/ent/verysecret_delete.go b/entgql/internal/todofed/ent/verysecret_delete.go index d9ed1594f..cac66d33b 100644 --- a/entgql/internal/todofed/ent/verysecret_delete.go +++ b/entgql/internal/todofed/ent/verysecret_delete.go @@ -41,7 +41,7 @@ func (vsd *VerySecretDelete) Where(ps ...predicate.VerySecret) *VerySecretDelete // Exec executes the deletion query and returns how many vertices were deleted. func (vsd *VerySecretDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) + return withHooks(ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todofed/ent/verysecret_update.go b/entgql/internal/todofed/ent/verysecret_update.go index 954001a16..7446d8852 100644 --- a/entgql/internal/todofed/ent/verysecret_update.go +++ b/entgql/internal/todofed/ent/verysecret_update.go @@ -47,6 +47,14 @@ func (vsu *VerySecretUpdate) SetPassword(s string) *VerySecretUpdate { return vsu } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsu *VerySecretUpdate) SetNillablePassword(s *string) *VerySecretUpdate { + if s != nil { + vsu.SetPassword(*s) + } + return vsu +} + // Mutation returns the VerySecretMutation object of the builder. func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { return vsu.mutation @@ -54,7 +62,7 @@ func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (vsu *VerySecretUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) + return withHooks(ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -117,6 +125,14 @@ func (vsuo *VerySecretUpdateOne) SetPassword(s string) *VerySecretUpdateOne { return vsuo } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsuo *VerySecretUpdateOne) SetNillablePassword(s *string) *VerySecretUpdateOne { + if s != nil { + vsuo.SetPassword(*s) + } + return vsuo +} + // Mutation returns the VerySecretMutation object of the builder. func (vsuo *VerySecretUpdateOne) Mutation() *VerySecretMutation { return vsuo.mutation @@ -137,7 +153,7 @@ func (vsuo *VerySecretUpdateOne) Select(field string, fields ...string) *VerySec // Save executes the query and returns the updated VerySecret entity. func (vsuo *VerySecretUpdateOne) Save(ctx context.Context) (*VerySecret, error) { - return withHooks[*VerySecret, VerySecretMutation](ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) + return withHooks(ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todofed/entity.resolvers.go b/entgql/internal/todofed/entity.resolvers.go index 1822b5b12..ee83a859a 100644 --- a/entgql/internal/todofed/entity.resolvers.go +++ b/entgql/internal/todofed/entity.resolvers.go @@ -16,6 +16,7 @@ package todofed // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" @@ -23,6 +24,7 @@ import ( "entgo.io/contrib/entgql/internal/todofed/ent" ) +// FindTodoByID is the resolver for the findTodoByID field. func (r *entityResolver) FindTodoByID(ctx context.Context, id int) (*ent.Todo, error) { todo, err := r.client.Todo.Get(ctx, id) return todo, ent.MaskNotFound(err) diff --git a/entgql/internal/todofed/generated.go b/entgql/internal/todofed/generated.go index 9503efd24..fe8eaea73 100644 --- a/entgql/internal/todofed/generated.go +++ b/entgql/internal/todofed/generated.go @@ -5,6 +5,7 @@ package todofed import ( "bytes" "context" + "embed" "errors" "fmt" "strconv" @@ -28,6 +29,7 @@ import ( // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ + schema: cfg.Schema, resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, @@ -35,6 +37,7 @@ func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { } type Config struct { + Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot @@ -124,17 +127,21 @@ type QueryResolver interface { } type executableSchema struct { + schema *ast.Schema resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} + ec := executionContext{nil, e, 0, 0, nil} _ = ec switch typeName + "." + field { @@ -377,7 +384,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputCategoryConfigInput, ec.unmarshalInputTodoInput, @@ -388,18 +395,33 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { - if !first { - return nil + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext } + + return &response } case ast.Mutation: return func(ctx context.Context) *graphql.Response { @@ -425,131 +447,65 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { type executionContext struct { *graphql.OperationContext *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } -var sources = []*ast.Source{ - {Name: "todo.graphql", Input: `interface Node { - id: ID! -} - -type CategoryConfig { - maxMembers: Int -} - -input CategoryConfigInput { - maxMembers: Int -} - -enum CategoryStatus { - ENABLED - DISABLED -} - -enum Status { - IN_PROGRESS - COMPLETED -} - -scalar Time -scalar Duration -scalar Uint64 - -type Todo implements Node @key(fields: "id") { - id: ID! - createdAt: Time - status: Status! - priority: Int! - text: String! - parent: Todo - children: [Todo!] - category: Category -} - -type Category implements Node { - id: ID! - text: String! - strings: [String] -} - -input TodoInput { - status: Status! = IN_PROGRESS - priority: Int - text: String! - parent: ID - category_id: ID -} - -scalar Cursor - -type PageInfo { - hasNextPage: Boolean! - hasPreviousPage: Boolean! - startCursor: Cursor - endCursor: Cursor -} - -type TodoList { - totalCount: Int! - items: [Todo]! -} - -type TodoEdge { - node: Todo - cursor: Cursor! -} - -enum OrderDirection { - ASC - DESC -} +//go:embed "todo.graphql" +var sourcesFS embed.FS -enum TodoOrderField { - CREATED_AT - PRIORITY - STATUS - TEXT -} - -input TodoOrder { - direction: OrderDirection! - field: TodoOrderField -} - -type Query { - node(id: ID!): Node - nodes(ids: [ID!]!): [Node]! - todos(after: Cursor, first: Int, before: Cursor, last: Int, orderBy: TodoOrder): TodoList +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) } -type Mutation { - createTodo(input: TodoInput!): Todo! - clearTodos: Int! -} -`, BuiltIn: false}, +var sources = []*ast.Source{ + {Name: "todo.graphql", Input: sourceData("todo.graphql"), BuiltIn: false}, {Name: "federation/directives.graphql", Input: ` - scalar _Any - scalar _FieldSet - - directive @external on FIELD_DEFINITION + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE directive @requires(fields: _FieldSet!) on FIELD_DEFINITION directive @provides(fields: _FieldSet!) on FIELD_DEFINITION directive @extends on OBJECT | INTERFACE - - directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE + directive @external on FIELD_DEFINITION + scalar _Any + scalar _FieldSet `, BuiltIn: true}, {Name: "federation/entity.graphql", Input: ` # a union of all types that use the @key directive @@ -994,7 +950,7 @@ func (ec *executionContext) fieldContext_Entity_findTodoByID(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Entity_findTodoByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -1067,7 +1023,7 @@ func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -1333,7 +1289,7 @@ func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -1388,7 +1344,7 @@ func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -1446,7 +1402,7 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -1501,7 +1457,7 @@ func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, fi ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -1623,7 +1579,7 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3738,7 +3694,7 @@ func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3926,7 +3882,7 @@ func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4097,16 +4053,20 @@ func (ec *executionContext) unmarshalInputCategoryConfigInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"maxMembers"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "maxMembers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("maxMembers")) - it.MaxMembers, err = ec.unmarshalOInt2int(ctx, v) + data, err := ec.unmarshalOInt2int(ctx, v) if err != nil { return it, err } + it.MaxMembers = data } } @@ -4124,48 +4084,48 @@ func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj int asMap["status"] = "IN_PROGRESS" } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "parent", "category_id"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalNStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodofedᚋentᚋtodoᚐStatus(ctx, v) + data, err := ec.unmarshalNStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodofedᚋentᚋtodoᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "parent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parent")) - it.Parent, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.Parent = data case "category_id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("category_id")) - it.CategoryID, err = ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖint(ctx, v) if err != nil { return it, err } + it.CategoryID = data } } @@ -4179,24 +4139,27 @@ func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj int asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalOTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodofedᚋentᚐTodoOrderField(ctx, v) + data, err := ec.unmarshalOTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodofedᚋentᚐTodoOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -4250,38 +4213,45 @@ var categoryImplementors = []string{"Category", "Node"} func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, obj *ent.Category) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Category") case "id": - out.Values[i] = ec._Category_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "text": - out.Values[i] = ec._Category_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "strings": - out.Values[i] = ec._Category_strings(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4289,24 +4259,35 @@ var categoryConfigImplementors = []string{"CategoryConfig"} func (ec *executionContext) _CategoryConfig(ctx context.Context, sel ast.SelectionSet, obj *schematype.CategoryConfig) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryConfigImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryConfig") case "maxMembers": - out.Values[i] = ec._CategoryConfig_maxMembers(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4319,7 +4300,7 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -4332,7 +4313,7 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g case "findTodoByID": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4340,26 +4321,37 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g }() res = ec._Entity_findTodoByID(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4372,7 +4364,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -4383,31 +4375,39 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "clearTodos": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_clearTodos(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4415,42 +4415,47 @@ var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4463,7 +4468,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -4476,7 +4481,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "node": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4487,16 +4492,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nodes": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4504,22 +4508,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_nodes(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4530,16 +4533,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_entities": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4547,22 +4549,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query__entities(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_service": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4570,38 +4571,45 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query__service(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) - case "__schema": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4609,48 +4617,39 @@ var todoImplementors = []string{"Todo", "Node", "_Entity"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *ent.Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Todo_createdAt(ctx, field, obj) - case "status": - out.Values[i] = ec._Todo_status(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "priority": - out.Values[i] = ec._Todo_priority(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "parent": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4660,14 +4659,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "children": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4677,14 +4692,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "category": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4694,18 +4725,46 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4713,31 +4772,40 @@ var todoEdgeImplementors = []string{"TodoEdge"} func (ec *executionContext) _TodoEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.TodoEdge) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoEdgeImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("TodoEdge") case "node": - out.Values[i] = ec._TodoEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._TodoEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4745,34 +4813,43 @@ var todoListImplementors = []string{"TodoList"} func (ec *executionContext) _TodoList(ctx context.Context, sel ast.SelectionSet, obj *ent.TodoList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("TodoList") case "totalCount": - out.Values[i] = ec._TodoList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._TodoList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4780,24 +4857,35 @@ var _ServiceImplementors = []string{"_Service"} func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("_Service") case "sdl": - out.Values[i] = ec.__Service_sdl(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4805,52 +4893,55 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isRepeatable": - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4858,42 +4949,47 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4901,56 +4997,57 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -4958,42 +5055,47 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -5001,53 +5103,54 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "description": - out.Values[i] = ec.___Schema_description(ctx, field, obj) - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -5055,63 +5158,56 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - case "specifiedByURL": - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } diff --git a/entgql/internal/todofed/gqlgen.yml b/entgql/internal/todofed/gqlgen.yml index ff92862fe..7338807dc 100644 --- a/entgql/internal/todofed/gqlgen.yml +++ b/entgql/internal/todofed/gqlgen.yml @@ -21,6 +21,8 @@ autobind: - entgo.io/contrib/entgql/internal/todofed/ent/todo - entgo.io/contrib/entgql/internal/todo/ent/schema/customstruct +# Disable the generated getters for all models and interfaces. +omit_getters: true models: ID: model: diff --git a/entgql/internal/todofed/models_gen.go b/entgql/internal/todofed/models_gen.go index ba7c3e00d..74fa65bbd 100644 --- a/entgql/internal/todofed/models_gen.go +++ b/entgql/internal/todofed/models_gen.go @@ -8,8 +8,8 @@ import ( type TodoInput struct { Status todo.Status `json:"status"` - Priority *int `json:"priority"` + Priority *int `json:"priority,omitempty"` Text string `json:"text"` - Parent *int `json:"parent"` - CategoryID *int `json:"category_id"` + Parent *int `json:"parent,omitempty"` + CategoryID *int `json:"category_id,omitempty"` } diff --git a/entgql/internal/todofed/server/server.go b/entgql/internal/todofed/server/server.go index ceabb985d..bb744e046 100644 --- a/entgql/internal/todofed/server/server.go +++ b/entgql/internal/todofed/server/server.go @@ -11,11 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package main import ( "context" "net/http" + "time" "entgo.io/contrib/entgql" "entgo.io/contrib/entgql/internal/todofed" @@ -65,7 +67,11 @@ func main() { http.Handle("/query", srv) log.Info("listening on", zap.String("address", cli.Addr)) - if err := http.ListenAndServe(cli.Addr, nil); err != nil { + server := &http.Server{ + Addr: cli.Addr, + ReadHeaderTimeout: 30 * time.Second, + } + if err := server.ListenAndServe(); err != nil { log.Error("http server terminated", zap.Error(err)) } } diff --git a/entgql/internal/todofed/todo.resolvers.go b/entgql/internal/todofed/todo.resolvers.go index a48f5c669..b97867e32 100644 --- a/entgql/internal/todofed/todo.resolvers.go +++ b/entgql/internal/todofed/todo.resolvers.go @@ -16,6 +16,7 @@ package todofed // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" @@ -24,6 +25,7 @@ import ( "entgo.io/contrib/entgql/internal/todofed/ent" ) +// CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo(ctx context.Context, input TodoInput) (*ent.Todo, error) { client := ent.FromContext(ctx) return client.Todo. @@ -35,6 +37,7 @@ func (r *mutationResolver) CreateTodo(ctx context.Context, input TodoInput) (*en Save(ctx) } +// ClearTodos is the resolver for the clearTodos field. func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { client := ent.FromContext(ctx) return client.Todo. @@ -42,14 +45,17 @@ func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { Exec(ctx) } +// Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id int) (ent.Noder, error) { return r.client.Noder(ctx, id) } +// Nodes is the resolver for the nodes field. func (r *queryResolver) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) { return r.client.Noders(ctx, ids) } +// Todos is the resolver for the todos field. func (r *queryResolver) Todos(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.TodoOrder) (*ent.TodoList, error) { return r.client.Todo.Query(). Paginate(ctx, after, first, before, last, diff --git a/entgql/internal/todogotype/ent.resolvers.go b/entgql/internal/todogotype/ent.resolvers.go index 2f5cb4ef0..940b3c01e 100644 --- a/entgql/internal/todogotype/ent.resolvers.go +++ b/entgql/internal/todogotype/ent.resolvers.go @@ -16,119 +16,173 @@ package todo // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" "fmt" + ent1 "entgo.io/contrib/entgql/internal/todo/ent" "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todogotype/ent" ) +// Types is the resolver for the types field. +func (r *categoryResolver) Types(ctx context.Context, obj *ent.Category) (*CategoryTypes, error) { + panic(fmt.Errorf("not implemented")) +} + +// ID is the resolver for the id field. +func (r *organizationResolver) ID(ctx context.Context, obj *ent1.Workspace) (string, error) { + panic(fmt.Errorf("not implemented")) +} + +// Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id string) (ent.Noder, error) { return r.client.Noder(ctx, id, ent.WithNodeType(nodeType)) } +// Nodes is the resolver for the nodes field. func (r *queryResolver) Nodes(ctx context.Context, ids []string) ([]ent.Noder, error) { return r.client.Noders(ctx, ids, ent.WithNodeType(nodeType)) } +// BillProducts is the resolver for the billProducts field. func (r *queryResolver) BillProducts(ctx context.Context) ([]*ent.BillProduct, error) { return r.client.BillProduct.Query().All(ctx) } +// Categories is the resolver for the categories field. func (r *queryResolver) Categories(ctx context.Context, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryList, error) { panic(fmt.Errorf("not implemented")) } +// Groups is the resolver for the groups field. func (r *queryResolver) Groups(ctx context.Context, limit *int, offset *int, where *ent.GroupWhereInput) (*ent.GroupList, error) { panic(fmt.Errorf("not implemented")) } +// OneToMany is the resolver for the oneToMany field. func (r *queryResolver) OneToMany(ctx context.Context, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) (*OneToManyList, error) { panic(fmt.Errorf("not implemented")) } -func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { +// Todos is the resolver for the todos field. +func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { panic(fmt.Errorf("not implemented")) } +// Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) { panic(fmt.Errorf("not implemented")) } +// Status is the resolver for the status field. func (r *todoResolver) Status(ctx context.Context, obj *ent.Todo) (todo.Status, error) { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *userResolver) Username(ctx context.Context, obj *ent.User) (string, error) { panic(fmt.Errorf("not implemented")) } +// RequiredMetadata is the resolver for the requiredMetadata field. +func (r *userResolver) RequiredMetadata(ctx context.Context, obj *ent.User) (map[string]interface{}, error) { + panic(fmt.Errorf("not implemented")) +} + +// Metadata is the resolver for the metadata field. func (r *userResolver) Metadata(ctx context.Context, obj *ent.User) (map[string]interface{}, error) { panic(fmt.Errorf("not implemented")) } +// Friends is the resolver for the friends field. func (r *userResolver) Friends(ctx context.Context, obj *ent.User, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) { panic(fmt.Errorf("not implemented")) } +// Friendships is the resolver for the friendships field. func (r *userResolver) Friendships(ctx context.Context, obj *ent.User, limit *int, offset *int, where *ent.FriendshipWhereInput) (*ent.FriendshipList, error) { panic(fmt.Errorf("not implemented")) } +// Types is the resolver for the types field. +func (r *createCategoryInputResolver) Types(ctx context.Context, obj *ent.CreateCategoryInput, data *CategoryTypesInput) error { + panic(fmt.Errorf("not implemented")) +} + +// Status is the resolver for the status field. func (r *createTodoInputResolver) Status(ctx context.Context, obj *ent.CreateTodoInput, data todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Status is the resolver for the status field. func (r *todoWhereInputResolver) Status(ctx context.Context, obj *ent.TodoWhereInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusNeq is the resolver for the statusNEQ field. func (r *todoWhereInputResolver) StatusNeq(ctx context.Context, obj *ent.TodoWhereInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusIn is the resolver for the statusIn field. func (r *todoWhereInputResolver) StatusIn(ctx context.Context, obj *ent.TodoWhereInput, data []todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusNotIn is the resolver for the statusNotIn field. func (r *todoWhereInputResolver) StatusNotIn(ctx context.Context, obj *ent.TodoWhereInput, data []todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Types is the resolver for the types field. +func (r *updateCategoryInputResolver) Types(ctx context.Context, obj *ent.UpdateCategoryInput, data *CategoryTypesInput) error { + panic(fmt.Errorf("not implemented")) +} + +// Status is the resolver for the status field. func (r *updateTodoInputResolver) Status(ctx context.Context, obj *ent.UpdateTodoInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *userWhereInputResolver) Username(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameNeq is the resolver for the usernameNEQ field. func (r *userWhereInputResolver) UsernameNeq(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameIn is the resolver for the usernameIn field. func (r *userWhereInputResolver) UsernameIn(ctx context.Context, obj *ent.UserWhereInput, data []string) error { panic(fmt.Errorf("not implemented")) } +// UsernameNotIn is the resolver for the usernameNotIn field. func (r *userWhereInputResolver) UsernameNotIn(ctx context.Context, obj *ent.UserWhereInput, data []string) error { panic(fmt.Errorf("not implemented")) } +// UsernameGt is the resolver for the usernameGT field. func (r *userWhereInputResolver) UsernameGt(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameGte is the resolver for the usernameGTE field. func (r *userWhereInputResolver) UsernameGte(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameLt is the resolver for the usernameLT field. func (r *userWhereInputResolver) UsernameLt(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameLte is the resolver for the usernameLTE field. func (r *userWhereInputResolver) UsernameLte(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } @@ -136,6 +190,9 @@ func (r *userWhereInputResolver) UsernameLte(ctx context.Context, obj *ent.UserW // Category returns CategoryResolver implementation. func (r *Resolver) Category() CategoryResolver { return &categoryResolver{r} } +// Organization returns OrganizationResolver implementation. +func (r *Resolver) Organization() OrganizationResolver { return &organizationResolver{r} } + // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } @@ -156,6 +213,11 @@ func (r *Resolver) CreateTodoInput() CreateTodoInputResolver { return &createTod // TodoWhereInput returns TodoWhereInputResolver implementation. func (r *Resolver) TodoWhereInput() TodoWhereInputResolver { return &todoWhereInputResolver{r} } +// UpdateCategoryInput returns UpdateCategoryInputResolver implementation. +func (r *Resolver) UpdateCategoryInput() UpdateCategoryInputResolver { + return &updateCategoryInputResolver{r} +} + // UpdateTodoInput returns UpdateTodoInputResolver implementation. func (r *Resolver) UpdateTodoInput() UpdateTodoInputResolver { return &updateTodoInputResolver{r} } @@ -163,11 +225,13 @@ func (r *Resolver) UpdateTodoInput() UpdateTodoInputResolver { return &updateTod func (r *Resolver) UserWhereInput() UserWhereInputResolver { return &userWhereInputResolver{r} } type categoryResolver struct{ *Resolver } +type organizationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } type todoResolver struct{ *Resolver } type userResolver struct{ *Resolver } type createCategoryInputResolver struct{ *Resolver } type createTodoInputResolver struct{ *Resolver } type todoWhereInputResolver struct{ *Resolver } +type updateCategoryInputResolver struct{ *Resolver } type updateTodoInputResolver struct{ *Resolver } type userWhereInputResolver struct{ *Resolver } diff --git a/entgql/internal/todogotype/ent/billproduct/where.go b/entgql/internal/todogotype/ent/billproduct/where.go index a26c84f74..83ea01388 100644 --- a/entgql/internal/todogotype/ent/billproduct/where.go +++ b/entgql/internal/todogotype/ent/billproduct/where.go @@ -263,32 +263,15 @@ func QuantityLTE(v uint64) predicate.BillProduct { // And groups predicates with the AND operator between them. func And(predicates ...predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BillProduct(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BillProduct(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.BillProduct(sql.NotPredicates(p)) } diff --git a/entgql/internal/todogotype/ent/billproduct_create.go b/entgql/internal/todogotype/ent/billproduct_create.go index 1a5f75a50..8d5fcf998 100644 --- a/entgql/internal/todogotype/ent/billproduct_create.go +++ b/entgql/internal/todogotype/ent/billproduct_create.go @@ -58,7 +58,7 @@ func (bpc *BillProductCreate) Mutation() *BillProductMutation { // Save creates the BillProduct in the database. func (bpc *BillProductCreate) Save(ctx context.Context) (*BillProduct, error) { - return withHooks[*BillProduct, BillProductMutation](ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) + return withHooks(ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -143,11 +143,15 @@ func (bpc *BillProductCreate) createSpec() (*BillProduct, *sqlgraph.CreateSpec) // BillProductCreateBulk is the builder for creating many BillProduct entities in bulk. type BillProductCreateBulk struct { config + err error builders []*BillProductCreate } // Save creates the BillProduct entities in the database. func (bpcb *BillProductCreateBulk) Save(ctx context.Context) ([]*BillProduct, error) { + if bpcb.err != nil { + return nil, bpcb.err + } specs := make([]*sqlgraph.CreateSpec, len(bpcb.builders)) nodes := make([]*BillProduct, len(bpcb.builders)) mutators := make([]Mutator, len(bpcb.builders)) diff --git a/entgql/internal/todogotype/ent/billproduct_delete.go b/entgql/internal/todogotype/ent/billproduct_delete.go index ca51e2179..9b3cdbce8 100644 --- a/entgql/internal/todogotype/ent/billproduct_delete.go +++ b/entgql/internal/todogotype/ent/billproduct_delete.go @@ -41,7 +41,7 @@ func (bpd *BillProductDelete) Where(ps ...predicate.BillProduct) *BillProductDel // Exec executes the deletion query and returns how many vertices were deleted. func (bpd *BillProductDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, BillProductMutation](ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) + return withHooks(ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/billproduct_update.go b/entgql/internal/todogotype/ent/billproduct_update.go index 1542e98ad..13a5dad97 100644 --- a/entgql/internal/todogotype/ent/billproduct_update.go +++ b/entgql/internal/todogotype/ent/billproduct_update.go @@ -47,12 +47,28 @@ func (bpu *BillProductUpdate) SetName(s string) *BillProductUpdate { return bpu } +// SetNillableName sets the "name" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableName(s *string) *BillProductUpdate { + if s != nil { + bpu.SetName(*s) + } + return bpu +} + // SetSku sets the "sku" field. func (bpu *BillProductUpdate) SetSku(s string) *BillProductUpdate { bpu.mutation.SetSku(s) return bpu } +// SetNillableSku sets the "sku" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableSku(s *string) *BillProductUpdate { + if s != nil { + bpu.SetSku(*s) + } + return bpu +} + // SetQuantity sets the "quantity" field. func (bpu *BillProductUpdate) SetQuantity(u uint64) *BillProductUpdate { bpu.mutation.ResetQuantity() @@ -60,6 +76,14 @@ func (bpu *BillProductUpdate) SetQuantity(u uint64) *BillProductUpdate { return bpu } +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableQuantity(u *uint64) *BillProductUpdate { + if u != nil { + bpu.SetQuantity(*u) + } + return bpu +} + // AddQuantity adds u to the "quantity" field. func (bpu *BillProductUpdate) AddQuantity(u int64) *BillProductUpdate { bpu.mutation.AddQuantity(u) @@ -73,7 +97,7 @@ func (bpu *BillProductUpdate) Mutation() *BillProductMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (bpu *BillProductUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, BillProductMutation](ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) + return withHooks(ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -145,12 +169,28 @@ func (bpuo *BillProductUpdateOne) SetName(s string) *BillProductUpdateOne { return bpuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableName(s *string) *BillProductUpdateOne { + if s != nil { + bpuo.SetName(*s) + } + return bpuo +} + // SetSku sets the "sku" field. func (bpuo *BillProductUpdateOne) SetSku(s string) *BillProductUpdateOne { bpuo.mutation.SetSku(s) return bpuo } +// SetNillableSku sets the "sku" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableSku(s *string) *BillProductUpdateOne { + if s != nil { + bpuo.SetSku(*s) + } + return bpuo +} + // SetQuantity sets the "quantity" field. func (bpuo *BillProductUpdateOne) SetQuantity(u uint64) *BillProductUpdateOne { bpuo.mutation.ResetQuantity() @@ -158,6 +198,14 @@ func (bpuo *BillProductUpdateOne) SetQuantity(u uint64) *BillProductUpdateOne { return bpuo } +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableQuantity(u *uint64) *BillProductUpdateOne { + if u != nil { + bpuo.SetQuantity(*u) + } + return bpuo +} + // AddQuantity adds u to the "quantity" field. func (bpuo *BillProductUpdateOne) AddQuantity(u int64) *BillProductUpdateOne { bpuo.mutation.AddQuantity(u) @@ -184,7 +232,7 @@ func (bpuo *BillProductUpdateOne) Select(field string, fields ...string) *BillPr // Save executes the query and returns the updated BillProduct entity. func (bpuo *BillProductUpdateOne) Save(ctx context.Context) (*BillProduct, error) { - return withHooks[*BillProduct, BillProductMutation](ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) + return withHooks(ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/category.go b/entgql/internal/todogotype/ent/category.go index 56722eaab..3000f603d 100644 --- a/entgql/internal/todogotype/ent/category.go +++ b/entgql/internal/todogotype/ent/category.go @@ -40,6 +40,8 @@ type Category struct { Status category.Status `json:"status,omitempty"` // Config holds the value of the "config" field. Config *schematype.CategoryConfig `json:"config,omitempty"` + // Types holds the value of the "types" field. + Types *schematype.CategoryTypes `json:"types,omitempty"` // Duration holds the value of the "duration" field. Duration time.Duration `json:"duration,omitempty"` // Count holds the value of the "count" field. @@ -91,7 +93,7 @@ func (*Category) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case category.FieldStrings: + case category.FieldTypes, category.FieldStrings: values[i] = new([]byte) case category.FieldID: values[i] = new(bigintgql.BigInt) @@ -140,6 +142,14 @@ func (c *Category) assignValues(columns []string, values []any) error { } else if value != nil { c.Config = value } + case category.FieldTypes: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field types", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &c.Types); err != nil { + return fmt.Errorf("unmarshal field types: %w", err) + } + } case category.FieldDuration: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field duration", values[i]) @@ -215,6 +225,9 @@ func (c *Category) String() string { builder.WriteString("config=") builder.WriteString(fmt.Sprintf("%v", c.Config)) builder.WriteString(", ") + builder.WriteString("types=") + builder.WriteString(fmt.Sprintf("%v", c.Types)) + builder.WriteString(", ") builder.WriteString("duration=") builder.WriteString(fmt.Sprintf("%v", c.Duration)) builder.WriteString(", ") diff --git a/entgql/internal/todogotype/ent/category/category.go b/entgql/internal/todogotype/ent/category/category.go index de05479b0..869878539 100644 --- a/entgql/internal/todogotype/ent/category/category.go +++ b/entgql/internal/todogotype/ent/category/category.go @@ -37,6 +37,8 @@ const ( FieldStatus = "status" // FieldConfig holds the string denoting the config field in the database. FieldConfig = "config" + // FieldTypes holds the string denoting the types field in the database. + FieldTypes = "types" // FieldDuration holds the string denoting the duration field in the database. FieldDuration = "duration" // FieldCount holds the string denoting the count field in the database. @@ -66,6 +68,7 @@ var Columns = []string{ FieldText, FieldStatus, FieldConfig, + FieldTypes, FieldDuration, FieldCount, FieldStrings, diff --git a/entgql/internal/todogotype/ent/category/where.go b/entgql/internal/todogotype/ent/category/where.go index 598a0168d..798148e92 100644 --- a/entgql/internal/todogotype/ent/category/where.go +++ b/entgql/internal/todogotype/ent/category/where.go @@ -227,6 +227,16 @@ func ConfigNotNil() predicate.Category { return predicate.Category(sql.FieldNotNull(FieldConfig)) } +// TypesIsNil applies the IsNil predicate on the "types" field. +func TypesIsNil() predicate.Category { + return predicate.Category(sql.FieldIsNull(FieldTypes)) +} + +// TypesNotNil applies the NotNil predicate on the "types" field. +func TypesNotNil() predicate.Category { + return predicate.Category(sql.FieldNotNull(FieldTypes)) +} + // DurationEQ applies the EQ predicate on the "duration" field. func DurationEQ(v time.Duration) predicate.Category { vc := int64(v) @@ -399,32 +409,15 @@ func HasSubCategoriesWith(preds ...predicate.Category) predicate.Category { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Category(sql.NotPredicates(p)) } diff --git a/entgql/internal/todogotype/ent/category_create.go b/entgql/internal/todogotype/ent/category_create.go index ec49daae7..e013998ba 100644 --- a/entgql/internal/todogotype/ent/category_create.go +++ b/entgql/internal/todogotype/ent/category_create.go @@ -55,6 +55,12 @@ func (cc *CategoryCreate) SetConfig(sc *schematype.CategoryConfig) *CategoryCrea return cc } +// SetTypes sets the "types" field. +func (cc *CategoryCreate) SetTypes(st *schematype.CategoryTypes) *CategoryCreate { + cc.mutation.SetTypes(st) + return cc +} + // SetDuration sets the "duration" field. func (cc *CategoryCreate) SetDuration(t time.Duration) *CategoryCreate { cc.mutation.SetDuration(t) @@ -141,7 +147,7 @@ func (cc *CategoryCreate) Mutation() *CategoryMutation { // Save creates the Category in the database. func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error) { cc.defaults() - return withHooks[*Category, CategoryMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) + return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -239,6 +245,10 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { _spec.SetField(category.FieldConfig, field.TypeOther, value) _node.Config = value } + if value, ok := cc.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + _node.Types = value + } if value, ok := cc.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) _node.Duration = value @@ -289,11 +299,15 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { // CategoryCreateBulk is the builder for creating many Category entities in bulk. type CategoryCreateBulk struct { config + err error builders []*CategoryCreate } // Save creates the Category entities in the database. func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error) { + if ccb.err != nil { + return nil, ccb.err + } specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) nodes := make([]*Category, len(ccb.builders)) mutators := make([]Mutator, len(ccb.builders)) diff --git a/entgql/internal/todogotype/ent/category_delete.go b/entgql/internal/todogotype/ent/category_delete.go index 482c2ba8e..df64e369e 100644 --- a/entgql/internal/todogotype/ent/category_delete.go +++ b/entgql/internal/todogotype/ent/category_delete.go @@ -41,7 +41,7 @@ func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (cd *CategoryDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) + return withHooks(ctx, cd.sqlExec, cd.mutation, cd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/category_update.go b/entgql/internal/todogotype/ent/category_update.go index 440cfc67e..247b82930 100644 --- a/entgql/internal/todogotype/ent/category_update.go +++ b/entgql/internal/todogotype/ent/category_update.go @@ -52,12 +52,28 @@ func (cu *CategoryUpdate) SetText(s string) *CategoryUpdate { return cu } +// SetNillableText sets the "text" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableText(s *string) *CategoryUpdate { + if s != nil { + cu.SetText(*s) + } + return cu +} + // SetStatus sets the "status" field. func (cu *CategoryUpdate) SetStatus(c category.Status) *CategoryUpdate { cu.mutation.SetStatus(c) return cu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableStatus(c *category.Status) *CategoryUpdate { + if c != nil { + cu.SetStatus(*c) + } + return cu +} + // SetConfig sets the "config" field. func (cu *CategoryUpdate) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdate { cu.mutation.SetConfig(sc) @@ -70,6 +86,18 @@ func (cu *CategoryUpdate) ClearConfig() *CategoryUpdate { return cu } +// SetTypes sets the "types" field. +func (cu *CategoryUpdate) SetTypes(st *schematype.CategoryTypes) *CategoryUpdate { + cu.mutation.SetTypes(st) + return cu +} + +// ClearTypes clears the value of the "types" field. +func (cu *CategoryUpdate) ClearTypes() *CategoryUpdate { + cu.mutation.ClearTypes() + return cu +} + // SetDuration sets the "duration" field. func (cu *CategoryUpdate) SetDuration(t time.Duration) *CategoryUpdate { cu.mutation.ResetDuration() @@ -221,7 +249,7 @@ func (cu *CategoryUpdate) RemoveSubCategories(c ...*Category) *CategoryUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) + return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -285,6 +313,12 @@ func (cu *CategoryUpdate) sqlSave(ctx context.Context) (n int, err error) { if cu.mutation.ConfigCleared() { _spec.ClearField(category.FieldConfig, field.TypeOther) } + if value, ok := cu.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + } + if cu.mutation.TypesCleared() { + _spec.ClearField(category.FieldTypes, field.TypeJSON) + } if value, ok := cu.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) } @@ -430,12 +464,28 @@ func (cuo *CategoryUpdateOne) SetText(s string) *CategoryUpdateOne { return cuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableText(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetText(*s) + } + return cuo +} + // SetStatus sets the "status" field. func (cuo *CategoryUpdateOne) SetStatus(c category.Status) *CategoryUpdateOne { cuo.mutation.SetStatus(c) return cuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableStatus(c *category.Status) *CategoryUpdateOne { + if c != nil { + cuo.SetStatus(*c) + } + return cuo +} + // SetConfig sets the "config" field. func (cuo *CategoryUpdateOne) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdateOne { cuo.mutation.SetConfig(sc) @@ -448,6 +498,18 @@ func (cuo *CategoryUpdateOne) ClearConfig() *CategoryUpdateOne { return cuo } +// SetTypes sets the "types" field. +func (cuo *CategoryUpdateOne) SetTypes(st *schematype.CategoryTypes) *CategoryUpdateOne { + cuo.mutation.SetTypes(st) + return cuo +} + +// ClearTypes clears the value of the "types" field. +func (cuo *CategoryUpdateOne) ClearTypes() *CategoryUpdateOne { + cuo.mutation.ClearTypes() + return cuo +} + // SetDuration sets the "duration" field. func (cuo *CategoryUpdateOne) SetDuration(t time.Duration) *CategoryUpdateOne { cuo.mutation.ResetDuration() @@ -612,7 +674,7 @@ func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUp // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) + return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -693,6 +755,12 @@ func (cuo *CategoryUpdateOne) sqlSave(ctx context.Context) (_node *Category, err if cuo.mutation.ConfigCleared() { _spec.ClearField(category.FieldConfig, field.TypeOther) } + if value, ok := cuo.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + } + if cuo.mutation.TypesCleared() { + _spec.ClearField(category.FieldTypes, field.TypeJSON) + } if value, ok := cuo.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) } diff --git a/entgql/internal/todogotype/ent/client.go b/entgql/internal/todogotype/ent/client.go index 5e07a0a0c..ae53d9b30 100644 --- a/entgql/internal/todogotype/ent/client.go +++ b/entgql/internal/todogotype/ent/client.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entgql/internal/todogotype/ent/migrate" "entgo.io/contrib/entgql/internal/todogotype/ent/schema/bigintgql" @@ -65,9 +66,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -102,6 +101,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -149,11 +155,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -303,6 +312,21 @@ func (c *BillProductClient) CreateBulk(builders ...*BillProductCreate) *BillProd return &BillProductCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BillProductClient) MapCreateBulk(slice any, setFunc func(*BillProductCreate, int)) *BillProductCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BillProductCreateBulk{err: fmt.Errorf("calling to BillProductClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BillProductCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BillProductCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for BillProduct. func (c *BillProductClient) Update() *BillProductUpdate { mutation := newBillProductMutation(c.config, OpUpdate) @@ -421,6 +445,21 @@ func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreate return &CategoryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CategoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CategoryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Category. func (c *CategoryClient) Update() *CategoryUpdate { mutation := newCategoryMutation(c.config, OpUpdate) @@ -571,6 +610,21 @@ func (c *FriendshipClient) CreateBulk(builders ...*FriendshipCreate) *Friendship return &FriendshipCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *FriendshipClient) MapCreateBulk(slice any, setFunc func(*FriendshipCreate, int)) *FriendshipCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &FriendshipCreateBulk{err: fmt.Errorf("calling to FriendshipClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*FriendshipCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &FriendshipCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Friendship. func (c *FriendshipClient) Update() *FriendshipUpdate { mutation := newFriendshipMutation(c.config, OpUpdate) @@ -721,6 +775,21 @@ func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk { return &GroupCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GroupCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GroupCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Group. func (c *GroupClient) Update() *GroupUpdate { mutation := newGroupMutation(c.config, OpUpdate) @@ -855,6 +924,21 @@ func (c *PetClient) CreateBulk(builders ...*PetCreate) *PetCreateBulk { return &PetCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PetClient) MapCreateBulk(slice any, setFunc func(*PetCreate, int)) *PetCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PetCreateBulk{err: fmt.Errorf("calling to PetClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PetCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PetCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Pet. func (c *PetClient) Update() *PetUpdate { mutation := newPetMutation(c.config, OpUpdate) @@ -973,6 +1057,21 @@ func (c *TodoClient) CreateBulk(builders ...*TodoCreate) *TodoCreateBulk { return &TodoCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TodoClient) MapCreateBulk(slice any, setFunc func(*TodoCreate, int)) *TodoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TodoCreateBulk{err: fmt.Errorf("calling to TodoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TodoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TodoCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Todo. func (c *TodoClient) Update() *TodoUpdate { mutation := newTodoMutation(c.config, OpUpdate) @@ -1155,6 +1254,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) @@ -1321,6 +1435,21 @@ func (c *VerySecretClient) CreateBulk(builders ...*VerySecretCreate) *VerySecret return &VerySecretCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *VerySecretClient) MapCreateBulk(slice any, setFunc func(*VerySecretCreate, int)) *VerySecretCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VerySecretCreateBulk{err: fmt.Errorf("calling to VerySecretClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VerySecretCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VerySecretCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for VerySecret. func (c *VerySecretClient) Update() *VerySecretUpdate { mutation := newVerySecretMutation(c.config, OpUpdate) diff --git a/entgql/internal/todogotype/ent/friendship/where.go b/entgql/internal/todogotype/ent/friendship/where.go index 001178a2f..a68d840ae 100644 --- a/entgql/internal/todogotype/ent/friendship/where.go +++ b/entgql/internal/todogotype/ent/friendship/where.go @@ -312,32 +312,15 @@ func HasFriendWith(preds ...predicate.User) predicate.Friendship { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Friendship(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Friendship(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Friendship(sql.NotPredicates(p)) } diff --git a/entgql/internal/todogotype/ent/friendship_create.go b/entgql/internal/todogotype/ent/friendship_create.go index 2fe0ac870..7badbd052 100644 --- a/entgql/internal/todogotype/ent/friendship_create.go +++ b/entgql/internal/todogotype/ent/friendship_create.go @@ -79,7 +79,7 @@ func (fc *FriendshipCreate) Mutation() *FriendshipMutation { // Save creates the Friendship in the database. func (fc *FriendshipCreate) Save(ctx context.Context) (*Friendship, error) { fc.defaults() - return withHooks[*Friendship, FriendshipMutation](ctx, fc.sqlSave, fc.mutation, fc.hooks) + return withHooks(ctx, fc.sqlSave, fc.mutation, fc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -204,11 +204,15 @@ func (fc *FriendshipCreate) createSpec() (*Friendship, *sqlgraph.CreateSpec) { // FriendshipCreateBulk is the builder for creating many Friendship entities in bulk. type FriendshipCreateBulk struct { config + err error builders []*FriendshipCreate } // Save creates the Friendship entities in the database. func (fcb *FriendshipCreateBulk) Save(ctx context.Context) ([]*Friendship, error) { + if fcb.err != nil { + return nil, fcb.err + } specs := make([]*sqlgraph.CreateSpec, len(fcb.builders)) nodes := make([]*Friendship, len(fcb.builders)) mutators := make([]Mutator, len(fcb.builders)) diff --git a/entgql/internal/todogotype/ent/friendship_delete.go b/entgql/internal/todogotype/ent/friendship_delete.go index 2181f6d4c..4365cadcd 100644 --- a/entgql/internal/todogotype/ent/friendship_delete.go +++ b/entgql/internal/todogotype/ent/friendship_delete.go @@ -41,7 +41,7 @@ func (fd *FriendshipDelete) Where(ps ...predicate.Friendship) *FriendshipDelete // Exec executes the deletion query and returns how many vertices were deleted. func (fd *FriendshipDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, FriendshipMutation](ctx, fd.sqlExec, fd.mutation, fd.hooks) + return withHooks(ctx, fd.sqlExec, fd.mutation, fd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/friendship_update.go b/entgql/internal/todogotype/ent/friendship_update.go index 6c7c5f655..2379623c6 100644 --- a/entgql/internal/todogotype/ent/friendship_update.go +++ b/entgql/internal/todogotype/ent/friendship_update.go @@ -63,12 +63,28 @@ func (fu *FriendshipUpdate) SetUserID(s string) *FriendshipUpdate { return fu } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (fu *FriendshipUpdate) SetNillableUserID(s *string) *FriendshipUpdate { + if s != nil { + fu.SetUserID(*s) + } + return fu +} + // SetFriendID sets the "friend_id" field. func (fu *FriendshipUpdate) SetFriendID(s string) *FriendshipUpdate { fu.mutation.SetFriendID(s) return fu } +// SetNillableFriendID sets the "friend_id" field if the given value is not nil. +func (fu *FriendshipUpdate) SetNillableFriendID(s *string) *FriendshipUpdate { + if s != nil { + fu.SetFriendID(*s) + } + return fu +} + // SetUser sets the "user" edge to the User entity. func (fu *FriendshipUpdate) SetUser(u *User) *FriendshipUpdate { return fu.SetUserID(u.ID) @@ -98,7 +114,7 @@ func (fu *FriendshipUpdate) ClearFriend() *FriendshipUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (fu *FriendshipUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, FriendshipMutation](ctx, fu.sqlSave, fu.mutation, fu.hooks) + return withHooks(ctx, fu.sqlSave, fu.mutation, fu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -247,12 +263,28 @@ func (fuo *FriendshipUpdateOne) SetUserID(s string) *FriendshipUpdateOne { return fuo } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (fuo *FriendshipUpdateOne) SetNillableUserID(s *string) *FriendshipUpdateOne { + if s != nil { + fuo.SetUserID(*s) + } + return fuo +} + // SetFriendID sets the "friend_id" field. func (fuo *FriendshipUpdateOne) SetFriendID(s string) *FriendshipUpdateOne { fuo.mutation.SetFriendID(s) return fuo } +// SetNillableFriendID sets the "friend_id" field if the given value is not nil. +func (fuo *FriendshipUpdateOne) SetNillableFriendID(s *string) *FriendshipUpdateOne { + if s != nil { + fuo.SetFriendID(*s) + } + return fuo +} + // SetUser sets the "user" edge to the User entity. func (fuo *FriendshipUpdateOne) SetUser(u *User) *FriendshipUpdateOne { return fuo.SetUserID(u.ID) @@ -295,7 +327,7 @@ func (fuo *FriendshipUpdateOne) Select(field string, fields ...string) *Friendsh // Save executes the query and returns the updated Friendship entity. func (fuo *FriendshipUpdateOne) Save(ctx context.Context) (*Friendship, error) { - return withHooks[*Friendship, FriendshipMutation](ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) + return withHooks(ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/gql_collection.go b/entgql/internal/todogotype/ent/gql_collection.go index 66bcccfc4..21f8443c5 100644 --- a/entgql/internal/todogotype/ent/gql_collection.go +++ b/entgql/internal/todogotype/ent/gql_collection.go @@ -40,13 +40,13 @@ func (bp *BillProductQuery) CollectFields(ctx context.Context, satisfies ...stri if fc == nil { return bp, nil } - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := bp.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return bp, nil } -func (bp *BillProductQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (bp *BillProductQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -87,7 +87,7 @@ type billproductPaginateArgs struct { opts []BillProductPaginateOption } -func newBillProductPaginateArgs(rv map[string]interface{}) *billproductPaginateArgs { +func newBillProductPaginateArgs(rv map[string]any) *billproductPaginateArgs { args := &billproductPaginateArgs{} if rv == nil { return args @@ -110,13 +110,13 @@ func (c *CategoryQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return c, nil } - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := c.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return c, nil } -func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (c *CategoryQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -125,6 +125,7 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "todos": var ( alias = field.Alias @@ -193,25 +194,30 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(category.TodosColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(category.TodosColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } c.WithNamedTodos(alias, func(wq *TodoQuery) { *wq = *query }) + case "subCategories": var ( alias = field.Alias @@ -284,19 +290,23 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Category")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Category"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Category")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Category"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(category.SubCategoriesPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(category.SubCategoriesPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -318,6 +328,11 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati selectedFields = append(selectedFields, category.FieldConfig) fieldSeen[category.FieldConfig] = struct{}{} } + case "types": + if _, ok := fieldSeen[category.FieldTypes]; !ok { + selectedFields = append(selectedFields, category.FieldTypes) + fieldSeen[category.FieldTypes] = struct{}{} + } case "duration": if _, ok := fieldSeen[category.FieldDuration]; !ok { selectedFields = append(selectedFields, category.FieldDuration) @@ -350,7 +365,7 @@ type categoryPaginateArgs struct { opts []CategoryPaginateOption } -func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { +func newCategoryPaginateArgs(rv map[string]any) *categoryPaginateArgs { args := &categoryPaginateArgs{} if rv == nil { return args @@ -365,10 +380,10 @@ func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { switch v := v.(type) { case []*CategoryOrder: args.opts = append(args.opts, WithCategoryOrder(v)) - case []interface{}: + case []any: var orders []*CategoryOrder for i := range v { - mv, ok := v[i].(map[string]interface{}) + mv, ok := v[i].(map[string]any) if !ok { continue } @@ -401,13 +416,13 @@ func (f *FriendshipQuery) CollectFields(ctx context.Context, satisfies ...string if fc == nil { return f, nil } - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := f.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return f, nil } -func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (f *FriendshipQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -416,13 +431,14 @@ func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "user": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: f.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } f.withUser = query @@ -430,13 +446,14 @@ func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, friendship.FieldUserID) fieldSeen[friendship.FieldUserID] = struct{}{} } + case "friend": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: f.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } f.withFriend = query @@ -476,7 +493,7 @@ type friendshipPaginateArgs struct { opts []FriendshipPaginateOption } -func newFriendshipPaginateArgs(rv map[string]interface{}) *friendshipPaginateArgs { +func newFriendshipPaginateArgs(rv map[string]any) *friendshipPaginateArgs { args := &friendshipPaginateArgs{} if rv == nil { return args @@ -499,13 +516,13 @@ func (gr *GroupQuery) CollectFields(ctx context.Context, satisfies ...string) (* if fc == nil { return gr, nil } - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := gr.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return gr, nil } -func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (gr *GroupQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -514,6 +531,7 @@ func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.Operation ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "users": var ( alias = field.Alias @@ -586,19 +604,23 @@ func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.Operation } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(group.UsersPrimaryKey[1], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(group.UsersPrimaryKey[1], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -627,7 +649,7 @@ type groupPaginateArgs struct { opts []GroupPaginateOption } -func newGroupPaginateArgs(rv map[string]interface{}) *groupPaginateArgs { +func newGroupPaginateArgs(rv map[string]any) *groupPaginateArgs { args := &groupPaginateArgs{} if rv == nil { return args @@ -650,13 +672,13 @@ func (pe *PetQuery) CollectFields(ctx context.Context, satisfies ...string) (*Pe if fc == nil { return pe, nil } - if err := pe.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := pe.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return pe, nil } -func (pe *PetQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (pe *PetQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -687,7 +709,7 @@ type petPaginateArgs struct { opts []PetPaginateOption } -func newPetPaginateArgs(rv map[string]interface{}) *petPaginateArgs { +func newPetPaginateArgs(rv map[string]any) *petPaginateArgs { args := &petPaginateArgs{} if rv == nil { return args @@ -710,13 +732,13 @@ func (t *TodoQuery) CollectFields(ctx context.Context, satisfies ...string) (*To if fc == nil { return t, nil } - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := t.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return t, nil } -func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (t *TodoQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -725,16 +747,18 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "parent": var ( alias = field.Alias path = append(path, alias) query = (&TodoClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, todoImplementors)...); err != nil { return err } t.withParent = query + case "children": var ( alias = field.Alias @@ -803,32 +827,37 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(todo.ChildrenColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(todo.ChildrenColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } t.WithNamedChildren(alias, func(wq *TodoQuery) { *wq = *query }) + case "category": var ( alias = field.Alias path = append(path, alias) query = (&CategoryClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, categoryImplementors)...); err != nil { return err } t.withCategory = query @@ -893,7 +922,7 @@ type todoPaginateArgs struct { opts []TodoPaginateOption } -func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { +func newTodoPaginateArgs(rv map[string]any) *todoPaginateArgs { args := &todoPaginateArgs{} if rv == nil { return args @@ -906,24 +935,30 @@ func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: - var ( - err1, err2 error - order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithTodoOrder(order)) - } - case *TodoOrder: - if v != nil { - args.opts = append(args.opts, WithTodoOrder(v)) + case []*TodoOrder: + args.opts = append(args.opts, WithTodoOrder(v)) + case []any: + var orders []*TodoOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} + ) + if d, ok := mv[directionField]; ok { + err1 = order.Direction.UnmarshalGQL(d) + } + if f, ok := mv[fieldField]; ok { + err2 = order.Field.UnmarshalGQL(f) + } + if err1 == nil && err2 == nil { + orders = append(orders, order) + } } + args.opts = append(args.opts, WithTodoOrder(orders)) } } if v, ok := rv[whereField].(*TodoWhereInput); ok { @@ -938,13 +973,13 @@ func (u *UserQuery) CollectFields(ctx context.Context, satisfies ...string) (*Us if fc == nil { return u, nil } - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := u.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return u, nil } -func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (u *UserQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -953,6 +988,7 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "groups": var ( alias = field.Alias @@ -1025,44 +1061,50 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Group")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Group"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Group")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Group"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(user.GroupsPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(user.GroupsPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } u.WithNamedGroups(alias, func(wq *GroupQuery) { *wq = *query }) + case "friends": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: u.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } u.WithNamedFriends(alias, func(wq *UserQuery) { *wq = *query }) + case "friendships": var ( alias = field.Alias path = append(path, alias) query = (&FriendshipClient{config: u.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, friendshipImplementors)...); err != nil { return err } u.WithNamedFriendships(alias, func(wq *FriendshipQuery) { @@ -1090,7 +1132,7 @@ type userPaginateArgs struct { opts []UserPaginateOption } -func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { +func newUserPaginateArgs(rv map[string]any) *userPaginateArgs { args := &userPaginateArgs{} if rv == nil { return args @@ -1103,7 +1145,7 @@ func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: + case map[string]any: var ( err1, err2 error order = &UserOrder{Field: &UserOrderField{}, Direction: entgql.OrderDirectionAsc} @@ -1138,35 +1180,18 @@ const ( whereField = "where" ) -func fieldArgs(ctx context.Context, whereInput interface{}, path ...string) map[string]interface{} { - fc := graphql.GetFieldContext(ctx) - if fc == nil { +func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { + field := collectedField(ctx, path...) + if field == nil || field.Arguments == nil { return nil } oc := graphql.GetOperationContext(ctx) - for _, name := range path { - var field *graphql.CollectedField - for _, f := range graphql.CollectFields(oc, fc.Field.Selections, nil) { - if f.Alias == name { - field = &f - break - } - } - if field == nil { - return nil - } - cf, err := fc.Child(ctx, *field) - if err != nil { - args := field.ArgumentMap(oc.Variables) - return unmarshalArgs(ctx, whereInput, args) - } - fc = cf - } - return fc.Args + args := field.ArgumentMap(oc.Variables) + return unmarshalArgs(ctx, whereInput, args) } // unmarshalArgs allows extracting the field arguments from their raw representation. -func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string]interface{}) map[string]interface{} { +func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{limitField, offsetField} { v, ok := args[k] if !ok { @@ -1186,39 +1211,17 @@ func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string] return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } diff --git a/entgql/internal/todogotype/ent/gql_edge.go b/entgql/internal/todogotype/ent/gql_edge.go index c53f3aa9c..8bd234169 100644 --- a/entgql/internal/todogotype/ent/gql_edge.go +++ b/entgql/internal/todogotype/ent/gql_edge.go @@ -23,7 +23,7 @@ import ( ) func (c *Category) Todos( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), @@ -110,7 +110,7 @@ func (t *Todo) Parent(ctx context.Context) (*Todo, error) { } func (t *Todo) Children( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), diff --git a/entgql/internal/todogotype/ent/gql_mutation_input.go b/entgql/internal/todogotype/ent/gql_mutation_input.go index 0993deec1..953b0324b 100644 --- a/entgql/internal/todogotype/ent/gql_mutation_input.go +++ b/entgql/internal/todogotype/ent/gql_mutation_input.go @@ -30,6 +30,7 @@ type CreateCategoryInput struct { Text string Status category.Status Config *schematype.CategoryConfig + Types *schematype.CategoryTypes Duration *time.Duration Count *uint64 Strings []string @@ -44,6 +45,9 @@ func (i *CreateCategoryInput) Mutate(m *CategoryMutation) { if v := i.Config; v != nil { m.SetConfig(v) } + if v := i.Types; v != nil { + m.SetTypes(v) + } if v := i.Duration; v != nil { m.SetDuration(*v) } @@ -73,6 +77,8 @@ type UpdateCategoryInput struct { Status *category.Status ClearConfig bool Config *schematype.CategoryConfig + ClearTypes bool + Types *schematype.CategoryTypes ClearDuration bool Duration *time.Duration ClearCount bool @@ -102,6 +108,12 @@ func (i *UpdateCategoryInput) Mutate(m *CategoryMutation) { if v := i.Config; v != nil { m.SetConfig(v) } + if i.ClearTypes { + m.ClearTypes() + } + if v := i.Types; v != nil { + m.SetTypes(v) + } if i.ClearDuration { m.ClearDuration() } diff --git a/entgql/internal/todogotype/ent/gql_node.go b/entgql/internal/todogotype/ent/gql_node.go index fcd65f62e..f3f4f2f2a 100644 --- a/entgql/internal/todogotype/ent/gql_node.go +++ b/entgql/internal/todogotype/ent/gql_node.go @@ -40,11 +40,15 @@ type Noder interface { IsNode() } +var billproductImplementors = []string{"BillProduct", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *BillProduct) IsNode() {} +func (*BillProduct) IsNode() {} + +var categoryImplementors = []string{"Category", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Category) IsNode() {} +func (*Category) IsNode() {} func (c Category) marshalID() string { var buf bytes.Buffer @@ -52,14 +56,23 @@ func (c Category) marshalID() string { return buf.String() } +var friendshipImplementors = []string{"Friendship", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *Friendship) IsNode() {} +func (*Friendship) IsNode() {} + +var groupImplementors = []string{"Group", "Node", "NamedNode"} // IsNode implements the Node interface check for GQLGen. -func (n *Group) IsNode() {} +func (*Group) IsNode() {} + +// IsNamedNode implements the NamedNode interface check for GQLGen. +func (*Group) IsNamedNode() {} + +var petImplementors = []string{"Pet", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Pet) IsNode() {} +func (*Pet) IsNode() {} func (pe Pet) marshalID() string { var buf bytes.Buffer @@ -67,11 +80,15 @@ func (pe Pet) marshalID() string { return buf.String() } +var todoImplementors = []string{"Todo", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *Todo) IsNode() {} +func (*Todo) IsNode() {} + +var userImplementors = []string{"User", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *User) IsNode() {} +func (*User) IsNode() {} var errNodeInvalidID = &NotFoundError{"node"} @@ -134,15 +151,12 @@ func (c *Client) noder(ctx context.Context, table string, id string) (Noder, err case billproduct.Table: query := c.BillProduct.Query(). Where(billproduct.ID(id)) - query, err := query.CollectFields(ctx, "BillProduct") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, billproductImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case category.Table: var uid bigintgql.BigInt if err := uid.UnmarshalGQL(id); err != nil { @@ -150,39 +164,30 @@ func (c *Client) noder(ctx context.Context, table string, id string) (Noder, err } query := c.Category.Query(). Where(category.ID(uid)) - query, err := query.CollectFields(ctx, "Category") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, categoryImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case friendship.Table: query := c.Friendship.Query(). Where(friendship.ID(id)) - query, err := query.CollectFields(ctx, "Friendship") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, friendshipImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case group.Table: query := c.Group.Query(). Where(group.ID(id)) - query, err := query.CollectFields(ctx, "Group") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, groupImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case pet.Table: var uid uintgql.Uint64 if err := uid.UnmarshalGQL(id); err != nil { @@ -190,39 +195,30 @@ func (c *Client) noder(ctx context.Context, table string, id string) (Noder, err } query := c.Pet.Query(). Where(pet.ID(uid)) - query, err := query.CollectFields(ctx, "Pet") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, petImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case todo.Table: query := c.Todo.Query(). Where(todo.ID(id)) - query, err := query.CollectFields(ctx, "Todo") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, todoImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case user.Table: query := c.User.Query(). Where(user.ID(id)) - query, err := query.CollectFields(ctx, "User") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, userImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) } @@ -299,7 +295,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []string) ([]Node case billproduct.Table: query := c.BillProduct.Query(). Where(billproduct.IDIn(ids...)) - query, err := query.CollectFields(ctx, "BillProduct") + query, err := query.CollectFields(ctx, billproductImplementors...) if err != nil { return nil, err } @@ -321,7 +317,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []string) ([]Node } query := c.Category.Query(). Where(category.IDIn(uids...)) - query, err := query.CollectFields(ctx, "Category") + query, err := query.CollectFields(ctx, categoryImplementors...) if err != nil { return nil, err } @@ -337,7 +333,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []string) ([]Node case friendship.Table: query := c.Friendship.Query(). Where(friendship.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Friendship") + query, err := query.CollectFields(ctx, friendshipImplementors...) if err != nil { return nil, err } @@ -353,7 +349,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []string) ([]Node case group.Table: query := c.Group.Query(). Where(group.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Group") + query, err := query.CollectFields(ctx, groupImplementors...) if err != nil { return nil, err } @@ -375,7 +371,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []string) ([]Node } query := c.Pet.Query(). Where(pet.IDIn(uids...)) - query, err := query.CollectFields(ctx, "Pet") + query, err := query.CollectFields(ctx, petImplementors...) if err != nil { return nil, err } @@ -391,7 +387,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []string) ([]Node case todo.Table: query := c.Todo.Query(). Where(todo.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Todo") + query, err := query.CollectFields(ctx, todoImplementors...) if err != nil { return nil, err } @@ -407,7 +403,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []string) ([]Node case user.Table: query := c.User.Query(). Where(user.IDIn(ids...)) - query, err := query.CollectFields(ctx, "User") + query, err := query.CollectFields(ctx, userImplementors...) if err != nil { return nil, err } diff --git a/entgql/internal/todogotype/ent/gql_pagination.go b/entgql/internal/todogotype/ent/gql_pagination.go index d09945275..5a7609a29 100644 --- a/entgql/internal/todogotype/ent/gql_pagination.go +++ b/entgql/internal/todogotype/ent/gql_pagination.go @@ -337,12 +337,12 @@ func (bp *BillProductQuery) PaginateLimitOffset( bp.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bp.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := bp.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -375,7 +375,9 @@ func (bp *BillProductQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = bp.Clone().Count(ctx); err != nil { + c := bp.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -388,16 +390,17 @@ func (bp *BillProductQuery) Paginate( if bp, err = pager.applyCursors(bp, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { bp.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -571,11 +574,11 @@ func (p *categoryPager) applyFilter(query *CategoryQuery) (*CategoryQuery, error } func (p *categoryPager) toCursor(c *Category) Cursor { - cs := make([]any, 0, len(p.order)) - for _, o := range p.order { - cs = append(cs, o.Field.toCursor(c).Value) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(c).Value) } - return Cursor{ID: c.marshalID(), Value: cs} + return Cursor{ID: c.marshalID(), Value: cs_} } func (p *categoryPager) applyCursors(query *CategoryQuery, after, before *Cursor) (*CategoryQuery, error) { @@ -702,12 +705,12 @@ func (c *CategoryQuery) PaginateLimitOffset( c.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -740,7 +743,9 @@ func (c *CategoryQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = c.Clone().Count(ctx); err != nil { + c := c.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -753,16 +758,17 @@ func (c *CategoryQuery) Paginate( if c, err = pager.applyCursors(c, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { c.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -790,6 +796,20 @@ var ( } }, } + // CategoryOrderFieldStatus orders Category by status. + CategoryOrderFieldStatus = &CategoryOrderField{ + Value: func(c *Category) (ent.Value, error) { + return c.Status, nil + }, + column: category.FieldStatus, + toTerm: category.ByStatus, + toCursor: func(c *Category) Cursor { + return Cursor{ + ID: c.marshalID(), + Value: c.Status, + } + }, + } // CategoryOrderFieldDuration orders Category by duration. CategoryOrderFieldDuration = &CategoryOrderField{ Value: func(c *Category) (ent.Value, error) { @@ -845,6 +865,8 @@ func (f CategoryOrderField) String() string { switch f.column { case CategoryOrderFieldText.column: str = "TEXT" + case CategoryOrderFieldStatus.column: + str = "STATUS" case CategoryOrderFieldDuration.column: str = "DURATION" case CategoryOrderFieldCount.column: @@ -869,6 +891,8 @@ func (f *CategoryOrderField) UnmarshalGQL(v interface{}) error { switch str { case "TEXT": *f = *CategoryOrderFieldText + case "STATUS": + *f = *CategoryOrderFieldStatus case "DURATION": *f = *CategoryOrderFieldDuration case "COUNT": @@ -1124,12 +1148,12 @@ func (f *FriendshipQuery) PaginateLimitOffset( f.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := f.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1162,7 +1186,9 @@ func (f *FriendshipQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = f.Clone().Count(ctx); err != nil { + c := f.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1175,16 +1201,17 @@ func (f *FriendshipQuery) Paginate( if f, err = pager.applyCursors(f, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { f.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1440,12 +1467,12 @@ func (gr *GroupQuery) PaginateLimitOffset( gr.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := gr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := gr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1478,7 +1505,9 @@ func (gr *GroupQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = gr.Clone().Count(ctx); err != nil { + c := gr.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1491,16 +1520,17 @@ func (gr *GroupQuery) Paginate( if gr, err = pager.applyCursors(gr, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { gr.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1756,12 +1786,12 @@ func (pe *PetQuery) PaginateLimitOffset( pe.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pe.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pe.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := pe.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := pe.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1794,7 +1824,9 @@ func (pe *PetQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = pe.Clone().Count(ctx); err != nil { + c := pe.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1807,16 +1839,17 @@ func (pe *PetQuery) Paginate( if pe, err = pager.applyCursors(pe, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { pe.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pe.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pe.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := pe.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := pe.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1938,19 +1971,14 @@ func (c *TodoList) build(nodes []*Todo, pager *todoPager, after *Cursor, first * type TodoPaginateOption func(*todoPager) error // WithTodoOrder configures pagination ordering. -func WithTodoOrder(order *TodoOrder) TodoPaginateOption { - if order == nil { - order = DefaultTodoOrder - } - o := *order +func WithTodoOrder(order []*TodoOrder) TodoPaginateOption { return func(pager *todoPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultTodoOrder.Field + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } } - pager.order = &o + pager.order = append(pager.order, order...) return nil } } @@ -1968,7 +1996,7 @@ func WithTodoFilter(filter func(*TodoQuery) (*TodoQuery, error)) TodoPaginateOpt type todoPager struct { reverse bool - order *TodoOrder + order []*TodoOrder filter func(*TodoQuery) (*TodoQuery, error) } @@ -1979,8 +2007,10 @@ func newTodoPager(opts []TodoPaginateOption, reverse bool) (*todoPager, error) { return nil, err } } - if pager.order == nil { - pager.order = DefaultTodoOrder + for i, o := range pager.order { + if i > 0 && o.Field == pager.order[i-1].Field { + return nil, fmt.Errorf("duplicate order direction %q", o.Direction) + } } return pager, nil } @@ -1993,57 +2023,100 @@ func (p *todoPager) applyFilter(query *TodoQuery) (*TodoQuery, error) { } func (p *todoPager) toCursor(t *Todo) Cursor { - return p.order.Field.toCursor(t) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(t).Value) + } + return Cursor{ID: t.ID, Value: cs_} } func (p *todoPager) applyCursors(query *TodoQuery, after, before *Cursor) (*TodoQuery, error) { - direction := p.order.Direction + idDirection := entgql.OrderDirectionAsc if p.reverse { - direction = direction.Reverse() + idDirection = entgql.OrderDirectionDesc + } + fields, directions := make([]string, 0, len(p.order)), make([]OrderDirection, 0, len(p.order)) + for _, o := range p.order { + fields = append(fields, o.Field.column) + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + directions = append(directions, direction) } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultTodoOrder.Field.column, p.order.Field.column, direction) { + predicates, err := entgql.MultiCursorsPredicate(after, before, &entgql.MultiCursorsOptions{ + FieldID: DefaultTodoOrder.Field.column, + DirectionID: idDirection, + Fields: fields, + Directions: directions, + }) + if err != nil { + return nil, err + } + for _, predicate := range predicates { query = query.Where(predicate) } return query, nil } func (p *todoPager) applyOrder(query *TodoQuery) *TodoQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultTodoOrder.Field { - query = query.Order(DefaultTodoOrder.Field.toTerm(direction.OrderTermOption())) + var defaultOrdered bool + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + if o.Field.column == DefaultTodoOrder.Field.column { + defaultOrdered = true + } + switch o.Field.column { + case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, TodoOrderFieldCategoryText.column: + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } + } } - switch p.order.Field.column { - case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, CategoryOrderFieldCategoryText.column: - default: - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) + if !defaultOrdered { + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() } + query = query.Order(DefaultTodoOrder.Field.toTerm(direction.OrderTermOption())) } return query } func (p *todoPager) orderExpr(query *TodoQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - switch p.order.Field.column { - case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, CategoryOrderFieldCategoryText.column: - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - default: - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) + for _, o := range p.order { + switch o.Field.column { + case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, TodoOrderFieldCategoryText.column: + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } } } return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultTodoOrder.Field { - b.Comma().Ident(DefaultTodoOrder.Field.column).Pad().WriteString(string(direction)) + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + b.Ident(o.Field.column).Pad().WriteString(string(direction)) + b.Comma() } + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + b.Ident(DefaultTodoOrder.Field.column).Pad().WriteString(string(direction)) }) } @@ -2081,12 +2154,12 @@ func (t *TodoQuery) PaginateLimitOffset( t.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2119,7 +2192,9 @@ func (t *TodoQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = t.Clone().Count(ctx); err != nil { + c := t.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2132,16 +2207,17 @@ func (t *TodoQuery) Paginate( if t, err = pager.applyCursors(t, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { t.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2250,8 +2326,8 @@ var ( } }, } - // CategoryOrderFieldCategoryText orders by CATEGORY_TEXT. - CategoryOrderFieldCategoryText = &TodoOrderField{ + // TodoOrderFieldCategoryText orders by CATEGORY_TEXT. + TodoOrderFieldCategoryText = &TodoOrderField{ Value: func(t *Todo) (ent.Value, error) { return t.Value("category_text") }, @@ -2288,7 +2364,7 @@ func (f TodoOrderField) String() string { str = "PARENT_STATUS" case TodoOrderFieldChildrenCount.column: str = "CHILDREN_COUNT" - case CategoryOrderFieldCategoryText.column: + case TodoOrderFieldCategoryText.column: str = "CATEGORY_TEXT" } return str @@ -2319,7 +2395,7 @@ func (f *TodoOrderField) UnmarshalGQL(v interface{}) error { case "CHILDREN_COUNT": *f = *TodoOrderFieldChildrenCount case "CATEGORY_TEXT": - *f = *CategoryOrderFieldCategoryText + *f = *TodoOrderFieldCategoryText default: return fmt.Errorf("%s is not a valid TodoOrderField", str) } @@ -2578,12 +2654,12 @@ func (u *UserQuery) PaginateLimitOffset( u.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := u.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := u.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2616,7 +2692,9 @@ func (u *UserQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = u.Clone().Count(ctx); err != nil { + c := u.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2629,16 +2707,17 @@ func (u *UserQuery) Paginate( if u, err = pager.applyCursors(u, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { u.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } diff --git a/entgql/internal/todogotype/ent/group/where.go b/entgql/internal/todogotype/ent/group/where.go index a8e6a3ca6..c866b741a 100644 --- a/entgql/internal/todogotype/ent/group/where.go +++ b/entgql/internal/todogotype/ent/group/where.go @@ -172,32 +172,15 @@ func HasUsersWith(preds ...predicate.User) predicate.Group { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Group(sql.NotPredicates(p)) } diff --git a/entgql/internal/todogotype/ent/group_create.go b/entgql/internal/todogotype/ent/group_create.go index 146739475..f03e74ec5 100644 --- a/entgql/internal/todogotype/ent/group_create.go +++ b/entgql/internal/todogotype/ent/group_create.go @@ -77,7 +77,7 @@ func (gc *GroupCreate) Mutation() *GroupMutation { // Save creates the Group in the database. func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) { gc.defaults() - return withHooks[*Group, GroupMutation](ctx, gc.sqlSave, gc.mutation, gc.hooks) + return withHooks(ctx, gc.sqlSave, gc.mutation, gc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -176,11 +176,15 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { // GroupCreateBulk is the builder for creating many Group entities in bulk. type GroupCreateBulk struct { config + err error builders []*GroupCreate } // Save creates the Group entities in the database. func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { + if gcb.err != nil { + return nil, gcb.err + } specs := make([]*sqlgraph.CreateSpec, len(gcb.builders)) nodes := make([]*Group, len(gcb.builders)) mutators := make([]Mutator, len(gcb.builders)) diff --git a/entgql/internal/todogotype/ent/group_delete.go b/entgql/internal/todogotype/ent/group_delete.go index 5879cbf94..c5dba2763 100644 --- a/entgql/internal/todogotype/ent/group_delete.go +++ b/entgql/internal/todogotype/ent/group_delete.go @@ -41,7 +41,7 @@ func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (gd *GroupDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gd.sqlExec, gd.mutation, gd.hooks) + return withHooks(ctx, gd.sqlExec, gd.mutation, gd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/group_update.go b/entgql/internal/todogotype/ent/group_update.go index f43880207..2e12848a3 100644 --- a/entgql/internal/todogotype/ent/group_update.go +++ b/entgql/internal/todogotype/ent/group_update.go @@ -99,7 +99,7 @@ func (gu *GroupUpdate) RemoveUsers(u ...*User) *GroupUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (gu *GroupUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gu.sqlSave, gu.mutation, gu.hooks) + return withHooks(ctx, gu.sqlSave, gu.mutation, gu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -271,7 +271,7 @@ func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOn // Save executes the query and returns the updated Group entity. func (guo *GroupUpdateOne) Save(ctx context.Context) (*Group, error) { - return withHooks[*Group, GroupMutation](ctx, guo.sqlSave, guo.mutation, guo.hooks) + return withHooks(ctx, guo.sqlSave, guo.mutation, guo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/migrate/schema.go b/entgql/internal/todogotype/ent/migrate/schema.go index 64ab1509f..9cda0102e 100644 --- a/entgql/internal/todogotype/ent/migrate/schema.go +++ b/entgql/internal/todogotype/ent/migrate/schema.go @@ -41,6 +41,7 @@ var ( {Name: "text", Type: field.TypeString, Size: 2147483647}, {Name: "status", Type: field.TypeEnum, Enums: []string{"ENABLED", "DISABLED"}}, {Name: "config", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"sqlite3": "json"}}, + {Name: "types", Type: field.TypeJSON, Nullable: true}, {Name: "duration", Type: field.TypeInt64, Nullable: true}, {Name: "count", Type: field.TypeUint64, Nullable: true}, {Name: "strings", Type: field.TypeJSON, Nullable: true}, diff --git a/entgql/internal/todogotype/ent/mutation.go b/entgql/internal/todogotype/ent/mutation.go index 80e0c976e..cd6fa8b07 100644 --- a/entgql/internal/todogotype/ent/mutation.go +++ b/entgql/internal/todogotype/ent/mutation.go @@ -538,6 +538,7 @@ type CategoryMutation struct { text *string status *category.Status _config **schematype.CategoryConfig + types **schematype.CategoryTypes duration *time.Duration addduration *time.Duration count *uint64 @@ -781,6 +782,55 @@ func (m *CategoryMutation) ResetConfig() { delete(m.clearedFields, category.FieldConfig) } +// SetTypes sets the "types" field. +func (m *CategoryMutation) SetTypes(st *schematype.CategoryTypes) { + m.types = &st +} + +// Types returns the value of the "types" field in the mutation. +func (m *CategoryMutation) Types() (r *schematype.CategoryTypes, exists bool) { + v := m.types + if v == nil { + return + } + return *v, true +} + +// OldTypes returns the old "types" field's value of the Category entity. +// If the Category object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CategoryMutation) OldTypes(ctx context.Context) (v *schematype.CategoryTypes, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTypes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTypes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTypes: %w", err) + } + return oldValue.Types, nil +} + +// ClearTypes clears the value of the "types" field. +func (m *CategoryMutation) ClearTypes() { + m.types = nil + m.clearedFields[category.FieldTypes] = struct{}{} +} + +// TypesCleared returns if the "types" field was cleared in this mutation. +func (m *CategoryMutation) TypesCleared() bool { + _, ok := m.clearedFields[category.FieldTypes] + return ok +} + +// ResetTypes resets all changes to the "types" field. +func (m *CategoryMutation) ResetTypes() { + m.types = nil + delete(m.clearedFields, category.FieldTypes) +} + // SetDuration sets the "duration" field. func (m *CategoryMutation) SetDuration(t time.Duration) { m.duration = &t @@ -1128,7 +1178,7 @@ func (m *CategoryMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *CategoryMutation) Fields() []string { - fields := make([]string, 0, 6) + fields := make([]string, 0, 7) if m.text != nil { fields = append(fields, category.FieldText) } @@ -1138,6 +1188,9 @@ func (m *CategoryMutation) Fields() []string { if m._config != nil { fields = append(fields, category.FieldConfig) } + if m.types != nil { + fields = append(fields, category.FieldTypes) + } if m.duration != nil { fields = append(fields, category.FieldDuration) } @@ -1161,6 +1214,8 @@ func (m *CategoryMutation) Field(name string) (ent.Value, bool) { return m.Status() case category.FieldConfig: return m.Config() + case category.FieldTypes: + return m.Types() case category.FieldDuration: return m.Duration() case category.FieldCount: @@ -1182,6 +1237,8 @@ func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldStatus(ctx) case category.FieldConfig: return m.OldConfig(ctx) + case category.FieldTypes: + return m.OldTypes(ctx) case category.FieldDuration: return m.OldDuration(ctx) case category.FieldCount: @@ -1218,6 +1275,13 @@ func (m *CategoryMutation) SetField(name string, value ent.Value) error { } m.SetConfig(v) return nil + case category.FieldTypes: + v, ok := value.(*schematype.CategoryTypes) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTypes(v) + return nil case category.FieldDuration: v, ok := value.(time.Duration) if !ok { @@ -1299,6 +1363,9 @@ func (m *CategoryMutation) ClearedFields() []string { if m.FieldCleared(category.FieldConfig) { fields = append(fields, category.FieldConfig) } + if m.FieldCleared(category.FieldTypes) { + fields = append(fields, category.FieldTypes) + } if m.FieldCleared(category.FieldDuration) { fields = append(fields, category.FieldDuration) } @@ -1325,6 +1392,9 @@ func (m *CategoryMutation) ClearField(name string) error { case category.FieldConfig: m.ClearConfig() return nil + case category.FieldTypes: + m.ClearTypes() + return nil case category.FieldDuration: m.ClearDuration() return nil @@ -1351,6 +1421,9 @@ func (m *CategoryMutation) ResetField(name string) error { case category.FieldConfig: m.ResetConfig() return nil + case category.FieldTypes: + m.ResetTypes() + return nil case category.FieldDuration: m.ResetDuration() return nil @@ -1700,6 +1773,7 @@ func (m *FriendshipMutation) ResetFriendID() { // ClearUser clears the "user" edge to the User entity. func (m *FriendshipMutation) ClearUser() { m.cleareduser = true + m.clearedFields[friendship.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. @@ -1726,6 +1800,7 @@ func (m *FriendshipMutation) ResetUser() { // ClearFriend clears the "friend" edge to the User entity. func (m *FriendshipMutation) ClearFriend() { m.clearedfriend = true + m.clearedFields[friendship.FieldFriendID] = struct{}{} } // FriendCleared reports if the "friend" edge to the User entity was cleared. @@ -3436,6 +3511,7 @@ func (m *TodoMutation) ResetChildren() { // ClearCategory clears the "category" edge to the Category entity. func (m *TodoMutation) ClearCategory() { m.clearedcategory = true + m.clearedFields[todo.FieldCategoryID] = struct{}{} } // CategoryCleared reports if the "category" edge to the Category entity was cleared. diff --git a/entgql/internal/todogotype/ent/pet/where.go b/entgql/internal/todogotype/ent/pet/where.go index ac8cc9209..ce3d3aa7a 100644 --- a/entgql/internal/todogotype/ent/pet/where.go +++ b/entgql/internal/todogotype/ent/pet/where.go @@ -139,32 +139,15 @@ func NameContainsFold(v string) predicate.Pet { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pet(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pet(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Pet(sql.NotPredicates(p)) } diff --git a/entgql/internal/todogotype/ent/pet_create.go b/entgql/internal/todogotype/ent/pet_create.go index 2909e2319..4aa254342 100644 --- a/entgql/internal/todogotype/ent/pet_create.go +++ b/entgql/internal/todogotype/ent/pet_create.go @@ -62,7 +62,7 @@ func (pc *PetCreate) Mutation() *PetMutation { // Save creates the Pet in the database. func (pc *PetCreate) Save(ctx context.Context) (*Pet, error) { pc.defaults() - return withHooks[*Pet, PetMutation](ctx, pc.sqlSave, pc.mutation, pc.hooks) + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -142,11 +142,15 @@ func (pc *PetCreate) createSpec() (*Pet, *sqlgraph.CreateSpec) { // PetCreateBulk is the builder for creating many Pet entities in bulk. type PetCreateBulk struct { config + err error builders []*PetCreate } // Save creates the Pet entities in the database. func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { + if pcb.err != nil { + return nil, pcb.err + } specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) nodes := make([]*Pet, len(pcb.builders)) mutators := make([]Mutator, len(pcb.builders)) diff --git a/entgql/internal/todogotype/ent/pet_delete.go b/entgql/internal/todogotype/ent/pet_delete.go index 96d533fec..d5a4824e8 100644 --- a/entgql/internal/todogotype/ent/pet_delete.go +++ b/entgql/internal/todogotype/ent/pet_delete.go @@ -41,7 +41,7 @@ func (pd *PetDelete) Where(ps ...predicate.Pet) *PetDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (pd *PetDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, PetMutation](ctx, pd.sqlExec, pd.mutation, pd.hooks) + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/pet_update.go b/entgql/internal/todogotype/ent/pet_update.go index 3c9904f2a..f1e5072ef 100644 --- a/entgql/internal/todogotype/ent/pet_update.go +++ b/entgql/internal/todogotype/ent/pet_update.go @@ -62,7 +62,7 @@ func (pu *PetUpdate) Mutation() *PetMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *PetUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, PetMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks) + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -153,7 +153,7 @@ func (puo *PetUpdateOne) Select(field string, fields ...string) *PetUpdateOne { // Save executes the query and returns the updated Pet entity. func (puo *PetUpdateOne) Save(ctx context.Context) (*Pet, error) { - return withHooks[*Pet, PetMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks) + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/runtime/runtime.go b/entgql/internal/todogotype/ent/runtime/runtime.go index 313e872ff..9c54740db 100644 --- a/entgql/internal/todogotype/ent/runtime/runtime.go +++ b/entgql/internal/todogotype/ent/runtime/runtime.go @@ -19,6 +19,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entgql/internal/todogotype/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entgql/internal/todogotype/ent/schema/group.go b/entgql/internal/todogotype/ent/schema/group.go index 9a922f81d..71fbd12a7 100644 --- a/entgql/internal/todogotype/ent/schema/group.go +++ b/entgql/internal/todogotype/ent/schema/group.go @@ -17,6 +17,7 @@ package schema import ( "entgo.io/contrib/entgql" "entgo.io/ent" + "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" ) @@ -40,6 +41,15 @@ func (Group) Edges() []ent.Edge { return []ent.Edge{ edge.From("users", User.Type). Ref("groups"). - Annotations(entgql.RelayConnection()), + Annotations( + entgql.RelayConnection(), + ), + } +} + +// Annotations returns Group annotations. +func (Group) Annotations() []schema.Annotation { + return []schema.Annotation{ + entgql.Implements("NamedNode"), } } diff --git a/entgql/internal/todogotype/ent/todo/where.go b/entgql/internal/todogotype/ent/todo/where.go index e216acfc0..d5d0f7b9a 100644 --- a/entgql/internal/todogotype/ent/todo/where.go +++ b/entgql/internal/todogotype/ent/todo/where.go @@ -524,32 +524,15 @@ func HasSecretWith(preds ...predicate.VerySecret) predicate.Todo { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Todo(sql.NotPredicates(p)) } diff --git a/entgql/internal/todogotype/ent/todo_create.go b/entgql/internal/todogotype/ent/todo_create.go index c3ac9e211..3c4da28f1 100644 --- a/entgql/internal/todogotype/ent/todo_create.go +++ b/entgql/internal/todogotype/ent/todo_create.go @@ -196,7 +196,7 @@ func (tc *TodoCreate) Mutation() *TodoMutation { // Save creates the Todo in the database. func (tc *TodoCreate) Save(ctx context.Context) (*Todo, error) { tc.defaults() - return withHooks[*Todo, TodoMutation](ctx, tc.sqlSave, tc.mutation, tc.hooks) + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -401,11 +401,15 @@ func (tc *TodoCreate) createSpec() (*Todo, *sqlgraph.CreateSpec) { // TodoCreateBulk is the builder for creating many Todo entities in bulk. type TodoCreateBulk struct { config + err error builders []*TodoCreate } // Save creates the Todo entities in the database. func (tcb *TodoCreateBulk) Save(ctx context.Context) ([]*Todo, error) { + if tcb.err != nil { + return nil, tcb.err + } specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) nodes := make([]*Todo, len(tcb.builders)) mutators := make([]Mutator, len(tcb.builders)) diff --git a/entgql/internal/todogotype/ent/todo_delete.go b/entgql/internal/todogotype/ent/todo_delete.go index 78613cf3a..697597f21 100644 --- a/entgql/internal/todogotype/ent/todo_delete.go +++ b/entgql/internal/todogotype/ent/todo_delete.go @@ -41,7 +41,7 @@ func (td *TodoDelete) Where(ps ...predicate.Todo) *TodoDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (td *TodoDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, td.sqlExec, td.mutation, td.hooks) + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/todo_update.go b/entgql/internal/todogotype/ent/todo_update.go index 2c9ef3a57..ac6f78363 100644 --- a/entgql/internal/todogotype/ent/todo_update.go +++ b/entgql/internal/todogotype/ent/todo_update.go @@ -50,6 +50,14 @@ func (tu *TodoUpdate) SetStatus(t todo.Status) *TodoUpdate { return tu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableStatus(t *todo.Status) *TodoUpdate { + if t != nil { + tu.SetStatus(*t) + } + return tu +} + // SetPriority sets the "priority" field. func (tu *TodoUpdate) SetPriority(i int) *TodoUpdate { tu.mutation.ResetPriority() @@ -77,6 +85,14 @@ func (tu *TodoUpdate) SetText(s string) *TodoUpdate { return tu } +// SetNillableText sets the "text" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableText(s *string) *TodoUpdate { + if s != nil { + tu.SetText(*s) + } + return tu +} + // SetBlob sets the "blob" field. func (tu *TodoUpdate) SetBlob(b []byte) *TodoUpdate { tu.mutation.SetBlob(b) @@ -230,7 +246,7 @@ func (tu *TodoUpdate) ClearSecret() *TodoUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TodoUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, tu.sqlSave, tu.mutation, tu.hooks) + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -457,6 +473,14 @@ func (tuo *TodoUpdateOne) SetStatus(t todo.Status) *TodoUpdateOne { return tuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableStatus(t *todo.Status) *TodoUpdateOne { + if t != nil { + tuo.SetStatus(*t) + } + return tuo +} + // SetPriority sets the "priority" field. func (tuo *TodoUpdateOne) SetPriority(i int) *TodoUpdateOne { tuo.mutation.ResetPriority() @@ -484,6 +508,14 @@ func (tuo *TodoUpdateOne) SetText(s string) *TodoUpdateOne { return tuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableText(s *string) *TodoUpdateOne { + if s != nil { + tuo.SetText(*s) + } + return tuo +} + // SetBlob sets the "blob" field. func (tuo *TodoUpdateOne) SetBlob(b []byte) *TodoUpdateOne { tuo.mutation.SetBlob(b) @@ -650,7 +682,7 @@ func (tuo *TodoUpdateOne) Select(field string, fields ...string) *TodoUpdateOne // Save executes the query and returns the updated Todo entity. func (tuo *TodoUpdateOne) Save(ctx context.Context) (*Todo, error) { - return withHooks[*Todo, TodoMutation](ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/user/where.go b/entgql/internal/todogotype/ent/user/where.go index 90193af7a..91e2b8693 100644 --- a/entgql/internal/todogotype/ent/user/where.go +++ b/entgql/internal/todogotype/ent/user/where.go @@ -218,32 +218,15 @@ func HasFriendshipsWith(preds ...predicate.Friendship) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entgql/internal/todogotype/ent/user_create.go b/entgql/internal/todogotype/ent/user_create.go index 83b8d991c..889f778de 100644 --- a/entgql/internal/todogotype/ent/user_create.go +++ b/entgql/internal/todogotype/ent/user_create.go @@ -108,7 +108,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { uc.defaults() - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -243,11 +243,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entgql/internal/todogotype/ent/user_delete.go b/entgql/internal/todogotype/ent/user_delete.go index 125171025..64ff12be3 100644 --- a/entgql/internal/todogotype/ent/user_delete.go +++ b/entgql/internal/todogotype/ent/user_delete.go @@ -41,7 +41,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/user_update.go b/entgql/internal/todogotype/ent/user_update.go index 13d9d1635..5de4de81f 100644 --- a/entgql/internal/todogotype/ent/user_update.go +++ b/entgql/internal/todogotype/ent/user_update.go @@ -172,7 +172,7 @@ func (uu *UserUpdate) RemoveFriendships(f ...*Friendship) *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -518,7 +518,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/verysecret/where.go b/entgql/internal/todogotype/ent/verysecret/where.go index 898a53ec9..9002de00f 100644 --- a/entgql/internal/todogotype/ent/verysecret/where.go +++ b/entgql/internal/todogotype/ent/verysecret/where.go @@ -148,32 +148,15 @@ func PasswordContainsFold(v string) predicate.VerySecret { // And groups predicates with the AND operator between them. func And(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.VerySecret(sql.NotPredicates(p)) } diff --git a/entgql/internal/todogotype/ent/verysecret_create.go b/entgql/internal/todogotype/ent/verysecret_create.go index d95d41867..9b04e27ff 100644 --- a/entgql/internal/todogotype/ent/verysecret_create.go +++ b/entgql/internal/todogotype/ent/verysecret_create.go @@ -61,7 +61,7 @@ func (vsc *VerySecretCreate) Mutation() *VerySecretMutation { // Save creates the VerySecret in the database. func (vsc *VerySecretCreate) Save(ctx context.Context) (*VerySecret, error) { vsc.defaults() - return withHooks[*VerySecret, VerySecretMutation](ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) + return withHooks(ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -144,11 +144,15 @@ func (vsc *VerySecretCreate) createSpec() (*VerySecret, *sqlgraph.CreateSpec) { // VerySecretCreateBulk is the builder for creating many VerySecret entities in bulk. type VerySecretCreateBulk struct { config + err error builders []*VerySecretCreate } // Save creates the VerySecret entities in the database. func (vscb *VerySecretCreateBulk) Save(ctx context.Context) ([]*VerySecret, error) { + if vscb.err != nil { + return nil, vscb.err + } specs := make([]*sqlgraph.CreateSpec, len(vscb.builders)) nodes := make([]*VerySecret, len(vscb.builders)) mutators := make([]Mutator, len(vscb.builders)) diff --git a/entgql/internal/todogotype/ent/verysecret_delete.go b/entgql/internal/todogotype/ent/verysecret_delete.go index d5c34c6c8..16a7c5082 100644 --- a/entgql/internal/todogotype/ent/verysecret_delete.go +++ b/entgql/internal/todogotype/ent/verysecret_delete.go @@ -41,7 +41,7 @@ func (vsd *VerySecretDelete) Where(ps ...predicate.VerySecret) *VerySecretDelete // Exec executes the deletion query and returns how many vertices were deleted. func (vsd *VerySecretDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) + return withHooks(ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todogotype/ent/verysecret_update.go b/entgql/internal/todogotype/ent/verysecret_update.go index e73c713a8..1fbcc41e5 100644 --- a/entgql/internal/todogotype/ent/verysecret_update.go +++ b/entgql/internal/todogotype/ent/verysecret_update.go @@ -47,6 +47,14 @@ func (vsu *VerySecretUpdate) SetPassword(s string) *VerySecretUpdate { return vsu } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsu *VerySecretUpdate) SetNillablePassword(s *string) *VerySecretUpdate { + if s != nil { + vsu.SetPassword(*s) + } + return vsu +} + // Mutation returns the VerySecretMutation object of the builder. func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { return vsu.mutation @@ -54,7 +62,7 @@ func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (vsu *VerySecretUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) + return withHooks(ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -117,6 +125,14 @@ func (vsuo *VerySecretUpdateOne) SetPassword(s string) *VerySecretUpdateOne { return vsuo } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsuo *VerySecretUpdateOne) SetNillablePassword(s *string) *VerySecretUpdateOne { + if s != nil { + vsuo.SetPassword(*s) + } + return vsuo +} + // Mutation returns the VerySecretMutation object of the builder. func (vsuo *VerySecretUpdateOne) Mutation() *VerySecretMutation { return vsuo.mutation @@ -137,7 +153,7 @@ func (vsuo *VerySecretUpdateOne) Select(field string, fields ...string) *VerySec // Save executes the query and returns the updated VerySecret entity. func (vsuo *VerySecretUpdateOne) Save(ctx context.Context) (*VerySecret, error) { - return withHooks[*VerySecret, VerySecretMutation](ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) + return withHooks(ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todogotype/generated.go b/entgql/internal/todogotype/generated.go index e722dfa42..6f8cfc632 100644 --- a/entgql/internal/todogotype/generated.go +++ b/entgql/internal/todogotype/generated.go @@ -13,6 +13,7 @@ import ( "time" "entgo.io/contrib/entgql" + ent1 "entgo.io/contrib/entgql/internal/todo/ent" "entgo.io/contrib/entgql/internal/todo/ent/schema/customstruct" "entgo.io/contrib/entgql/internal/todo/ent/schema/durationgql" "entgo.io/contrib/entgql/internal/todo/ent/schema/schematype" @@ -31,6 +32,7 @@ import ( // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ + schema: cfg.Schema, resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, @@ -38,6 +40,7 @@ func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { } type Config struct { + Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot @@ -46,12 +49,14 @@ type Config struct { type ResolverRoot interface { Category() CategoryResolver Mutation() MutationResolver + Organization() OrganizationResolver Query() QueryResolver Todo() TodoResolver User() UserResolver CreateCategoryInput() CreateCategoryInputResolver CreateTodoInput() CreateTodoInputResolver TodoWhereInput() TodoWhereInputResolver + UpdateCategoryInput() UpdateCategoryInputResolver UpdateTodoInput() UpdateTodoInputResolver UserWhereInput() UserWhereInputResolver } @@ -77,8 +82,9 @@ type ComplexityRoot struct { Strings func(childComplexity int) int SubCategories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int Text func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int TodosCount func(childComplexity int) int + Types func(childComplexity int) int } CategoryConfig struct { @@ -90,6 +96,10 @@ type ComplexityRoot struct { TotalCount func(childComplexity int) int } + CategoryTypes struct { + Public func(childComplexity int) int + } + Custom struct { Info func(childComplexity int) int } @@ -140,6 +150,11 @@ type ComplexityRoot struct { TotalCount func(childComplexity int) int } + Organization struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int @@ -149,25 +164,26 @@ type ComplexityRoot struct { Project struct { ID func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int } Query struct { - BillProducts func(childComplexity int) int - Categories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int - Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int - Node func(childComplexity int, id string) int - Nodes func(childComplexity int, ids []string) int - OneToMany func(childComplexity int, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) int - Ping func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int - Users func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int + BillProducts func(childComplexity int) int + Categories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int + Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int + Node func(childComplexity int, id string) int + Nodes func(childComplexity int, ids []string) int + OneToMany func(childComplexity int, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) int + Ping func(childComplexity int) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int + TodosWithJoins func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int + Users func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int } Todo struct { Category func(childComplexity int) int CategoryID func(childComplexity int) int - Children func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Children func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int CreatedAt func(childComplexity int) int Custom func(childComplexity int) int Customp func(childComplexity int) int @@ -186,13 +202,14 @@ type ComplexityRoot struct { } User struct { - Friends func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int - Friendships func(childComplexity int, limit *int, offset *int, where *ent.FriendshipWhereInput) int - Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int - ID func(childComplexity int) int - Metadata func(childComplexity int) int - Name func(childComplexity int) int - Username func(childComplexity int) int + Friends func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int + Friendships func(childComplexity int, limit *int, offset *int, where *ent.FriendshipWhereInput) int + Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int + ID func(childComplexity int) int + Metadata func(childComplexity int) int + Name func(childComplexity int) int + RequiredMetadata func(childComplexity int) int + Username func(childComplexity int) int } UserList struct { @@ -202,6 +219,8 @@ type ComplexityRoot struct { } type CategoryResolver interface { + Types(ctx context.Context, obj *ent.Category) (*CategoryTypes, error) + TodosCount(ctx context.Context, obj *ent.Category) (*int, error) } type MutationResolver interface { @@ -211,6 +230,9 @@ type MutationResolver interface { ClearTodos(ctx context.Context) (int, error) UpdateFriendship(ctx context.Context, id string, input UpdateFriendshipInput) (*ent.Friendship, error) } +type OrganizationResolver interface { + ID(ctx context.Context, obj *ent1.Workspace) (string, error) +} type QueryResolver interface { Node(ctx context.Context, id string) (ent.Noder, error) Nodes(ctx context.Context, ids []string) ([]ent.Noder, error) @@ -218,9 +240,10 @@ type QueryResolver interface { Categories(ctx context.Context, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryList, error) Groups(ctx context.Context, limit *int, offset *int, where *ent.GroupWhereInput) (*ent.GroupList, error) OneToMany(ctx context.Context, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) (*OneToManyList, error) - Todos(ctx context.Context, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) + Todos(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) Users(ctx context.Context, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) Ping(ctx context.Context) (string, error) + TodosWithJoins(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) } type TodoResolver interface { Status(ctx context.Context, obj *ent.Todo) (todo.Status, error) @@ -229,6 +252,7 @@ type TodoResolver interface { } type UserResolver interface { Username(ctx context.Context, obj *ent.User) (string, error) + RequiredMetadata(ctx context.Context, obj *ent.User) (map[string]interface{}, error) Metadata(ctx context.Context, obj *ent.User) (map[string]interface{}, error) Friends(ctx context.Context, obj *ent.User, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) @@ -236,6 +260,8 @@ type UserResolver interface { } type CreateCategoryInputResolver interface { + Types(ctx context.Context, obj *ent.CreateCategoryInput, data *CategoryTypesInput) error + CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error } type CreateTodoInputResolver interface { @@ -249,6 +275,9 @@ type TodoWhereInputResolver interface { CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error } +type UpdateCategoryInputResolver interface { + Types(ctx context.Context, obj *ent.UpdateCategoryInput, data *CategoryTypesInput) error +} type UpdateTodoInputResolver interface { Status(ctx context.Context, obj *ent.UpdateTodoInput, data *todo.Status) error } @@ -264,17 +293,21 @@ type UserWhereInputResolver interface { } type executableSchema struct { + schema *ast.Schema resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} + ec := executionContext{nil, e, 0, 0, nil} _ = ec switch typeName + "." + field { @@ -377,7 +410,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Category.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Category.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Category.todosCount": if e.complexity.Category.TodosCount == nil { @@ -386,6 +419,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Category.TodosCount(childComplexity), true + case "Category.types": + if e.complexity.Category.Types == nil { + break + } + + return e.complexity.Category.Types(childComplexity), true + case "CategoryConfig.maxMembers": if e.complexity.CategoryConfig.MaxMembers == nil { break @@ -407,6 +447,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CategoryList.TotalCount(childComplexity), true + case "CategoryTypes.public": + if e.complexity.CategoryTypes.Public == nil { + break + } + + return e.complexity.CategoryTypes.Public(childComplexity), true + case "Custom.info": if e.complexity.Custom.Info == nil { break @@ -614,6 +661,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OneToManyList.TotalCount(childComplexity), true + case "Organization.id": + if e.complexity.Organization.ID == nil { + break + } + + return e.complexity.Organization.ID(childComplexity), true + + case "Organization.name": + if e.complexity.Organization.Name == nil { + break + } + + return e.complexity.Organization.Name(childComplexity), true + case "PageInfo.endCursor": if e.complexity.PageInfo.EndCursor == nil { break @@ -659,7 +720,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Project.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Project.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Query.billProducts": if e.complexity.Query.BillProducts == nil { @@ -745,7 +806,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Query.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + + case "Query.todosWithJoins": + if e.complexity.Query.TodosWithJoins == nil { + break + } + + args, err := ec.field_Query_todosWithJoins_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.TodosWithJoins(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Query.users": if e.complexity.Query.Users == nil { @@ -783,7 +856,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Todo.Children(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Todo.Children(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Todo.createdAt": if e.complexity.Todo.CreatedAt == nil { @@ -926,6 +999,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Name(childComplexity), true + case "User.requiredMetadata": + if e.complexity.User.RequiredMetadata == nil { + break + } + + return e.complexity.User.RequiredMetadata(childComplexity), true + case "User.username": if e.complexity.User.Username == nil { break @@ -953,11 +1033,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputBillProductWhereInput, ec.unmarshalInputCategoryConfigInput, ec.unmarshalInputCategoryOrder, + ec.unmarshalInputCategoryTypesInput, ec.unmarshalInputCategoryWhereInput, ec.unmarshalInputCreateCategoryInput, ec.unmarshalInputCreateTodoInput, @@ -966,6 +1047,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputGroupWhereInput, ec.unmarshalInputOneToManyOrder, ec.unmarshalInputOneToManyWhereInput, + ec.unmarshalInputOrganizationWhereInput, ec.unmarshalInputProjectWhereInput, ec.unmarshalInputTodoOrder, ec.unmarshalInputTodoWhereInput, @@ -981,18 +1063,33 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { - if !first { - return nil + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext } + + return &response } case ast.Mutation: return func(ctx context.Context) *graphql.Response { @@ -1018,20 +1115,42 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { type executionContext struct { *graphql.OperationContext *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } var sources = []*ast.Source{ @@ -1045,6 +1164,14 @@ input CategoryConfigInput { maxMembers: Int } +type CategoryTypes { + public: Boolean +} + +input CategoryTypesInput { + public: Boolean +} + scalar Duration scalar UUID @@ -1068,6 +1195,21 @@ extend type Query { This field is an example of extending the built-in Query type from Ent. """ ping: String! + + """This is the todo item""" + todosWithJoins( + """Pagination limit.""" + limit: Int = 100 + + """Pagination offset.""" + offset: Int = 0 + + """Ordering options for Todos returned from the connection.""" + orderBy: [TodoOrder!] + + """Filtering options for Todos returned from the connection.""" + where: TodoWhereInput +): TodoList } type Mutation { @@ -1085,22 +1227,31 @@ type Custom { extend input CreateCategoryInput { createTodos: [CreateTodoInput!] } -`, BuiltIn: false}, - {Name: "../todo/ent.graphql", Input: `directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -"""Represents BillProduct object""" + +interface NamedNode { + name: String! +}`, BuiltIn: false}, + {Name: "../todo/ent.graphql", Input: `directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @goModel(model: String, models: [String!], forceGenerate: Boolean) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +""" +Represents BillProduct object +""" type BillProduct implements Node { id: ID! name: String! sku: String! quantity: Uint64! } -"""BillProductWhereInput is used for filtering BillProduct objects.""" +""" +BillProductWhereInput is used for filtering BillProduct objects. +""" input BillProductWhereInput { not: BillProductWhereInput and: [BillProductWhereInput!] or: [BillProductWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1109,7 +1260,9 @@ input BillProductWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1123,7 +1276,9 @@ input BillProductWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """sku field predicates""" + """ + sku field predicates + """ sku: String skuNEQ: String skuIn: [String!] @@ -1137,7 +1292,9 @@ input BillProductWhereInput { skuHasSuffix: String skuEqualFold: String skuContainsFold: String - """quantity field predicates""" + """ + quantity field predicates + """ quantity: Uint64 quantityNEQ: Uint64 quantityIn: [Uint64!] @@ -1147,75 +1304,115 @@ input BillProductWhereInput { quantityLT: Uint64 quantityLTE: Uint64 } -"""Represents Category object""" +""" +Represents Category object +""" type Category implements Node { id: ID! text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList subCategories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type CategoryList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Category]! } -"""Ordering options for Category connections""" +""" +Ordering options for Category connections +""" input CategoryOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Categories.""" + """ + The field by which to order Categories. + """ field: CategoryOrderField! } -"""Properties by which Category connections can be ordered.""" +""" +Properties by which Category connections can be ordered. +""" enum CategoryOrderField { ID TEXT + STATUS DURATION COUNT TODOS_COUNT } -"""CategoryStatus is enum for the field status""" +""" +CategoryStatus is enum for the field status +""" enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { ENABLED DISABLED } -"""CategoryWhereInput is used for filtering Category objects.""" +""" +CategoryWhereInput is used for filtering Category objects. +""" input CategoryWhereInput { not: CategoryWhereInput and: [CategoryWhereInput!] or: [CategoryWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1224,7 +1421,9 @@ input CategoryWhereInput { idGTE: ID idLT: ID idLTE: ID - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -1238,12 +1437,16 @@ input CategoryWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """status field predicates""" + """ + status field predicates + """ status: CategoryStatus statusNEQ: CategoryStatus statusIn: [CategoryStatus!] statusNotIn: [CategoryStatus!] - """config field predicates""" + """ + config field predicates + """ config: CategoryConfigInput configNEQ: CategoryConfigInput configIn: [CategoryConfigInput!] @@ -1254,7 +1457,9 @@ input CategoryWhereInput { configLTE: CategoryConfigInput configIsNil: Boolean configNotNil: Boolean - """duration field predicates""" + """ + duration field predicates + """ duration: Duration durationNEQ: Duration durationIn: [Duration!] @@ -1265,7 +1470,9 @@ input CategoryWhereInput { durationLTE: Duration durationIsNil: Boolean durationNotNil: Boolean - """count field predicates""" + """ + count field predicates + """ count: Uint64 countNEQ: Uint64 countIn: [Uint64!] @@ -1276,25 +1483,34 @@ input CategoryWhereInput { countLTE: Uint64 countIsNil: Boolean countNotNil: Boolean - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] - """sub_categories edge predicates""" + """ + sub_categories edge predicates + """ hasSubCategories: Boolean hasSubCategoriesWith: [CategoryWhereInput!] } -"""CreateCategoryInput is used for create Category object.""" +""" +CreateCategoryInput is used for create Category object. +""" input CreateCategoryInput { text: String! status: CategoryStatus! config: CategoryConfigInput + types: CategoryTypesInput duration: Duration count: Uint64 strings: [String!] todoIDs: [ID!] subCategoryIDs: [ID!] } -"""CreateTodoInput is used for create Todo object.""" +""" +CreateTodoInput is used for create Todo object. +""" input CreateTodoInput { status: TodoStatus! priority: Int @@ -1305,11 +1521,14 @@ input CreateTodoInput { categoryID: ID secretID: ID } -"""CreateUserInput is used for create User object.""" +""" +CreateUserInput is used for create User object. +""" input CreateUserInput { name: String username: UUID password: String + requiredMetadata: Map! metadata: Map groupIDs: [ID!] friendIDs: [ID!] @@ -1327,19 +1546,29 @@ type Friendship implements Node { user: User! friend: User! } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type FriendshipList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Friendship]! } -"""FriendshipWhereInput is used for filtering Friendship objects.""" +""" +FriendshipWhereInput is used for filtering Friendship objects. +""" input FriendshipWhereInput { not: FriendshipWhereInput and: [FriendshipWhereInput!] or: [FriendshipWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1348,7 +1577,9 @@ input FriendshipWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -1358,36 +1589,54 @@ input FriendshipWhereInput { createdAtLT: Time createdAtLTE: Time } -type Group implements Node @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { +type Group implements Node & NamedNode @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { id: ID! name: String! users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type GroupList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Group]! } -"""GroupWhereInput is used for filtering Group objects.""" +""" +GroupWhereInput is used for filtering Group objects. +""" input GroupWhereInput { not: GroupWhereInput and: [GroupWhereInput!] or: [GroupWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1396,7 +1645,9 @@ input GroupWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1410,18 +1661,24 @@ input GroupWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """users edge predicates""" + """ + users edge predicates + """ hasUsers: Boolean hasUsersWith: [UserWhereInput!] } -"""The builtin Map type""" +""" +The builtin Map type +""" scalar Map """ An object with an ID. Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) """ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder") { - """The id of the object.""" + """ + The id of the object. + """ id: ID! } type OneToMany implements Node { @@ -1431,30 +1688,48 @@ type OneToMany implements Node { parent: OneToMany children: [OneToMany!] } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type OneToManyList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [OneToMany]! } -"""Ordering options for OneToMany connections""" +""" +Ordering options for OneToMany connections +""" input OneToManyOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" + """ + The field by which to order OneToManies. + """ field: OneToManyOrderField! } -"""Properties by which OneToMany connections can be ordered.""" +""" +Properties by which OneToMany connections can be ordered. +""" enum OneToManyOrderField { NAME } -"""OneToManyWhereInput is used for filtering OneToMany objects.""" +""" +OneToManyWhereInput is used for filtering OneToMany objects. +""" input OneToManyWhereInput { not: OneToManyWhereInput and: [OneToManyWhereInput!] or: [OneToManyWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1463,7 +1738,9 @@ input OneToManyWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1477,7 +1754,9 @@ input OneToManyWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """field2 field predicates""" + """ + field2 field predicates + """ field2: String field2NEQ: String field2In: [String!] @@ -1493,56 +1772,125 @@ input OneToManyWhereInput { field2NotNil: Boolean field2EqualFold: String field2ContainsFold: String - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [OneToManyWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [OneToManyWhereInput!] } -"""Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument.""" +""" +Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument. +""" enum OrderDirection { - """Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument.""" + """ + Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument. + """ ASC - """Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument.""" + """ + Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument. + """ DESC } +type Organization implements Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Workspace") { + id: ID! + name: String! +} +""" +OrganizationWhereInput is used for filtering Workspace objects. +""" +input OrganizationWhereInput { + not: OrganizationWhereInput + and: [OrganizationWhereInput!] + or: [OrganizationWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String +} """ Information about pagination in a connection. https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo """ type PageInfo { - """When paginating forwards, are there more items?""" + """ + When paginating forwards, are there more items? + """ hasNextPage: Boolean! - """When paginating backwards, are there more items?""" + """ + When paginating backwards, are there more items? + """ hasPreviousPage: Boolean! - """When paginating backwards, the cursor to continue.""" + """ + When paginating backwards, the cursor to continue. + """ startCursor: Cursor - """When paginating forwards, the cursor to continue.""" + """ + When paginating forwards, the cursor to continue. + """ endCursor: Cursor } type Project implements Node { id: ID! todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList } -"""ProjectWhereInput is used for filtering Project objects.""" +""" +ProjectWhereInput is used for filtering Project objects. +""" input ProjectWhereInput { not: ProjectWhereInput and: [ProjectWhereInput!] or: [ProjectWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1551,87 +1899,139 @@ input ProjectWhereInput { idGTE: ID idLT: ID idLTE: ID - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] } type Query { - """Fetches an object given its ID.""" + """ + Fetches an object given its ID. + """ node( - """ID of the object.""" + """ + ID of the object. + """ id: ID! ): Node - """Lookup nodes by a list of IDs.""" + """ + Lookup nodes by a list of IDs. + """ nodes( - """The list of node IDs.""" + """ + The list of node IDs. + """ ids: [ID!]! ): [Node]! billProducts: [BillProduct!]! categories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList oneToMany( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for OneToManies returned from the connection.""" + """ + Ordering options for OneToManies returned from the connection. + """ orderBy: OneToManyOrder - """Filtering options for OneToManies returned from the connection.""" + """ + Filtering options for OneToManies returned from the connection. + """ where: OneToManyWhereInput ): OneToManyList - """This is the todo item""" + """ + This is the todo item + """ todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""The builtin Time type""" +""" +The builtin Time type +""" scalar Time type Todo implements Node { id: ID! @@ -1645,39 +2045,65 @@ type Todo implements Node { init: Map custom: [Custom!] customp: [Custom] - """Todo parent""" + """ + Todo parent + """ parent: Todo - """Todo children""" + """ + Todo children + """ children( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList category: Category } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type TodoList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Todo]! } -"""Ordering options for Todo connections""" +""" +Ordering options for Todo connections +""" input TodoOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Todos.""" + """ + The field by which to order Todos. + """ field: TodoOrderField! } -"""Properties by which Todo connections can be ordered.""" +""" +Properties by which Todo connections can be ordered. +""" enum TodoOrderField { CREATED_AT STATUS @@ -1687,18 +2113,24 @@ enum TodoOrderField { CHILDREN_COUNT CATEGORY_TEXT } -"""TodoStatus is enum for the field status""" +""" +TodoStatus is enum for the field status +""" enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { IN_PROGRESS COMPLETED PENDING } -"""TodoWhereInput is used for filtering Todo objects.""" +""" +TodoWhereInput is used for filtering Todo objects. +""" input TodoWhereInput { not: TodoWhereInput and: [TodoWhereInput!] or: [TodoWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1707,7 +2139,9 @@ input TodoWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -1716,12 +2150,16 @@ input TodoWhereInput { createdAtGTE: Time createdAtLT: Time createdAtLTE: Time - """status field predicates""" + """ + status field predicates + """ status: TodoStatus statusNEQ: TodoStatus statusIn: [TodoStatus!] statusNotIn: [TodoStatus!] - """priority field predicates""" + """ + priority field predicates + """ priority: Int priorityNEQ: Int priorityIn: [Int!] @@ -1730,7 +2168,9 @@ input TodoWhereInput { priorityGTE: Int priorityLT: Int priorityLTE: Int - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -1744,31 +2184,45 @@ input TodoWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """category_id field predicates""" + """ + category_id field predicates + """ categoryID: ID categoryIDNEQ: ID categoryIDIn: [ID!] categoryIDNotIn: [ID!] categoryIDIsNil: Boolean categoryIDNotNil: Boolean - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [TodoWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [TodoWhereInput!] - """category edge predicates""" + """ + category edge predicates + """ hasCategory: Boolean hasCategoryWith: [CategoryWhereInput!] } -"""The builtin Uint64 type""" +""" +The builtin Uint64 type +""" scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" +""" +UpdateCategoryInput is used for update Category object. +""" input UpdateCategoryInput { text: String status: CategoryStatus config: CategoryConfigInput clearConfig: Boolean + types: CategoryTypesInput + clearTypes: Boolean duration: Duration clearDuration: Boolean count: Uint64 @@ -1783,13 +2237,17 @@ input UpdateCategoryInput { removeSubCategoryIDs: [ID!] clearSubCategories: Boolean } -"""UpdateFriendshipInput is used for update Friendship object.""" +""" +UpdateFriendshipInput is used for update Friendship object. +""" input UpdateFriendshipInput { createdAt: Time userID: ID friendID: ID } -"""UpdateTodoInput is used for update Todo object.""" +""" +UpdateTodoInput is used for update Todo object. +""" input UpdateTodoInput { status: TodoStatus priority: Int @@ -1804,12 +2262,15 @@ input UpdateTodoInput { secretID: ID clearSecret: Boolean } -"""UpdateUserInput is used for update User object.""" +""" +UpdateUserInput is used for update User object. +""" input UpdateUserInput { name: String username: UUID password: String clearPassword: Boolean + requiredMetadata: Map metadata: Map clearMetadata: Boolean addGroupIDs: [ID!] @@ -1823,66 +2284,107 @@ type User implements Node { id: ID! name: String! username: UUID! + requiredMetadata: Map! metadata: Map - """The groups of the user""" + """ + The groups of the user + """ groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList friends( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList friendships( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Friendships returned from the connection.""" + """ + Filtering options for Friendships returned from the connection. + """ where: FriendshipWhereInput ): FriendshipList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type UserList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [User]! } -"""Ordering options for User connections""" +""" +Ordering options for User connections +""" input UserOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Users.""" + """ + The field by which to order Users. + """ field: UserOrderField! } -"""Properties by which User connections can be ordered.""" +""" +Properties by which User connections can be ordered. +""" enum UserOrderField { GROUPS_COUNT } -"""UserWhereInput is used for filtering User objects.""" +""" +UserWhereInput is used for filtering User objects. +""" input UserWhereInput { not: UserWhereInput and: [UserWhereInput!] or: [UserWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1891,7 +2393,9 @@ input UserWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1905,7 +2409,9 @@ input UserWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """username field predicates""" + """ + username field predicates + """ username: UUID usernameNEQ: UUID usernameIn: [UUID!] @@ -1914,13 +2420,19 @@ input UserWhereInput { usernameGTE: UUID usernameLT: UUID usernameLTE: UUID - """groups edge predicates""" + """ + groups edge predicates + """ hasGroups: Boolean hasGroupsWith: [GroupWhereInput!] - """friends edge predicates""" + """ + friends edge predicates + """ hasFriends: Boolean hasFriendsWith: [UserWhereInput!] - """friendships edge predicates""" + """ + friendships edge predicates + """ hasFriendships: Boolean hasFriendshipsWith: [FriendshipWhereInput!] } @@ -2010,10 +2522,10 @@ func (ec *executionContext) field_Category_todos_args(ctx context.Context, rawAr } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2172,10 +2684,10 @@ func (ec *executionContext) field_Project_todos_args(ctx context.Context, rawArg } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2355,6 +2867,48 @@ func (ec *executionContext) field_Query_oneToMany_args(ctx context.Context, rawA return args, nil } +func (ec *executionContext) field_Query_todosWithJoins_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["offset"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset")) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["offset"] = arg1 + var arg2 []*ent.TodoOrder + if tmp, ok := rawArgs["orderBy"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["orderBy"] = arg2 + var arg3 *ent.TodoWhereInput + if tmp, ok := rawArgs["where"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) + arg3, err = ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["where"] = arg3 + return args, nil +} + func (ec *executionContext) field_Query_todos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2376,10 +2930,10 @@ func (ec *executionContext) field_Query_todos_args(ctx context.Context, rawArgs } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2460,10 +3014,10 @@ func (ec *executionContext) field_Todo_children_args(ctx context.Context, rawArg } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2980,6 +3534,51 @@ func (ec *executionContext) fieldContext_Category_config(ctx context.Context, fi return fc, nil } +func (ec *executionContext) _Category_types(ctx context.Context, field graphql.CollectedField, obj *ent.Category) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Category_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Category().Types(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*CategoryTypes) + fc.Result = res + return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypes(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Category_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Category", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "public": + return ec.fieldContext_CategoryTypes_public(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CategoryTypes", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Category_duration(ctx context.Context, field graphql.CollectedField, obj *ent.Category) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Category_duration(ctx, field) if err != nil { @@ -3117,7 +3716,7 @@ func (ec *executionContext) _Category_todos(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -3156,7 +3755,7 @@ func (ec *executionContext) fieldContext_Category_todos(ctx context.Context, fie ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Category_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3214,7 +3813,7 @@ func (ec *executionContext) fieldContext_Category_subCategories(ctx context.Cont ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Category_subCategories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3392,6 +3991,8 @@ func (ec *executionContext) fieldContext_CategoryList_items(ctx context.Context, return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -3411,6 +4012,47 @@ func (ec *executionContext) fieldContext_CategoryList_items(ctx context.Context, return fc, nil } +func (ec *executionContext) _CategoryTypes_public(ctx context.Context, field graphql.CollectedField, obj *CategoryTypes) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CategoryTypes_public(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Public, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CategoryTypes_public(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CategoryTypes", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Custom_info(ctx context.Context, field graphql.CollectedField, obj *customstruct.Custom) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Custom_info(ctx, field) if err != nil { @@ -3676,6 +4318,8 @@ func (ec *executionContext) fieldContext_Friendship_user(ctx context.Context, fi return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -3736,6 +4380,8 @@ func (ec *executionContext) fieldContext_Friendship_friend(ctx context.Context, return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -3994,7 +4640,7 @@ func (ec *executionContext) fieldContext_Group_users(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Group_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4166,6 +4812,8 @@ func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Con return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -4191,7 +4839,7 @@ func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Con ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createCategory_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4278,7 +4926,7 @@ func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4365,7 +5013,7 @@ func (ec *executionContext) fieldContext_Mutation_updateTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4478,7 +5126,7 @@ func (ec *executionContext) fieldContext_Mutation_updateFriendship(ctx context.C ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateFriendship_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4818,6 +5466,94 @@ func (ec *executionContext) fieldContext_OneToManyList_items(ctx context.Context return fc, nil } +func (ec *executionContext) _Organization_id(ctx context.Context, field graphql.CollectedField, obj *ent1.Workspace) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Organization().ID(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Organization_name(ctx context.Context, field graphql.CollectedField, obj *ent1.Workspace) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[string]) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { @@ -5085,7 +5821,7 @@ func (ec *executionContext) fieldContext_Project_todos(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Project_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5137,7 +5873,7 @@ func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5192,7 +5928,7 @@ func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5304,7 +6040,7 @@ func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_categories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5362,7 +6098,7 @@ func (ec *executionContext) fieldContext_Query_groups(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_groups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5420,7 +6156,7 @@ func (ec *executionContext) fieldContext_Query_oneToMany(ctx context.Context, fi ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_oneToMany_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5439,7 +6175,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Todos(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return ec.resolvers.Query().Todos(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5478,7 +6214,7 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5536,7 +6272,7 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5585,8 +6321,8 @@ func (ec *executionContext) fieldContext_Query_ping(ctx context.Context, field g return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _Query_todosWithJoins(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_todosWithJoins(ctx, field) if err != nil { return graphql.Null } @@ -5599,7 +6335,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return ec.resolvers.Query().TodosWithJoins(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5608,21 +6344,79 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*ent.TodoList) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOTodoList2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoList(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_todosWithJoins(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) + case "totalCount": + return ec.fieldContext_TodoList_totalCount(ctx, field) + case "items": + return ec.fieldContext_TodoList_items(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TodoList", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_todosWithJoins_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) case "name": return ec.fieldContext___Type_name(ctx, field) case "description": @@ -5654,7 +6448,7 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6275,7 +7069,7 @@ func (ec *executionContext) _Todo_children(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Children(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Children(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -6314,7 +7108,7 @@ func (ec *executionContext) fieldContext_Todo_children(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Todo_children_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6363,6 +7157,8 @@ func (ec *executionContext) fieldContext_Todo_category(ctx context.Context, fiel return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -6675,6 +7471,50 @@ func (ec *executionContext) fieldContext_User_username(ctx context.Context, fiel return fc, nil } +func (ec *executionContext) _User_requiredMetadata(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_requiredMetadata(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().RequiredMetadata(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(map[string]interface{}) + fc.Result = res + return ec.marshalNMap2map(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_requiredMetadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Map does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_metadata(ctx, field) if err != nil { @@ -6769,7 +7609,7 @@ func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_groups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6827,7 +7667,7 @@ func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_friends_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6885,7 +7725,7 @@ func (ec *executionContext) fieldContext_User_friendships(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_friendships_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6979,6 +7819,8 @@ func (ec *executionContext) fieldContext_UserList_items(ctx context.Context, fie return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -8415,7 +9257,7 @@ func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -8603,7 +9445,7 @@ func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -8774,368 +9616,328 @@ func (ec *executionContext) unmarshalInputBillProductWhereInput(ctx context.Cont asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "sku", "skuNEQ", "skuIn", "skuNotIn", "skuGT", "skuGTE", "skuLT", "skuLTE", "skuContains", "skuHasPrefix", "skuHasSuffix", "skuEqualFold", "skuContainsFold", "quantity", "quantityNEQ", "quantityIn", "quantityNotIn", "quantityGT", "quantityGTE", "quantityLT", "quantityLTE"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOBillProductWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐBillProductWhereInput(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐBillProductWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐBillProductWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐBillProductWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐBillProductWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐBillProductWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "sku": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sku")) - it.Sku, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Sku = data case "skuNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuNEQ")) - it.SkuNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuNEQ = data case "skuIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuIn")) - it.SkuIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.SkuIn = data case "skuNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuNotIn")) - it.SkuNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.SkuNotIn = data case "skuGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuGT")) - it.SkuGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuGT = data case "skuGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuGTE")) - it.SkuGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuGTE = data case "skuLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuLT")) - it.SkuLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuLT = data case "skuLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuLTE")) - it.SkuLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuLTE = data case "skuContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuContains")) - it.SkuContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuContains = data case "skuHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuHasPrefix")) - it.SkuHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuHasPrefix = data case "skuHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuHasSuffix")) - it.SkuHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuHasSuffix = data case "skuEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuEqualFold")) - it.SkuEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuEqualFold = data case "skuContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuContainsFold")) - it.SkuContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuContainsFold = data case "quantity": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantity")) - it.Quantity, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Quantity = data case "quantityNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityNEQ")) - it.QuantityNEQ, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityNEQ = data case "quantityIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityIn")) - it.QuantityIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.QuantityIn = data case "quantityNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityNotIn")) - it.QuantityNotIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.QuantityNotIn = data case "quantityGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityGT")) - it.QuantityGT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityGT = data case "quantityGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityGTE")) - it.QuantityGTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityGTE = data case "quantityLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityLT")) - it.QuantityLT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityLT = data case "quantityLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityLTE")) - it.QuantityLTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityLTE = data } } @@ -9149,16 +9951,20 @@ func (ec *executionContext) unmarshalInputCategoryConfigInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"maxMembers"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "maxMembers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("maxMembers")) - it.MaxMembers, err = ec.unmarshalOInt2int(ctx, v) + data, err := ec.unmarshalOInt2int(ctx, v) if err != nil { return it, err } + it.MaxMembers = data } } @@ -9176,24 +9982,54 @@ func (ec *executionContext) unmarshalInputCategoryOrder(ctx context.Context, obj asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNCategoryOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryOrderField(ctx, v) + data, err := ec.unmarshalNCategoryOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCategoryTypesInput(ctx context.Context, obj interface{}) (CategoryTypesInput, error) { + var it CategoryTypesInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"public"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Public = data } } @@ -9207,504 +10043,447 @@ func (ec *executionContext) unmarshalInputCategoryWhereInput(ctx context.Context asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "text", "textNEQ", "textIn", "textNotIn", "textGT", "textGTE", "textLT", "textLTE", "textContains", "textHasPrefix", "textHasSuffix", "textEqualFold", "textContainsFold", "status", "statusNEQ", "statusIn", "statusNotIn", "config", "configNEQ", "configIn", "configNotIn", "configGT", "configGTE", "configLT", "configLTE", "configIsNil", "configNotNil", "duration", "durationNEQ", "durationIn", "durationNotIn", "durationGT", "durationGTE", "durationLT", "durationLTE", "durationIsNil", "durationNotNil", "count", "countNEQ", "countIn", "countNotIn", "countGT", "countGTE", "countLT", "countLTE", "countIsNil", "countNotNil", "hasTodos", "hasTodosWith", "hasSubCategories", "hasSubCategoriesWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInput(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "textNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNEQ")) - it.TextNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextNEQ = data case "textIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textIn")) - it.TextIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextIn = data case "textNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNotIn")) - it.TextNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextNotIn = data case "textGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGT")) - it.TextGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGT = data case "textGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGTE")) - it.TextGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGTE = data case "textLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLT")) - it.TextLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLT = data case "textLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLTE")) - it.TextLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLTE = data case "textContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContains")) - it.TextContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContains = data case "textHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasPrefix")) - it.TextHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasPrefix = data case "textHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasSuffix")) - it.TextHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasSuffix = data case "textEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textEqualFold")) - it.TextEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextEqualFold = data case "textContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContainsFold")) - it.TextContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContainsFold = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "statusNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) - it.StatusNEQ, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.StatusNEQ = data case "statusIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) - it.StatusIn, err = ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusIn = data case "statusNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) - it.StatusNotIn, err = ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusNotIn = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.Config = data case "configNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNEQ")) - it.ConfigNEQ, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigNEQ = data case "configIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configIn")) - it.ConfigIn, err = ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) if err != nil { return it, err } + it.ConfigIn = data case "configNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNotIn")) - it.ConfigNotIn, err = ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) if err != nil { return it, err } + it.ConfigNotIn = data case "configGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configGT")) - it.ConfigGT, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigGT = data case "configGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configGTE")) - it.ConfigGTE, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigGTE = data case "configLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configLT")) - it.ConfigLT, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigLT = data case "configLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configLTE")) - it.ConfigLTE, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigLTE = data case "configIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configIsNil")) - it.ConfigIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ConfigIsNil = data case "configNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNotNil")) - it.ConfigNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ConfigNotNil = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "durationNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNEQ")) - it.DurationNEQ, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationNEQ = data case "durationIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationIn")) - it.DurationIn, err = ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) + data, err := ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) if err != nil { return it, err } + it.DurationIn = data case "durationNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNotIn")) - it.DurationNotIn, err = ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) + data, err := ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) if err != nil { return it, err } + it.DurationNotIn = data case "durationGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationGT")) - it.DurationGT, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationGT = data case "durationGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationGTE")) - it.DurationGTE, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationGTE = data case "durationLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationLT")) - it.DurationLT, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationLT = data case "durationLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationLTE")) - it.DurationLTE, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationLTE = data case "durationIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationIsNil")) - it.DurationIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.DurationIsNil = data case "durationNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNotNil")) - it.DurationNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.DurationNotNil = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "countNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNEQ")) - it.CountNEQ, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountNEQ = data case "countIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countIn")) - it.CountIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.CountIn = data case "countNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNotIn")) - it.CountNotIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.CountNotIn = data case "countGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countGT")) - it.CountGT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountGT = data case "countGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countGTE")) - it.CountGTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountGTE = data case "countLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countLT")) - it.CountLT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountLT = data case "countLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countLTE")) - it.CountLTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountLTE = data case "countIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countIsNil")) - it.CountIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CountIsNil = data case "countNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNotNil")) - it.CountNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CountNotNil = data case "hasTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) - it.HasTodos, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasTodos = data case "hasTodosWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) - it.HasTodosWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasTodosWith = data case "hasSubCategories": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSubCategories")) - it.HasSubCategories, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasSubCategories = data case "hasSubCategoriesWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSubCategoriesWith")) - it.HasSubCategoriesWith, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasSubCategoriesWith = data } } @@ -9718,75 +10497,79 @@ func (ec *executionContext) unmarshalInputCreateCategoryInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"text", "status", "config", "types", "duration", "count", "strings", "todoIDs", "subCategoryIDs", "createTodos"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalNCategoryStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalNCategoryStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + if err != nil { + return it, err + } + it.Config = data + case "types": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("types")) + data, err := ec.unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypesInput(ctx, v) if err != nil { return it, err } + if err = ec.resolvers.CreateCategoryInput().Types(ctx, &it, data); err != nil { + return it, err + } case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "strings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strings")) - it.Strings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Strings = data case "todoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("todoIDs")) - it.TodoIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TodoIDs = data case "subCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subCategoryIDs")) - it.SubCategoryIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) if err != nil { return it, err } + it.SubCategoryIDs = data case "createTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTodos")) data, err := ec.unmarshalOCreateTodoInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCreateTodoInputᚄ(ctx, v) if err != nil { @@ -9808,11 +10591,14 @@ func (ec *executionContext) unmarshalInputCreateTodoInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "init", "parentID", "childIDs", "categoryID", "secretID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalNTodoStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -9822,61 +10608,54 @@ func (ec *executionContext) unmarshalInputCreateTodoInput(ctx context.Context, o return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "init": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("init")) - it.Init, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Init = data case "parentID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) - it.ParentID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ParentID = data case "childIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("childIDs")) - it.ChildIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.ChildIDs = data case "categoryID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryID")) - it.CategoryID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.CategoryID = data case "secretID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretID")) - it.SecretID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.SecretID = data } } @@ -9890,56 +10669,62 @@ func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "username", "password", "requiredMetadata", "metadata", "groupIDs", "friendIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - it.Username, err = ec.unmarshalOUUID2ᚖstring(ctx, v) + data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { return it, err } + it.Username = data case "password": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Password = data + case "requiredMetadata": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requiredMetadata")) + data, err := ec.unmarshalNMap2map(ctx, v) if err != nil { return it, err } + it.RequiredMetadata = data case "metadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadata")) - it.Metadata, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Metadata = data case "groupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIDs")) - it.GroupIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.GroupIDs = data case "friendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("friendIDs")) - it.FriendIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.FriendIDs = data } } @@ -9953,160 +10738,146 @@ func (ec *executionContext) unmarshalInputFriendshipWhereInput(ctx context.Conte asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendshipWhereInput(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendshipWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "createdAt": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAt = data case "createdAtNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtNEQ = data case "createdAtIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtIn = data case "createdAtNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtNotIn = data case "createdAtGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGT = data case "createdAtGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGTE = data case "createdAtLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLT = data case "createdAtLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLTE = data } } @@ -10120,216 +10891,195 @@ func (ec *executionContext) unmarshalInputGroupWhereInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasUsers", "hasUsersWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroupWhereInput(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroupWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "hasUsers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUsers")) - it.HasUsers, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasUsers = data case "hasUsersWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUsersWith")) - it.HasUsersWith, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasUsersWith = data } } @@ -10347,24 +11097,27 @@ func (ec *executionContext) unmarshalInputOneToManyOrder(ctx context.Context, ob asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNOneToManyOrderField2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyOrderField(ctx, v) + data, err := ec.unmarshalNOneToManyOrderField2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -10378,676 +11131,805 @@ func (ec *executionContext) unmarshalInputOneToManyWhereInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "field2", "field2NEQ", "field2In", "field2NotIn", "field2GT", "field2GTE", "field2LT", "field2LTE", "field2Contains", "field2HasPrefix", "field2HasSuffix", "field2IsNil", "field2NotNil", "field2EqualFold", "field2ContainsFold", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInput(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNeq, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGt, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGte, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLt, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLte, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLte = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNeq, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNeq = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGt = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGte = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLt = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLte = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "field2": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2")) - it.Field2, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2 = data case "field2NEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NEQ")) - it.Field2neq, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2neq = data case "field2In": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2In")) - it.Field2In, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Field2In = data case "field2NotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NotIn")) - it.Field2NotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Field2NotIn = data case "field2GT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2GT")) - it.Field2gt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2gt = data case "field2GTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2GTE")) - it.Field2gte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2gte = data case "field2LT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2LT")) - it.Field2lt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2lt = data case "field2LTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2LTE")) - it.Field2lte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2lte = data case "field2Contains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2Contains")) - it.Field2Contains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2Contains = data case "field2HasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2HasPrefix")) - it.Field2HasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2HasPrefix = data case "field2HasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2HasSuffix")) - it.Field2HasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2HasSuffix = data case "field2IsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2IsNil")) - it.Field2IsNil, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Field2IsNil = data case "field2NotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NotNil")) - it.Field2NotNil, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Field2NotNil = data case "field2EqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2EqualFold")) - it.Field2EqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2EqualFold = data case "field2ContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2ContainsFold")) - it.Field2ContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2ContainsFold = data case "hasParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParent")) - it.HasParent, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasParent = data case "hasParentWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParentWith")) - it.HasParentWith, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasParentWith = data case "hasChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildren")) - it.HasChildren, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasChildren = data case "hasChildrenWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildrenWith")) - it.HasChildrenWith, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasChildrenWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputProjectWhereInput(ctx context.Context, obj interface{}) (ProjectWhereInput, error) { - var it ProjectWhereInput +func (ec *executionContext) unmarshalInputOrganizationWhereInput(ctx context.Context, obj interface{}) (OrganizationWhereInput, error) { + var it OrganizationWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐProjectWhereInput(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOrganizationWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐProjectWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOrganizationWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐProjectWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOrganizationWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNeq, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGt, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGte, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLt, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLte, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } - case "hasTodos": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) - it.HasTodos, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.IDLte = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hasTodosWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) - it.HasTodosWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj interface{}) (ent.TodoOrder, error) { - var it ent.TodoOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - for k, v := range asMap { - switch k { - case "direction": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + it.NameNeq = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "field": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderField(ctx, v) + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGt = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGte = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLt = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLte = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data } } return it, nil } -func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, obj interface{}) (ent.TodoWhereInput, error) { - var it ent.TodoWhereInput +func (ec *executionContext) unmarshalInputProjectWhereInput(ctx context.Context, obj interface{}) (ProjectWhereInput, error) { + var it ProjectWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "hasTodos", "hasTodosWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInput(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐProjectWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐProjectWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐProjectWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } - case "createdAt": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IDLte = data + case "hasTodos": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "createdAtNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.HasTodos = data + case "hasTodosWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "createdAtIn": - var err error + it.HasTodosWith = data + } + } - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + return it, nil +} + +func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj interface{}) (ent.TodoOrder, error) { + var it ent.TodoOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - case "createdAtNotIn": - var err error + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, obj interface{}) (ent.TodoWhereInput, error) { + var it ent.TodoWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "status", "statusNEQ", "statusIn", "statusNotIn", "priority", "priorityNEQ", "priorityIn", "priorityNotIn", "priorityGT", "priorityGTE", "priorityLT", "priorityLTE", "text", "textNEQ", "textIn", "textNotIn", "textGT", "textGTE", "textLT", "textLTE", "textContains", "textHasPrefix", "textHasSuffix", "textEqualFold", "textContainsFold", "categoryID", "categoryIDNEQ", "categoryIDIn", "categoryIDNotIn", "categoryIDIsNil", "categoryIDNotNil", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith", "hasCategory", "hasCategoryWith", "createdToday"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtNotIn = data case "createdAtGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGT = data case "createdAtGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGTE = data case "createdAtLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLT = data case "createdAtLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLTE = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11057,8 +11939,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11068,8 +11948,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) data, err := ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) if err != nil { @@ -11079,8 +11957,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) data, err := ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) if err != nil { @@ -11090,272 +11966,237 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "priorityNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityNEQ")) - it.PriorityNEQ, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityNEQ = data case "priorityIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityIn")) - it.PriorityIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.PriorityIn = data case "priorityNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityNotIn")) - it.PriorityNotIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.PriorityNotIn = data case "priorityGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityGT")) - it.PriorityGT, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityGT = data case "priorityGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityGTE")) - it.PriorityGTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityGTE = data case "priorityLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityLT")) - it.PriorityLT, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityLT = data case "priorityLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityLTE")) - it.PriorityLTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityLTE = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "textNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNEQ")) - it.TextNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextNEQ = data case "textIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textIn")) - it.TextIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextIn = data case "textNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNotIn")) - it.TextNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextNotIn = data case "textGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGT")) - it.TextGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGT = data case "textGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGTE")) - it.TextGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGTE = data case "textLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLT")) - it.TextLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLT = data case "textLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLTE")) - it.TextLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLTE = data case "textContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContains")) - it.TextContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContains = data case "textHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasPrefix")) - it.TextHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasPrefix = data case "textHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasSuffix")) - it.TextHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasSuffix = data case "textEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textEqualFold")) - it.TextEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextEqualFold = data case "textContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContainsFold")) - it.TextContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContainsFold = data case "categoryID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryID")) - it.CategoryID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.CategoryID = data case "categoryIDNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNEQ")) - it.CategoryIDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, v) if err != nil { return it, err } + it.CategoryIDNEQ = data case "categoryIDIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDIn")) - it.CategoryIDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) if err != nil { return it, err } + it.CategoryIDIn = data case "categoryIDNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNotIn")) - it.CategoryIDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) if err != nil { return it, err } + it.CategoryIDNotIn = data case "categoryIDIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDIsNil")) - it.CategoryIDIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CategoryIDIsNil = data case "categoryIDNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNotNil")) - it.CategoryIDNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CategoryIDNotNil = data case "hasParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParent")) - it.HasParent, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasParent = data case "hasParentWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParentWith")) - it.HasParentWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasParentWith = data case "hasChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildren")) - it.HasChildren, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasChildren = data case "hasChildrenWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildrenWith")) - it.HasChildrenWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasChildrenWith = data case "hasCategory": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCategory")) - it.HasCategory, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasCategory = data case "hasCategoryWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCategoryWith")) - it.HasCategoryWith, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasCategoryWith = data case "createdToday": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdToday")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { @@ -11377,144 +12218,148 @@ func (ec *executionContext) unmarshalInputUpdateCategoryInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"text", "status", "config", "clearConfig", "types", "clearTypes", "duration", "clearDuration", "count", "clearCount", "strings", "appendStrings", "clearStrings", "addTodoIDs", "removeTodoIDs", "clearTodos", "addSubCategoryIDs", "removeSubCategoryIDs", "clearSubCategories"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.Config = data case "clearConfig": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearConfig")) - it.ClearConfig, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearConfig = data + case "types": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("types")) + data, err := ec.unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypesInput(ctx, v) + if err != nil { + return it, err + } + if err = ec.resolvers.UpdateCategoryInput().Types(ctx, &it, data); err != nil { + return it, err + } + case "clearTypes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTypes")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearTypes = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "clearDuration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearDuration")) - it.ClearDuration, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearDuration = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "clearCount": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearCount")) - it.ClearCount, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearCount = data case "strings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strings")) - it.Strings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Strings = data case "appendStrings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("appendStrings")) - it.AppendStrings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.AppendStrings = data case "clearStrings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearStrings")) - it.ClearStrings, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearStrings = data case "addTodoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addTodoIDs")) - it.AddTodoIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.AddTodoIDs = data case "removeTodoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeTodoIDs")) - it.RemoveTodoIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.RemoveTodoIDs = data case "clearTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTodos")) - it.ClearTodos, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearTodos = data case "addSubCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addSubCategoryIDs")) - it.AddSubCategoryIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) if err != nil { return it, err } + it.AddSubCategoryIDs = data case "removeSubCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeSubCategoryIDs")) - it.RemoveSubCategoryIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx, v) if err != nil { return it, err } + it.RemoveSubCategoryIDs = data case "clearSubCategories": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSubCategories")) - it.ClearSubCategories, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearSubCategories = data } } @@ -11528,32 +12373,34 @@ func (ec *executionContext) unmarshalInputUpdateFriendshipInput(ctx context.Cont asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"createdAt", "userID", "friendID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "createdAt": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAt = data case "userID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - it.UserID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.UserID = data case "friendID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("friendID")) - it.FriendID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.FriendID = data } } @@ -11567,11 +12414,14 @@ func (ec *executionContext) unmarshalInputUpdateTodoInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "init", "clearInit", "parentID", "clearParent", "addChildIDs", "removeChildIDs", "clearChildren", "secretID", "clearSecret"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11581,93 +12431,82 @@ func (ec *executionContext) unmarshalInputUpdateTodoInput(ctx context.Context, o return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "init": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("init")) - it.Init, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Init = data case "clearInit": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearInit")) - it.ClearInit, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearInit = data case "parentID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) - it.ParentID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ParentID = data case "clearParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearParent")) - it.ClearParent, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearParent = data case "addChildIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addChildIDs")) - it.AddChildIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.AddChildIDs = data case "removeChildIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeChildIDs")) - it.RemoveChildIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.RemoveChildIDs = data case "clearChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearChildren")) - it.ClearChildren, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearChildren = data case "secretID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretID")) - it.SecretID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.SecretID = data case "clearSecret": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSecret")) - it.ClearSecret, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearSecret = data } } @@ -11681,104 +12520,104 @@ func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "username", "password", "clearPassword", "requiredMetadata", "metadata", "clearMetadata", "addGroupIDs", "removeGroupIDs", "clearGroups", "addFriendIDs", "removeFriendIDs", "clearFriends"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) - it.Username, err = ec.unmarshalOUUID2ᚖstring(ctx, v) + data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { return it, err } + it.Username = data case "password": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Password = data case "clearPassword": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearPassword")) - it.ClearPassword, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.ClearPassword = data + case "requiredMetadata": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requiredMetadata")) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.RequiredMetadata = data case "metadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadata")) - it.Metadata, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Metadata = data case "clearMetadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearMetadata")) - it.ClearMetadata, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.ClearMetadata = data case "addGroupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addGroupIDs")) - it.AddGroupIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.AddGroupIDs = data case "removeGroupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeGroupIDs")) - it.RemoveGroupIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.RemoveGroupIDs = data case "clearGroups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearGroups")) - it.ClearGroups, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.ClearGroups = data case "addFriendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addFriendIDs")) - it.AddFriendIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.AddFriendIDs = data case "removeFriendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeFriendIDs")) - it.RemoveFriendIDs, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.RemoveFriendIDs = data case "clearFriends": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearFriends")) - it.ClearFriends, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.ClearFriends = data } } @@ -11796,24 +12635,27 @@ func (ec *executionContext) unmarshalInputUserOrder(ctx context.Context, obj int asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNUserOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserOrderField(ctx, v) + data, err := ec.unmarshalNUserOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -11827,203 +12669,182 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "username", "usernameNEQ", "usernameIn", "usernameNotIn", "usernameGT", "usernameGTE", "usernameLT", "usernameLTE", "hasGroups", "hasGroupsWith", "hasFriends", "hasFriendsWith", "hasFriendships", "hasFriendshipsWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOUserWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInput(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖstring(ctx, v) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12033,8 +12854,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameNEQ")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12044,8 +12863,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameIn")) data, err := ec.unmarshalOUUID2ᚕstringᚄ(ctx, v) if err != nil { @@ -12055,8 +12872,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameNotIn")) data, err := ec.unmarshalOUUID2ᚕstringᚄ(ctx, v) if err != nil { @@ -12066,8 +12881,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameGT")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12077,8 +12890,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameGTE")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12088,8 +12899,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameLT")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12099,8 +12908,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameLTE")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12110,53 +12917,47 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "hasGroups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasGroups")) - it.HasGroups, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasGroups = data case "hasGroupsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasGroupsWith")) - it.HasGroupsWith, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasGroupsWith = data case "hasFriends": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriends")) - it.HasFriends, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasFriends = data case "hasFriendsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendsWith")) - it.HasFriendsWith, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasFriendsWith = data case "hasFriendships": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendships")) - it.HasFriendships, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasFriendships = data case "hasFriendshipsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendshipsWith")) - it.HasFriendshipsWith, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasFriendshipsWith = data } } @@ -12167,30 +12968,44 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob // region ************************** interface.gotpl *************************** -func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { +func (ec *executionContext) _NamedNode(ctx context.Context, sel ast.SelectionSet, obj NamedNode) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null - case *ent.BillProduct: - if obj == nil { - return graphql.Null - } - return ec._BillProduct(ctx, sel, obj) - case *ent.Category: + case *ent.Group: if obj == nil { return graphql.Null } - return ec._Category(ctx, sel, obj) - case *ent.Friendship: + return ec._Group(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case *ent.Group: if obj == nil { return graphql.Null } - return ec._Friendship(ctx, sel, obj) - case *ent.Group: + return ec._Group(ctx, sel, obj) + case *ent.BillProduct: if obj == nil { return graphql.Null } - return ec._Group(ctx, sel, obj) + return ec._BillProduct(ctx, sel, obj) + case *ent.Category: + if obj == nil { + return graphql.Null + } + return ec._Category(ctx, sel, obj) + case *ent.Friendship: + if obj == nil { + return graphql.Null + } + return ec._Friendship(ctx, sel, obj) case OneToMany: return ec._OneToMany(ctx, sel, &obj) case *OneToMany: @@ -12198,6 +13013,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._OneToMany(ctx, sel, obj) + case *ent1.Workspace: + if obj == nil { + return graphql.Null + } + return ec._Organization(ctx, sel, obj) case Project: return ec._Project(ctx, sel, &obj) case *Project: @@ -12228,48 +13048,53 @@ var billProductImplementors = []string{"BillProduct", "Node"} func (ec *executionContext) _BillProduct(ctx context.Context, sel ast.SelectionSet, obj *ent.BillProduct) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, billProductImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("BillProduct") case "id": - out.Values[i] = ec._BillProduct_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec._BillProduct_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "sku": - out.Values[i] = ec._BillProduct_sku(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "quantity": - out.Values[i] = ec._BillProduct_quantity(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12277,53 +13102,73 @@ var categoryImplementors = []string{"Category", "Node"} func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, obj *ent.Category) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Category") case "id": - out.Values[i] = ec._Category_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Category_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "status": - out.Values[i] = ec._Category_status(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "config": - out.Values[i] = ec._Category_config(ctx, field, obj) + case "types": + field := field - case "duration": + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Category_types(ctx, field, obj) + return res + } - out.Values[i] = ec._Category_duration(ctx, field, obj) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - case "count": + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "duration": + out.Values[i] = ec._Category_duration(ctx, field, obj) + case "count": out.Values[i] = ec._Category_count(ctx, field, obj) - case "strings": - out.Values[i] = ec._Category_strings(ctx, field, obj) - case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12333,14 +13178,30 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "subCategories": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12350,14 +13211,30 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "todosCount": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12367,18 +13244,46 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12386,24 +13291,35 @@ var categoryConfigImplementors = []string{"CategoryConfig"} func (ec *executionContext) _CategoryConfig(ctx context.Context, sel ast.SelectionSet, obj *schematype.CategoryConfig) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryConfigImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryConfig") case "maxMembers": - out.Values[i] = ec._CategoryConfig_maxMembers(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12411,34 +13327,79 @@ var categoryListImplementors = []string{"CategoryList"} func (ec *executionContext) _CategoryList(ctx context.Context, sel ast.SelectionSet, obj *ent.CategoryList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryList") case "totalCount": - out.Values[i] = ec._CategoryList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._CategoryList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var categoryTypesImplementors = []string{"CategoryTypes"} + +func (ec *executionContext) _CategoryTypes(ctx context.Context, sel ast.SelectionSet, obj *CategoryTypes) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, categoryTypesImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CategoryTypes") + case "public": + out.Values[i] = ec._CategoryTypes_public(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12446,27 +13407,38 @@ var customImplementors = []string{"Custom"} func (ec *executionContext) _Custom(ctx context.Context, sel ast.SelectionSet, obj *customstruct.Custom) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, customImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Custom") case "info": - out.Values[i] = ec._Custom_info(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12474,44 +13446,37 @@ var friendshipImplementors = []string{"Friendship", "Node"} func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSet, obj *ent.Friendship) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendshipImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Friendship") case "id": - out.Values[i] = ec._Friendship_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Friendship_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "userID": - out.Values[i] = ec._Friendship_userID(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "friendID": - out.Values[i] = ec._Friendship_friendID(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "user": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12519,19 +13484,35 @@ func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSe }() res = ec._Friendship_user(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friend": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12539,23 +13520,51 @@ func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSe }() res = ec._Friendship_friend(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12563,65 +13572,71 @@ var friendshipListImplementors = []string{"FriendshipList"} func (ec *executionContext) _FriendshipList(ctx context.Context, sel ast.SelectionSet, obj *ent.FriendshipList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendshipListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FriendshipList") case "totalCount": - out.Values[i] = ec._FriendshipList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._FriendshipList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } -var groupImplementors = []string{"Group", "Node"} +var groupImplementors = []string{"Group", "Node", "NamedNode"} func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, obj *ent.Group) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, groupImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Group") case "id": - out.Values[i] = ec._Group_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._Group_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "users": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12631,18 +13646,46 @@ func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, ob return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12650,34 +13693,43 @@ var groupListImplementors = []string{"GroupList"} func (ec *executionContext) _GroupList(ctx context.Context, sel ast.SelectionSet, obj *ent.GroupList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, groupListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("GroupList") case "totalCount": - out.Values[i] = ec._GroupList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._GroupList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12690,7 +13742,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -12701,58 +13753,60 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createCategory": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createCategory(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "createTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "updateTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "clearTodos": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_clearTodos(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "updateFriendship": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateFriendship(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12760,46 +13814,49 @@ var oneToManyImplementors = []string{"OneToMany", "Node"} func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet, obj *OneToMany) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, oneToManyImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OneToMany") case "id": - out.Values[i] = ec._OneToMany_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec._OneToMany_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "field2": - out.Values[i] = ec._OneToMany_field2(ctx, field, obj) - case "parent": - out.Values[i] = ec._OneToMany_parent(ctx, field, obj) - case "children": - out.Values[i] = ec._OneToMany_children(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12807,34 +13864,118 @@ var oneToManyListImplementors = []string{"OneToManyList"} func (ec *executionContext) _OneToManyList(ctx context.Context, sel ast.SelectionSet, obj *OneToManyList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, oneToManyListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OneToManyList") case "totalCount": - out.Values[i] = ec._OneToManyList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._OneToManyList_items(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out +} + +var organizationImplementors = []string{"Organization", "Node"} + +func (ec *executionContext) _Organization(ctx context.Context, sel ast.SelectionSet, obj *ent1.Workspace) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, organizationImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Organization") + case "id": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Organization_id(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "name": + out.Values[i] = ec._Organization_name(ctx, field, obj) if out.Values[i] == graphql.Null { - invalids++ + atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12842,42 +13983,47 @@ var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[string]) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12885,31 +14031,40 @@ var projectImplementors = []string{"Project", "Node"} func (ec *executionContext) _Project(ctx context.Context, sel ast.SelectionSet, obj *Project) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, projectImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Project") case "id": - out.Values[i] = ec._Project_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "todos": - out.Values[i] = ec._Project_todos(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12922,7 +14077,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -12935,7 +14090,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "node": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12946,16 +14101,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nodes": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12963,22 +14117,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_nodes(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "billProducts": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12986,22 +14139,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_billProducts(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "categories": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13012,16 +14164,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "groups": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13032,16 +14183,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "oneToMany": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13052,16 +14202,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13072,16 +14221,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "users": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13092,16 +14240,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "ping": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13109,38 +14256,64 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_ping(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "__type": + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "todosWithJoins": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_todosWithJoins(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) - case "__schema": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13148,30 +14321,27 @@ var todoImplementors = []string{"Todo", "Node"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *ent.Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Todo_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "status": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13179,57 +14349,57 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj }() res = ec._Todo_status(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) - case "priorityOrder": + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "priorityOrder": out.Values[i] = ec._Todo_priorityOrder(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "categoryID": - out.Values[i] = ec._Todo_categoryID(ctx, field, obj) - case "category_id": - out.Values[i] = ec._Todo_category_id(ctx, field, obj) - case "categoryX": - out.Values[i] = ec._Todo_categoryX(ctx, field, obj) - case "init": - out.Values[i] = ec._Todo_init(ctx, field, obj) - case "custom": - out.Values[i] = ec._Todo_custom(ctx, field, obj) - case "customp": - out.Values[i] = ec._Todo_customp(ctx, field, obj) - case "parent": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13239,14 +14409,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "children": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13256,14 +14442,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "category": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13273,14 +14475,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "extendedField": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13290,18 +14508,46 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13309,34 +14555,43 @@ var todoListImplementors = []string{"TodoList"} func (ec *executionContext) _TodoList(ctx context.Context, sel ast.SelectionSet, obj *ent.TodoList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("TodoList") case "totalCount": - out.Values[i] = ec._TodoList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._TodoList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13344,30 +14599,27 @@ var userImplementors = []string{"User", "Node"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *ent.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "username": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13375,19 +14627,71 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj }() res = ec._User_username(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "requiredMetadata": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_requiredMetadata(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "metadata": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13397,14 +14701,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "groups": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13414,14 +14734,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friends": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13431,14 +14767,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friendships": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13448,18 +14800,46 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13467,34 +14847,43 @@ var userListImplementors = []string{"UserList"} func (ec *executionContext) _UserList(ctx context.Context, sel ast.SelectionSet, obj *ent.UserList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("UserList") case "totalCount": - out.Values[i] = ec._UserList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._UserList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13502,52 +14891,55 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isRepeatable": - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13555,42 +14947,47 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13598,56 +14995,57 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13655,42 +15053,47 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13698,53 +15101,54 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "description": - out.Values[i] = ec.___Schema_description(ctx, field, obj) - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13752,63 +15156,56 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - case "specifiedByURL": - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -14189,6 +15586,27 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } +func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + func (ec *executionContext) marshalNNode2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v []ent.Noder) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -14300,6 +15718,11 @@ func (ec *executionContext) marshalNOrderDirection2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) unmarshalNOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOrganizationWhereInput(ctx context.Context, v interface{}) (*OrganizationWhereInput, error) { + res, err := ec.unmarshalInputOrganizationWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐProjectWhereInput(ctx context.Context, v interface{}) (*ProjectWhereInput, error) { res, err := ec.unmarshalInputProjectWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -14419,6 +15842,11 @@ func (ec *executionContext) marshalNTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinte return ec._Todo(ctx, sel, v) } +func (ec *executionContext) unmarshalNTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrder(ctx context.Context, v interface{}) (*ent.TodoOrder, error) { + res, err := ec.unmarshalInputTodoOrder(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderField(ctx context.Context, v interface{}) (*ent.TodoOrderField, error) { var res = new(ent.TodoOrderField) err := res.UnmarshalGQL(v) @@ -15018,6 +16446,21 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } +func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypesInput(ctx context.Context, v interface{}) (*CategoryTypesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputCategoryTypesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.CategoryWhereInput, error) { if v == nil { return nil, nil @@ -15627,6 +17070,34 @@ func (ec *executionContext) unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontri return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOrganizationWhereInputᚄ(ctx context.Context, v interface{}) ([]*OrganizationWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*OrganizationWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOrganizationWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOrganizationWhereInput(ctx context.Context, v interface{}) (*OrganizationWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputOrganizationWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐProjectWhereInputᚄ(ctx context.Context, v interface{}) ([]*ProjectWhereInput, error) { if v == nil { return nil, nil @@ -15777,12 +17248,24 @@ func (ec *executionContext) marshalOTodoList2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._TodoList(ctx, sel, v) } -func (ec *executionContext) unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrder(ctx context.Context, v interface{}) (*ent.TodoOrder, error) { +func (ec *executionContext) unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrderᚄ(ctx context.Context, v interface{}) ([]*ent.TodoOrder, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalInputTodoOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.TodoOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodoOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil } func (ec *executionContext) unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx context.Context, v interface{}) ([]todo.Status, error) { diff --git a/entgql/internal/todogotype/gqlgen.yml b/entgql/internal/todogotype/gqlgen.yml index 310ff2195..f39195c39 100644 --- a/entgql/internal/todogotype/gqlgen.yml +++ b/entgql/internal/todogotype/gqlgen.yml @@ -17,6 +17,8 @@ autobind: - entgo.io/contrib/entgql/internal/todogotype/ent/todo - entgo.io/contrib/entgql/internal/todo/ent/schema/customstruct +# Disable the generated getters for all models and interfaces. +omit_getters: true models: ID: model: diff --git a/entgql/internal/todogotype/models_gen.go b/entgql/internal/todogotype/models_gen.go index 8b909a056..2ac5ef3da 100644 --- a/entgql/internal/todogotype/models_gen.go +++ b/entgql/internal/todogotype/models_gen.go @@ -12,22 +12,35 @@ import ( "entgo.io/contrib/entgql/internal/todogotype/ent" ) +type NamedNode interface { + IsNamedNode() +} + +type CategoryTypes struct { + Public *bool `json:"public,omitempty"` +} + +type CategoryTypesInput struct { + Public *bool `json:"public,omitempty"` +} + // CreateUserInput is used for create User object. type CreateUserInput struct { - Name *string `json:"name"` - Username *string `json:"username"` - Password *string `json:"password"` - Metadata map[string]interface{} `json:"metadata"` - GroupIDs []string `json:"groupIDs"` - FriendIDs []string `json:"friendIDs"` + Name *string `json:"name,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + RequiredMetadata map[string]interface{} `json:"requiredMetadata"` + Metadata map[string]interface{} `json:"metadata,omitempty"` + GroupIDs []string `json:"groupIDs,omitempty"` + FriendIDs []string `json:"friendIDs,omitempty"` } type OneToMany struct { ID string `json:"id"` Name string `json:"name"` - Field2 *string `json:"field2"` - Parent *OneToMany `json:"parent"` - Children []*OneToMany `json:"children"` + Field2 *string `json:"field2,omitempty"` + Parent *OneToMany `json:"parent,omitempty"` + Children []*OneToMany `json:"children,omitempty"` } func (OneToMany) IsNode() {} @@ -50,103 +63,134 @@ type OneToManyOrder struct { // OneToManyWhereInput is used for filtering OneToMany objects. type OneToManyWhereInput struct { - Not *OneToManyWhereInput `json:"not"` - And []*OneToManyWhereInput `json:"and"` - Or []*OneToManyWhereInput `json:"or"` + Not *OneToManyWhereInput `json:"not,omitempty"` + And []*OneToManyWhereInput `json:"and,omitempty"` + Or []*OneToManyWhereInput `json:"or,omitempty"` // id field predicates - ID *string `json:"id"` - IDNeq *string `json:"idNEQ"` - IDIn []string `json:"idIn"` - IDNotIn []string `json:"idNotIn"` - IDGt *string `json:"idGT"` - IDGte *string `json:"idGTE"` - IDLt *string `json:"idLT"` - IDLte *string `json:"idLTE"` + ID *string `json:"id,omitempty"` + IDNeq *string `json:"idNEQ,omitempty"` + IDIn []string `json:"idIn,omitempty"` + IDNotIn []string `json:"idNotIn,omitempty"` + IDGt *string `json:"idGT,omitempty"` + IDGte *string `json:"idGTE,omitempty"` + IDLt *string `json:"idLT,omitempty"` + IDLte *string `json:"idLTE,omitempty"` // name field predicates - Name *string `json:"name"` - NameNeq *string `json:"nameNEQ"` - NameIn []string `json:"nameIn"` - NameNotIn []string `json:"nameNotIn"` - NameGt *string `json:"nameGT"` - NameGte *string `json:"nameGTE"` - NameLt *string `json:"nameLT"` - NameLte *string `json:"nameLTE"` - NameContains *string `json:"nameContains"` - NameHasPrefix *string `json:"nameHasPrefix"` - NameHasSuffix *string `json:"nameHasSuffix"` - NameEqualFold *string `json:"nameEqualFold"` - NameContainsFold *string `json:"nameContainsFold"` + Name *string `json:"name,omitempty"` + NameNeq *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGt *string `json:"nameGT,omitempty"` + NameGte *string `json:"nameGTE,omitempty"` + NameLt *string `json:"nameLT,omitempty"` + NameLte *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` // field2 field predicates - Field2 *string `json:"field2"` - Field2neq *string `json:"field2NEQ"` - Field2In []string `json:"field2In"` - Field2NotIn []string `json:"field2NotIn"` - Field2gt *string `json:"field2GT"` - Field2gte *string `json:"field2GTE"` - Field2lt *string `json:"field2LT"` - Field2lte *string `json:"field2LTE"` - Field2Contains *string `json:"field2Contains"` - Field2HasPrefix *string `json:"field2HasPrefix"` - Field2HasSuffix *string `json:"field2HasSuffix"` - Field2IsNil *bool `json:"field2IsNil"` - Field2NotNil *bool `json:"field2NotNil"` - Field2EqualFold *string `json:"field2EqualFold"` - Field2ContainsFold *string `json:"field2ContainsFold"` + Field2 *string `json:"field2,omitempty"` + Field2neq *string `json:"field2NEQ,omitempty"` + Field2In []string `json:"field2In,omitempty"` + Field2NotIn []string `json:"field2NotIn,omitempty"` + Field2gt *string `json:"field2GT,omitempty"` + Field2gte *string `json:"field2GTE,omitempty"` + Field2lt *string `json:"field2LT,omitempty"` + Field2lte *string `json:"field2LTE,omitempty"` + Field2Contains *string `json:"field2Contains,omitempty"` + Field2HasPrefix *string `json:"field2HasPrefix,omitempty"` + Field2HasSuffix *string `json:"field2HasSuffix,omitempty"` + Field2IsNil *bool `json:"field2IsNil,omitempty"` + Field2NotNil *bool `json:"field2NotNil,omitempty"` + Field2EqualFold *string `json:"field2EqualFold,omitempty"` + Field2ContainsFold *string `json:"field2ContainsFold,omitempty"` // parent edge predicates - HasParent *bool `json:"hasParent"` - HasParentWith []*OneToManyWhereInput `json:"hasParentWith"` + HasParent *bool `json:"hasParent,omitempty"` + HasParentWith []*OneToManyWhereInput `json:"hasParentWith,omitempty"` // children edge predicates - HasChildren *bool `json:"hasChildren"` - HasChildrenWith []*OneToManyWhereInput `json:"hasChildrenWith"` + HasChildren *bool `json:"hasChildren,omitempty"` + HasChildrenWith []*OneToManyWhereInput `json:"hasChildrenWith,omitempty"` +} + +// OrganizationWhereInput is used for filtering Workspace objects. +type OrganizationWhereInput struct { + Not *OrganizationWhereInput `json:"not,omitempty"` + And []*OrganizationWhereInput `json:"and,omitempty"` + Or []*OrganizationWhereInput `json:"or,omitempty"` + // id field predicates + ID *string `json:"id,omitempty"` + IDNeq *string `json:"idNEQ,omitempty"` + IDIn []string `json:"idIn,omitempty"` + IDNotIn []string `json:"idNotIn,omitempty"` + IDGt *string `json:"idGT,omitempty"` + IDGte *string `json:"idGTE,omitempty"` + IDLt *string `json:"idLT,omitempty"` + IDLte *string `json:"idLTE,omitempty"` + // name field predicates + Name *string `json:"name,omitempty"` + NameNeq *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGt *string `json:"nameGT,omitempty"` + NameGte *string `json:"nameGTE,omitempty"` + NameLt *string `json:"nameLT,omitempty"` + NameLte *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` } type Project struct { ID string `json:"id"` - Todos *ent.TodoList `json:"todos"` + Todos *ent.TodoList `json:"todos,omitempty"` } func (Project) IsNode() {} // ProjectWhereInput is used for filtering Project objects. type ProjectWhereInput struct { - Not *ProjectWhereInput `json:"not"` - And []*ProjectWhereInput `json:"and"` - Or []*ProjectWhereInput `json:"or"` + Not *ProjectWhereInput `json:"not,omitempty"` + And []*ProjectWhereInput `json:"and,omitempty"` + Or []*ProjectWhereInput `json:"or,omitempty"` // id field predicates - ID *string `json:"id"` - IDNeq *string `json:"idNEQ"` - IDIn []string `json:"idIn"` - IDNotIn []string `json:"idNotIn"` - IDGt *string `json:"idGT"` - IDGte *string `json:"idGTE"` - IDLt *string `json:"idLT"` - IDLte *string `json:"idLTE"` + ID *string `json:"id,omitempty"` + IDNeq *string `json:"idNEQ,omitempty"` + IDIn []string `json:"idIn,omitempty"` + IDNotIn []string `json:"idNotIn,omitempty"` + IDGt *string `json:"idGT,omitempty"` + IDGte *string `json:"idGTE,omitempty"` + IDLt *string `json:"idLT,omitempty"` + IDLte *string `json:"idLTE,omitempty"` // todos edge predicates - HasTodos *bool `json:"hasTodos"` - HasTodosWith []*ent.TodoWhereInput `json:"hasTodosWith"` + HasTodos *bool `json:"hasTodos,omitempty"` + HasTodosWith []*ent.TodoWhereInput `json:"hasTodosWith,omitempty"` } // UpdateFriendshipInput is used for update Friendship object. type UpdateFriendshipInput struct { - CreatedAt *time.Time `json:"createdAt"` - UserID *string `json:"userID"` - FriendID *string `json:"friendID"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + UserID *string `json:"userID,omitempty"` + FriendID *string `json:"friendID,omitempty"` } // UpdateUserInput is used for update User object. type UpdateUserInput struct { - Name *string `json:"name"` - Username *string `json:"username"` - Password *string `json:"password"` - ClearPassword *bool `json:"clearPassword"` - Metadata map[string]interface{} `json:"metadata"` - ClearMetadata *bool `json:"clearMetadata"` - AddGroupIDs []string `json:"addGroupIDs"` - RemoveGroupIDs []string `json:"removeGroupIDs"` - ClearGroups *bool `json:"clearGroups"` - AddFriendIDs []string `json:"addFriendIDs"` - RemoveFriendIDs []string `json:"removeFriendIDs"` - ClearFriends *bool `json:"clearFriends"` + Name *string `json:"name,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + ClearPassword *bool `json:"clearPassword,omitempty"` + RequiredMetadata map[string]interface{} `json:"requiredMetadata,omitempty"` + Metadata map[string]interface{} `json:"metadata,omitempty"` + ClearMetadata *bool `json:"clearMetadata,omitempty"` + AddGroupIDs []string `json:"addGroupIDs,omitempty"` + RemoveGroupIDs []string `json:"removeGroupIDs,omitempty"` + ClearGroups *bool `json:"clearGroups,omitempty"` + AddFriendIDs []string `json:"addFriendIDs,omitempty"` + RemoveFriendIDs []string `json:"removeFriendIDs,omitempty"` + ClearFriends *bool `json:"clearFriends,omitempty"` } // Properties by which OneToMany connections can be ordered. diff --git a/entgql/internal/todogotype/todo.resolvers.go b/entgql/internal/todogotype/todo.resolvers.go index ba383b4e2..acf1aa2d9 100644 --- a/entgql/internal/todogotype/todo.resolvers.go +++ b/entgql/internal/todogotype/todo.resolvers.go @@ -16,6 +16,7 @@ package todo // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" @@ -24,42 +25,57 @@ import ( "entgo.io/contrib/entgql/internal/todogotype/ent" ) +// TodosCount is the resolver for the todosCount field. func (r *categoryResolver) TodosCount(ctx context.Context, obj *ent.Category) (*int, error) { panic(fmt.Errorf("not implemented")) } +// CreateCategory is the resolver for the createCategory field. func (r *mutationResolver) CreateCategory(ctx context.Context, input ent.CreateCategoryInput) (*ent.Category, error) { panic(fmt.Errorf("not implemented")) } +// CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo(ctx context.Context, input ent.CreateTodoInput) (*ent.Todo, error) { panic(fmt.Errorf("not implemented")) } +// UpdateTodo is the resolver for the updateTodo field. func (r *mutationResolver) UpdateTodo(ctx context.Context, id string, input ent.UpdateTodoInput) (*ent.Todo, error) { panic(fmt.Errorf("not implemented")) } +// ClearTodos is the resolver for the clearTodos field. func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { panic(fmt.Errorf("not implemented")) } +// UpdateFriendship is the resolver for the updateFriendship field. func (r *mutationResolver) UpdateFriendship(ctx context.Context, id string, input UpdateFriendshipInput) (*ent.Friendship, error) { panic(fmt.Errorf("not implemented")) } +// Ping is the resolver for the ping field. func (r *queryResolver) Ping(ctx context.Context) (string, error) { panic(fmt.Errorf("not implemented")) } +// TodosWithJoins is the resolver for the todosWithJoins field. +func (r *queryResolver) TodosWithJoins(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { + panic(fmt.Errorf("not implemented")) +} + +// ExtendedField is the resolver for the extendedField field. func (r *todoResolver) ExtendedField(ctx context.Context, obj *ent.Todo) (*string, error) { panic(fmt.Errorf("not implemented")) } +// CreateTodos is the resolver for the createTodos field. func (r *createCategoryInputResolver) CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error { panic(fmt.Errorf("not implemented")) } +// CreatedToday is the resolver for the createdToday field. func (r *todoWhereInputResolver) CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error { panic(fmt.Errorf("not implemented")) } diff --git a/entgql/internal/todopulid/ent.resolvers.go b/entgql/internal/todopulid/ent.resolvers.go index f0a75eff5..158cd744e 100644 --- a/entgql/internal/todopulid/ent.resolvers.go +++ b/entgql/internal/todopulid/ent.resolvers.go @@ -16,32 +16,49 @@ package todopulid // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" "fmt" + ent1 "entgo.io/contrib/entgql/internal/todo/ent" "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todopulid/ent" "entgo.io/contrib/entgql/internal/todopulid/ent/schema/pulid" ) +// Types is the resolver for the types field. +func (r *categoryResolver) Types(ctx context.Context, obj *ent.Category) (*CategoryTypes, error) { + panic(fmt.Errorf("not implemented")) +} + +// ID is the resolver for the id field. +func (r *organizationResolver) ID(ctx context.Context, obj *ent1.Workspace) (pulid.ID, error) { + panic(fmt.Errorf("not implemented")) +} + +// Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id pulid.ID) (ent.Noder, error) { return r.client.Noder(ctx, id, ent.WithNodeType(ent.IDToType)) } +// Nodes is the resolver for the nodes field. func (r *queryResolver) Nodes(ctx context.Context, ids []pulid.ID) ([]ent.Noder, error) { return r.client.Noders(ctx, ids, ent.WithNodeType(ent.IDToType)) } +// BillProducts is the resolver for the billProducts field. func (r *queryResolver) BillProducts(ctx context.Context) ([]*ent.BillProduct, error) { return r.client.BillProduct.Query().All(ctx) } +// Categories is the resolver for the categories field. func (r *queryResolver) Categories(ctx context.Context, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryList, error) { panic(fmt.Errorf("not implemented")) } +// Groups is the resolver for the groups field. func (r *queryResolver) Groups(ctx context.Context, limit *int, offset *int, where *ent.GroupWhereInput) (*ent.GroupList, error) { return r.client.Group.Query(). PaginateLimitOffset(ctx, limit, offset, @@ -49,11 +66,13 @@ func (r *queryResolver) Groups(ctx context.Context, limit *int, offset *int, whe ) } +// OneToMany is the resolver for the oneToMany field. func (r *queryResolver) OneToMany(ctx context.Context, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) (*OneToManyList, error) { panic(fmt.Errorf("not implemented")) } -func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { +// Todos is the resolver for the todos field. +func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { return r.client.Todo.Query(). PaginateLimitOffset(ctx, limit, offset, ent.WithTodoOrder(orderBy), @@ -61,6 +80,7 @@ func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orde ) } +// Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) { return r.client.User.Query(). PaginateLimitOffset(ctx, limit, offset, @@ -68,82 +88,112 @@ func (r *queryResolver) Users(ctx context.Context, limit *int, offset *int, orde ) } +// Status is the resolver for the status field. func (r *todoResolver) Status(ctx context.Context, obj *ent.Todo) (todo.Status, error) { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *userResolver) Username(ctx context.Context, obj *ent.User) (string, error) { panic(fmt.Errorf("not implemented")) } +// Friends is the resolver for the friends field. func (r *userResolver) Friends(ctx context.Context, obj *ent.User, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) { panic(fmt.Errorf("not implemented")) } +// Friendships is the resolver for the friendships field. func (r *userResolver) Friendships(ctx context.Context, obj *ent.User, limit *int, offset *int, where *ent.FriendshipWhereInput) (*ent.FriendshipList, error) { panic(fmt.Errorf("not implemented")) } +// Types is the resolver for the types field. +func (r *createCategoryInputResolver) Types(ctx context.Context, obj *ent.CreateCategoryInput, data *CategoryTypesInput) error { + panic(fmt.Errorf("not implemented")) +} + +// Status is the resolver for the status field. func (r *createTodoInputResolver) Status(ctx context.Context, obj *ent.CreateTodoInput, data todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *createUserInputResolver) Username(ctx context.Context, obj *ent.CreateUserInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// Status is the resolver for the status field. func (r *todoWhereInputResolver) Status(ctx context.Context, obj *ent.TodoWhereInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusNeq is the resolver for the statusNEQ field. func (r *todoWhereInputResolver) StatusNeq(ctx context.Context, obj *ent.TodoWhereInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusIn is the resolver for the statusIn field. func (r *todoWhereInputResolver) StatusIn(ctx context.Context, obj *ent.TodoWhereInput, data []todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusNotIn is the resolver for the statusNotIn field. func (r *todoWhereInputResolver) StatusNotIn(ctx context.Context, obj *ent.TodoWhereInput, data []todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Types is the resolver for the types field. +func (r *updateCategoryInputResolver) Types(ctx context.Context, obj *ent.UpdateCategoryInput, data *CategoryTypesInput) error { + panic(fmt.Errorf("not implemented")) +} + +// Status is the resolver for the status field. func (r *updateTodoInputResolver) Status(ctx context.Context, obj *ent.UpdateTodoInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *updateUserInputResolver) Username(ctx context.Context, obj *ent.UpdateUserInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *userWhereInputResolver) Username(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameNeq is the resolver for the usernameNEQ field. func (r *userWhereInputResolver) UsernameNeq(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameIn is the resolver for the usernameIn field. func (r *userWhereInputResolver) UsernameIn(ctx context.Context, obj *ent.UserWhereInput, data []string) error { panic(fmt.Errorf("not implemented")) } +// UsernameNotIn is the resolver for the usernameNotIn field. func (r *userWhereInputResolver) UsernameNotIn(ctx context.Context, obj *ent.UserWhereInput, data []string) error { panic(fmt.Errorf("not implemented")) } +// UsernameGt is the resolver for the usernameGT field. func (r *userWhereInputResolver) UsernameGt(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameGte is the resolver for the usernameGTE field. func (r *userWhereInputResolver) UsernameGte(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameLt is the resolver for the usernameLT field. func (r *userWhereInputResolver) UsernameLt(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameLte is the resolver for the usernameLTE field. func (r *userWhereInputResolver) UsernameLte(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } @@ -151,6 +201,9 @@ func (r *userWhereInputResolver) UsernameLte(ctx context.Context, obj *ent.UserW // Category returns CategoryResolver implementation. func (r *Resolver) Category() CategoryResolver { return &categoryResolver{r} } +// Organization returns OrganizationResolver implementation. +func (r *Resolver) Organization() OrganizationResolver { return &organizationResolver{r} } + // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } @@ -174,6 +227,11 @@ func (r *Resolver) CreateUserInput() CreateUserInputResolver { return &createUse // TodoWhereInput returns TodoWhereInputResolver implementation. func (r *Resolver) TodoWhereInput() TodoWhereInputResolver { return &todoWhereInputResolver{r} } +// UpdateCategoryInput returns UpdateCategoryInputResolver implementation. +func (r *Resolver) UpdateCategoryInput() UpdateCategoryInputResolver { + return &updateCategoryInputResolver{r} +} + // UpdateTodoInput returns UpdateTodoInputResolver implementation. func (r *Resolver) UpdateTodoInput() UpdateTodoInputResolver { return &updateTodoInputResolver{r} } @@ -184,6 +242,7 @@ func (r *Resolver) UpdateUserInput() UpdateUserInputResolver { return &updateUse func (r *Resolver) UserWhereInput() UserWhereInputResolver { return &userWhereInputResolver{r} } type categoryResolver struct{ *Resolver } +type organizationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } type todoResolver struct{ *Resolver } type userResolver struct{ *Resolver } @@ -191,6 +250,7 @@ type createCategoryInputResolver struct{ *Resolver } type createTodoInputResolver struct{ *Resolver } type createUserInputResolver struct{ *Resolver } type todoWhereInputResolver struct{ *Resolver } +type updateCategoryInputResolver struct{ *Resolver } type updateTodoInputResolver struct{ *Resolver } type updateUserInputResolver struct{ *Resolver } type userWhereInputResolver struct{ *Resolver } diff --git a/entgql/internal/todopulid/ent/billproduct/where.go b/entgql/internal/todopulid/ent/billproduct/where.go index ffc1ce09e..0063f5328 100644 --- a/entgql/internal/todopulid/ent/billproduct/where.go +++ b/entgql/internal/todopulid/ent/billproduct/where.go @@ -254,32 +254,15 @@ func QuantityLTE(v uint64) predicate.BillProduct { // And groups predicates with the AND operator between them. func And(predicates ...predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BillProduct(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BillProduct(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.BillProduct(sql.NotPredicates(p)) } diff --git a/entgql/internal/todopulid/ent/billproduct_create.go b/entgql/internal/todopulid/ent/billproduct_create.go index e5c2a13d8..81ec7dfed 100644 --- a/entgql/internal/todopulid/ent/billproduct_create.go +++ b/entgql/internal/todopulid/ent/billproduct_create.go @@ -74,7 +74,7 @@ func (bpc *BillProductCreate) Mutation() *BillProductMutation { // Save creates the BillProduct in the database. func (bpc *BillProductCreate) Save(ctx context.Context) (*BillProduct, error) { bpc.defaults() - return withHooks[*BillProduct, BillProductMutation](ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) + return withHooks(ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -171,11 +171,15 @@ func (bpc *BillProductCreate) createSpec() (*BillProduct, *sqlgraph.CreateSpec) // BillProductCreateBulk is the builder for creating many BillProduct entities in bulk. type BillProductCreateBulk struct { config + err error builders []*BillProductCreate } // Save creates the BillProduct entities in the database. func (bpcb *BillProductCreateBulk) Save(ctx context.Context) ([]*BillProduct, error) { + if bpcb.err != nil { + return nil, bpcb.err + } specs := make([]*sqlgraph.CreateSpec, len(bpcb.builders)) nodes := make([]*BillProduct, len(bpcb.builders)) mutators := make([]Mutator, len(bpcb.builders)) diff --git a/entgql/internal/todopulid/ent/billproduct_delete.go b/entgql/internal/todopulid/ent/billproduct_delete.go index 1d10a37d5..1ac3fbb1a 100644 --- a/entgql/internal/todopulid/ent/billproduct_delete.go +++ b/entgql/internal/todopulid/ent/billproduct_delete.go @@ -41,7 +41,7 @@ func (bpd *BillProductDelete) Where(ps ...predicate.BillProduct) *BillProductDel // Exec executes the deletion query and returns how many vertices were deleted. func (bpd *BillProductDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, BillProductMutation](ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) + return withHooks(ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/billproduct_update.go b/entgql/internal/todopulid/ent/billproduct_update.go index f5d0b9bbd..81207fee3 100644 --- a/entgql/internal/todopulid/ent/billproduct_update.go +++ b/entgql/internal/todopulid/ent/billproduct_update.go @@ -47,12 +47,28 @@ func (bpu *BillProductUpdate) SetName(s string) *BillProductUpdate { return bpu } +// SetNillableName sets the "name" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableName(s *string) *BillProductUpdate { + if s != nil { + bpu.SetName(*s) + } + return bpu +} + // SetSku sets the "sku" field. func (bpu *BillProductUpdate) SetSku(s string) *BillProductUpdate { bpu.mutation.SetSku(s) return bpu } +// SetNillableSku sets the "sku" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableSku(s *string) *BillProductUpdate { + if s != nil { + bpu.SetSku(*s) + } + return bpu +} + // SetQuantity sets the "quantity" field. func (bpu *BillProductUpdate) SetQuantity(u uint64) *BillProductUpdate { bpu.mutation.ResetQuantity() @@ -60,6 +76,14 @@ func (bpu *BillProductUpdate) SetQuantity(u uint64) *BillProductUpdate { return bpu } +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableQuantity(u *uint64) *BillProductUpdate { + if u != nil { + bpu.SetQuantity(*u) + } + return bpu +} + // AddQuantity adds u to the "quantity" field. func (bpu *BillProductUpdate) AddQuantity(u int64) *BillProductUpdate { bpu.mutation.AddQuantity(u) @@ -73,7 +97,7 @@ func (bpu *BillProductUpdate) Mutation() *BillProductMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (bpu *BillProductUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, BillProductMutation](ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) + return withHooks(ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -145,12 +169,28 @@ func (bpuo *BillProductUpdateOne) SetName(s string) *BillProductUpdateOne { return bpuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableName(s *string) *BillProductUpdateOne { + if s != nil { + bpuo.SetName(*s) + } + return bpuo +} + // SetSku sets the "sku" field. func (bpuo *BillProductUpdateOne) SetSku(s string) *BillProductUpdateOne { bpuo.mutation.SetSku(s) return bpuo } +// SetNillableSku sets the "sku" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableSku(s *string) *BillProductUpdateOne { + if s != nil { + bpuo.SetSku(*s) + } + return bpuo +} + // SetQuantity sets the "quantity" field. func (bpuo *BillProductUpdateOne) SetQuantity(u uint64) *BillProductUpdateOne { bpuo.mutation.ResetQuantity() @@ -158,6 +198,14 @@ func (bpuo *BillProductUpdateOne) SetQuantity(u uint64) *BillProductUpdateOne { return bpuo } +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableQuantity(u *uint64) *BillProductUpdateOne { + if u != nil { + bpuo.SetQuantity(*u) + } + return bpuo +} + // AddQuantity adds u to the "quantity" field. func (bpuo *BillProductUpdateOne) AddQuantity(u int64) *BillProductUpdateOne { bpuo.mutation.AddQuantity(u) @@ -184,7 +232,7 @@ func (bpuo *BillProductUpdateOne) Select(field string, fields ...string) *BillPr // Save executes the query and returns the updated BillProduct entity. func (bpuo *BillProductUpdateOne) Save(ctx context.Context) (*BillProduct, error) { - return withHooks[*BillProduct, BillProductMutation](ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) + return withHooks(ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/category.go b/entgql/internal/todopulid/ent/category.go index aa196729f..978d17cf0 100644 --- a/entgql/internal/todopulid/ent/category.go +++ b/entgql/internal/todopulid/ent/category.go @@ -40,6 +40,8 @@ type Category struct { Status category.Status `json:"status,omitempty"` // Config holds the value of the "config" field. Config *schematype.CategoryConfig `json:"config,omitempty"` + // Types holds the value of the "types" field. + Types *schematype.CategoryTypes `json:"types,omitempty"` // Duration holds the value of the "duration" field. Duration time.Duration `json:"duration,omitempty"` // Count holds the value of the "count" field. @@ -91,7 +93,7 @@ func (*Category) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case category.FieldStrings: + case category.FieldTypes, category.FieldStrings: values[i] = new([]byte) case category.FieldID: values[i] = new(pulid.ID) @@ -140,6 +142,14 @@ func (c *Category) assignValues(columns []string, values []any) error { } else if value != nil { c.Config = value } + case category.FieldTypes: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field types", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &c.Types); err != nil { + return fmt.Errorf("unmarshal field types: %w", err) + } + } case category.FieldDuration: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field duration", values[i]) @@ -215,6 +225,9 @@ func (c *Category) String() string { builder.WriteString("config=") builder.WriteString(fmt.Sprintf("%v", c.Config)) builder.WriteString(", ") + builder.WriteString("types=") + builder.WriteString(fmt.Sprintf("%v", c.Types)) + builder.WriteString(", ") builder.WriteString("duration=") builder.WriteString(fmt.Sprintf("%v", c.Duration)) builder.WriteString(", ") diff --git a/entgql/internal/todopulid/ent/category/category.go b/entgql/internal/todopulid/ent/category/category.go index 8b5f2a34d..2b58d1801 100644 --- a/entgql/internal/todopulid/ent/category/category.go +++ b/entgql/internal/todopulid/ent/category/category.go @@ -37,6 +37,8 @@ const ( FieldStatus = "status" // FieldConfig holds the string denoting the config field in the database. FieldConfig = "config" + // FieldTypes holds the string denoting the types field in the database. + FieldTypes = "types" // FieldDuration holds the string denoting the duration field in the database. FieldDuration = "duration" // FieldCount holds the string denoting the count field in the database. @@ -66,6 +68,7 @@ var Columns = []string{ FieldText, FieldStatus, FieldConfig, + FieldTypes, FieldDuration, FieldCount, FieldStrings, diff --git a/entgql/internal/todopulid/ent/category/where.go b/entgql/internal/todopulid/ent/category/where.go index 1cf633266..67fd18815 100644 --- a/entgql/internal/todopulid/ent/category/where.go +++ b/entgql/internal/todopulid/ent/category/where.go @@ -227,6 +227,16 @@ func ConfigNotNil() predicate.Category { return predicate.Category(sql.FieldNotNull(FieldConfig)) } +// TypesIsNil applies the IsNil predicate on the "types" field. +func TypesIsNil() predicate.Category { + return predicate.Category(sql.FieldIsNull(FieldTypes)) +} + +// TypesNotNil applies the NotNil predicate on the "types" field. +func TypesNotNil() predicate.Category { + return predicate.Category(sql.FieldNotNull(FieldTypes)) +} + // DurationEQ applies the EQ predicate on the "duration" field. func DurationEQ(v time.Duration) predicate.Category { vc := int64(v) @@ -399,32 +409,15 @@ func HasSubCategoriesWith(preds ...predicate.Category) predicate.Category { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Category(sql.NotPredicates(p)) } diff --git a/entgql/internal/todopulid/ent/category_create.go b/entgql/internal/todopulid/ent/category_create.go index cd63430b0..520504003 100644 --- a/entgql/internal/todopulid/ent/category_create.go +++ b/entgql/internal/todopulid/ent/category_create.go @@ -55,6 +55,12 @@ func (cc *CategoryCreate) SetConfig(sc *schematype.CategoryConfig) *CategoryCrea return cc } +// SetTypes sets the "types" field. +func (cc *CategoryCreate) SetTypes(st *schematype.CategoryTypes) *CategoryCreate { + cc.mutation.SetTypes(st) + return cc +} + // SetDuration sets the "duration" field. func (cc *CategoryCreate) SetDuration(t time.Duration) *CategoryCreate { cc.mutation.SetDuration(t) @@ -141,7 +147,7 @@ func (cc *CategoryCreate) Mutation() *CategoryMutation { // Save creates the Category in the database. func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error) { cc.defaults() - return withHooks[*Category, CategoryMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) + return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -239,6 +245,10 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { _spec.SetField(category.FieldConfig, field.TypeOther, value) _node.Config = value } + if value, ok := cc.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + _node.Types = value + } if value, ok := cc.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) _node.Duration = value @@ -289,11 +299,15 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { // CategoryCreateBulk is the builder for creating many Category entities in bulk. type CategoryCreateBulk struct { config + err error builders []*CategoryCreate } // Save creates the Category entities in the database. func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error) { + if ccb.err != nil { + return nil, ccb.err + } specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) nodes := make([]*Category, len(ccb.builders)) mutators := make([]Mutator, len(ccb.builders)) diff --git a/entgql/internal/todopulid/ent/category_delete.go b/entgql/internal/todopulid/ent/category_delete.go index 53f8a1ece..54d1a26a9 100644 --- a/entgql/internal/todopulid/ent/category_delete.go +++ b/entgql/internal/todopulid/ent/category_delete.go @@ -41,7 +41,7 @@ func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (cd *CategoryDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) + return withHooks(ctx, cd.sqlExec, cd.mutation, cd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/category_update.go b/entgql/internal/todopulid/ent/category_update.go index 866790750..ee945dc28 100644 --- a/entgql/internal/todopulid/ent/category_update.go +++ b/entgql/internal/todopulid/ent/category_update.go @@ -52,12 +52,28 @@ func (cu *CategoryUpdate) SetText(s string) *CategoryUpdate { return cu } +// SetNillableText sets the "text" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableText(s *string) *CategoryUpdate { + if s != nil { + cu.SetText(*s) + } + return cu +} + // SetStatus sets the "status" field. func (cu *CategoryUpdate) SetStatus(c category.Status) *CategoryUpdate { cu.mutation.SetStatus(c) return cu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableStatus(c *category.Status) *CategoryUpdate { + if c != nil { + cu.SetStatus(*c) + } + return cu +} + // SetConfig sets the "config" field. func (cu *CategoryUpdate) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdate { cu.mutation.SetConfig(sc) @@ -70,6 +86,18 @@ func (cu *CategoryUpdate) ClearConfig() *CategoryUpdate { return cu } +// SetTypes sets the "types" field. +func (cu *CategoryUpdate) SetTypes(st *schematype.CategoryTypes) *CategoryUpdate { + cu.mutation.SetTypes(st) + return cu +} + +// ClearTypes clears the value of the "types" field. +func (cu *CategoryUpdate) ClearTypes() *CategoryUpdate { + cu.mutation.ClearTypes() + return cu +} + // SetDuration sets the "duration" field. func (cu *CategoryUpdate) SetDuration(t time.Duration) *CategoryUpdate { cu.mutation.ResetDuration() @@ -221,7 +249,7 @@ func (cu *CategoryUpdate) RemoveSubCategories(c ...*Category) *CategoryUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) + return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -285,6 +313,12 @@ func (cu *CategoryUpdate) sqlSave(ctx context.Context) (n int, err error) { if cu.mutation.ConfigCleared() { _spec.ClearField(category.FieldConfig, field.TypeOther) } + if value, ok := cu.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + } + if cu.mutation.TypesCleared() { + _spec.ClearField(category.FieldTypes, field.TypeJSON) + } if value, ok := cu.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) } @@ -430,12 +464,28 @@ func (cuo *CategoryUpdateOne) SetText(s string) *CategoryUpdateOne { return cuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableText(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetText(*s) + } + return cuo +} + // SetStatus sets the "status" field. func (cuo *CategoryUpdateOne) SetStatus(c category.Status) *CategoryUpdateOne { cuo.mutation.SetStatus(c) return cuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableStatus(c *category.Status) *CategoryUpdateOne { + if c != nil { + cuo.SetStatus(*c) + } + return cuo +} + // SetConfig sets the "config" field. func (cuo *CategoryUpdateOne) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdateOne { cuo.mutation.SetConfig(sc) @@ -448,6 +498,18 @@ func (cuo *CategoryUpdateOne) ClearConfig() *CategoryUpdateOne { return cuo } +// SetTypes sets the "types" field. +func (cuo *CategoryUpdateOne) SetTypes(st *schematype.CategoryTypes) *CategoryUpdateOne { + cuo.mutation.SetTypes(st) + return cuo +} + +// ClearTypes clears the value of the "types" field. +func (cuo *CategoryUpdateOne) ClearTypes() *CategoryUpdateOne { + cuo.mutation.ClearTypes() + return cuo +} + // SetDuration sets the "duration" field. func (cuo *CategoryUpdateOne) SetDuration(t time.Duration) *CategoryUpdateOne { cuo.mutation.ResetDuration() @@ -612,7 +674,7 @@ func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUp // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) + return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -693,6 +755,12 @@ func (cuo *CategoryUpdateOne) sqlSave(ctx context.Context) (_node *Category, err if cuo.mutation.ConfigCleared() { _spec.ClearField(category.FieldConfig, field.TypeOther) } + if value, ok := cuo.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + } + if cuo.mutation.TypesCleared() { + _spec.ClearField(category.FieldTypes, field.TypeJSON) + } if value, ok := cuo.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) } diff --git a/entgql/internal/todopulid/ent/client.go b/entgql/internal/todopulid/ent/client.go index a83c50d26..2abfe0fb8 100644 --- a/entgql/internal/todopulid/ent/client.go +++ b/entgql/internal/todopulid/ent/client.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entgql/internal/todopulid/ent/migrate" "entgo.io/contrib/entgql/internal/todopulid/ent/schema/pulid" @@ -61,9 +62,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -97,6 +96,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -144,11 +150,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -292,6 +301,21 @@ func (c *BillProductClient) CreateBulk(builders ...*BillProductCreate) *BillProd return &BillProductCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BillProductClient) MapCreateBulk(slice any, setFunc func(*BillProductCreate, int)) *BillProductCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BillProductCreateBulk{err: fmt.Errorf("calling to BillProductClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BillProductCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BillProductCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for BillProduct. func (c *BillProductClient) Update() *BillProductUpdate { mutation := newBillProductMutation(c.config, OpUpdate) @@ -410,6 +434,21 @@ func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreate return &CategoryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CategoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CategoryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Category. func (c *CategoryClient) Update() *CategoryUpdate { mutation := newCategoryMutation(c.config, OpUpdate) @@ -560,6 +599,21 @@ func (c *FriendshipClient) CreateBulk(builders ...*FriendshipCreate) *Friendship return &FriendshipCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *FriendshipClient) MapCreateBulk(slice any, setFunc func(*FriendshipCreate, int)) *FriendshipCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &FriendshipCreateBulk{err: fmt.Errorf("calling to FriendshipClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*FriendshipCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &FriendshipCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Friendship. func (c *FriendshipClient) Update() *FriendshipUpdate { mutation := newFriendshipMutation(c.config, OpUpdate) @@ -710,6 +764,21 @@ func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk { return &GroupCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GroupCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GroupCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Group. func (c *GroupClient) Update() *GroupUpdate { mutation := newGroupMutation(c.config, OpUpdate) @@ -844,6 +913,21 @@ func (c *TodoClient) CreateBulk(builders ...*TodoCreate) *TodoCreateBulk { return &TodoCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TodoClient) MapCreateBulk(slice any, setFunc func(*TodoCreate, int)) *TodoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TodoCreateBulk{err: fmt.Errorf("calling to TodoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TodoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TodoCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Todo. func (c *TodoClient) Update() *TodoUpdate { mutation := newTodoMutation(c.config, OpUpdate) @@ -1026,6 +1110,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) @@ -1192,6 +1291,21 @@ func (c *VerySecretClient) CreateBulk(builders ...*VerySecretCreate) *VerySecret return &VerySecretCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *VerySecretClient) MapCreateBulk(slice any, setFunc func(*VerySecretCreate, int)) *VerySecretCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VerySecretCreateBulk{err: fmt.Errorf("calling to VerySecretClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VerySecretCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VerySecretCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for VerySecret. func (c *VerySecretClient) Update() *VerySecretUpdate { mutation := newVerySecretMutation(c.config, OpUpdate) diff --git a/entgql/internal/todopulid/ent/friendship/where.go b/entgql/internal/todopulid/ent/friendship/where.go index f79af66c2..49666e6ee 100644 --- a/entgql/internal/todopulid/ent/friendship/where.go +++ b/entgql/internal/todopulid/ent/friendship/where.go @@ -313,32 +313,15 @@ func HasFriendWith(preds ...predicate.User) predicate.Friendship { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Friendship(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Friendship(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Friendship(sql.NotPredicates(p)) } diff --git a/entgql/internal/todopulid/ent/friendship_create.go b/entgql/internal/todopulid/ent/friendship_create.go index b3a86c75a..8117b0b8e 100644 --- a/entgql/internal/todopulid/ent/friendship_create.go +++ b/entgql/internal/todopulid/ent/friendship_create.go @@ -94,7 +94,7 @@ func (fc *FriendshipCreate) Mutation() *FriendshipMutation { // Save creates the Friendship in the database. func (fc *FriendshipCreate) Save(ctx context.Context) (*Friendship, error) { fc.defaults() - return withHooks[*Friendship, FriendshipMutation](ctx, fc.sqlSave, fc.mutation, fc.hooks) + return withHooks(ctx, fc.sqlSave, fc.mutation, fc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -227,11 +227,15 @@ func (fc *FriendshipCreate) createSpec() (*Friendship, *sqlgraph.CreateSpec) { // FriendshipCreateBulk is the builder for creating many Friendship entities in bulk. type FriendshipCreateBulk struct { config + err error builders []*FriendshipCreate } // Save creates the Friendship entities in the database. func (fcb *FriendshipCreateBulk) Save(ctx context.Context) ([]*Friendship, error) { + if fcb.err != nil { + return nil, fcb.err + } specs := make([]*sqlgraph.CreateSpec, len(fcb.builders)) nodes := make([]*Friendship, len(fcb.builders)) mutators := make([]Mutator, len(fcb.builders)) diff --git a/entgql/internal/todopulid/ent/friendship_delete.go b/entgql/internal/todopulid/ent/friendship_delete.go index e20661159..ee544beaf 100644 --- a/entgql/internal/todopulid/ent/friendship_delete.go +++ b/entgql/internal/todopulid/ent/friendship_delete.go @@ -41,7 +41,7 @@ func (fd *FriendshipDelete) Where(ps ...predicate.Friendship) *FriendshipDelete // Exec executes the deletion query and returns how many vertices were deleted. func (fd *FriendshipDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, FriendshipMutation](ctx, fd.sqlExec, fd.mutation, fd.hooks) + return withHooks(ctx, fd.sqlExec, fd.mutation, fd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/friendship_update.go b/entgql/internal/todopulid/ent/friendship_update.go index 4e5196821..7e37f74cd 100644 --- a/entgql/internal/todopulid/ent/friendship_update.go +++ b/entgql/internal/todopulid/ent/friendship_update.go @@ -64,12 +64,28 @@ func (fu *FriendshipUpdate) SetUserID(pu pulid.ID) *FriendshipUpdate { return fu } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (fu *FriendshipUpdate) SetNillableUserID(pu *pulid.ID) *FriendshipUpdate { + if pu != nil { + fu.SetUserID(*pu) + } + return fu +} + // SetFriendID sets the "friend_id" field. func (fu *FriendshipUpdate) SetFriendID(pu pulid.ID) *FriendshipUpdate { fu.mutation.SetFriendID(pu) return fu } +// SetNillableFriendID sets the "friend_id" field if the given value is not nil. +func (fu *FriendshipUpdate) SetNillableFriendID(pu *pulid.ID) *FriendshipUpdate { + if pu != nil { + fu.SetFriendID(*pu) + } + return fu +} + // SetUser sets the "user" edge to the User entity. func (fu *FriendshipUpdate) SetUser(u *User) *FriendshipUpdate { return fu.SetUserID(u.ID) @@ -99,7 +115,7 @@ func (fu *FriendshipUpdate) ClearFriend() *FriendshipUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (fu *FriendshipUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, FriendshipMutation](ctx, fu.sqlSave, fu.mutation, fu.hooks) + return withHooks(ctx, fu.sqlSave, fu.mutation, fu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -248,12 +264,28 @@ func (fuo *FriendshipUpdateOne) SetUserID(pu pulid.ID) *FriendshipUpdateOne { return fuo } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (fuo *FriendshipUpdateOne) SetNillableUserID(pu *pulid.ID) *FriendshipUpdateOne { + if pu != nil { + fuo.SetUserID(*pu) + } + return fuo +} + // SetFriendID sets the "friend_id" field. func (fuo *FriendshipUpdateOne) SetFriendID(pu pulid.ID) *FriendshipUpdateOne { fuo.mutation.SetFriendID(pu) return fuo } +// SetNillableFriendID sets the "friend_id" field if the given value is not nil. +func (fuo *FriendshipUpdateOne) SetNillableFriendID(pu *pulid.ID) *FriendshipUpdateOne { + if pu != nil { + fuo.SetFriendID(*pu) + } + return fuo +} + // SetUser sets the "user" edge to the User entity. func (fuo *FriendshipUpdateOne) SetUser(u *User) *FriendshipUpdateOne { return fuo.SetUserID(u.ID) @@ -296,7 +328,7 @@ func (fuo *FriendshipUpdateOne) Select(field string, fields ...string) *Friendsh // Save executes the query and returns the updated Friendship entity. func (fuo *FriendshipUpdateOne) Save(ctx context.Context) (*Friendship, error) { - return withHooks[*Friendship, FriendshipMutation](ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) + return withHooks(ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/gql_collection.go b/entgql/internal/todopulid/ent/gql_collection.go index 3588b0750..5c5e992b3 100644 --- a/entgql/internal/todopulid/ent/gql_collection.go +++ b/entgql/internal/todopulid/ent/gql_collection.go @@ -39,13 +39,13 @@ func (bp *BillProductQuery) CollectFields(ctx context.Context, satisfies ...stri if fc == nil { return bp, nil } - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := bp.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return bp, nil } -func (bp *BillProductQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (bp *BillProductQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -86,7 +86,7 @@ type billproductPaginateArgs struct { opts []BillProductPaginateOption } -func newBillProductPaginateArgs(rv map[string]interface{}) *billproductPaginateArgs { +func newBillProductPaginateArgs(rv map[string]any) *billproductPaginateArgs { args := &billproductPaginateArgs{} if rv == nil { return args @@ -109,13 +109,13 @@ func (c *CategoryQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return c, nil } - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := c.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return c, nil } -func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (c *CategoryQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -124,6 +124,7 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "todos": var ( alias = field.Alias @@ -192,25 +193,30 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(category.TodosColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(category.TodosColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } c.WithNamedTodos(alias, func(wq *TodoQuery) { *wq = *query }) + case "subCategories": var ( alias = field.Alias @@ -283,19 +289,23 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Category")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Category"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Category")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Category"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(category.SubCategoriesPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(category.SubCategoriesPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -317,6 +327,11 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati selectedFields = append(selectedFields, category.FieldConfig) fieldSeen[category.FieldConfig] = struct{}{} } + case "types": + if _, ok := fieldSeen[category.FieldTypes]; !ok { + selectedFields = append(selectedFields, category.FieldTypes) + fieldSeen[category.FieldTypes] = struct{}{} + } case "duration": if _, ok := fieldSeen[category.FieldDuration]; !ok { selectedFields = append(selectedFields, category.FieldDuration) @@ -349,7 +364,7 @@ type categoryPaginateArgs struct { opts []CategoryPaginateOption } -func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { +func newCategoryPaginateArgs(rv map[string]any) *categoryPaginateArgs { args := &categoryPaginateArgs{} if rv == nil { return args @@ -364,10 +379,10 @@ func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { switch v := v.(type) { case []*CategoryOrder: args.opts = append(args.opts, WithCategoryOrder(v)) - case []interface{}: + case []any: var orders []*CategoryOrder for i := range v { - mv, ok := v[i].(map[string]interface{}) + mv, ok := v[i].(map[string]any) if !ok { continue } @@ -400,13 +415,13 @@ func (f *FriendshipQuery) CollectFields(ctx context.Context, satisfies ...string if fc == nil { return f, nil } - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := f.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return f, nil } -func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (f *FriendshipQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -415,13 +430,14 @@ func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "user": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: f.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } f.withUser = query @@ -429,13 +445,14 @@ func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, friendship.FieldUserID) fieldSeen[friendship.FieldUserID] = struct{}{} } + case "friend": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: f.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } f.withFriend = query @@ -475,7 +492,7 @@ type friendshipPaginateArgs struct { opts []FriendshipPaginateOption } -func newFriendshipPaginateArgs(rv map[string]interface{}) *friendshipPaginateArgs { +func newFriendshipPaginateArgs(rv map[string]any) *friendshipPaginateArgs { args := &friendshipPaginateArgs{} if rv == nil { return args @@ -498,13 +515,13 @@ func (gr *GroupQuery) CollectFields(ctx context.Context, satisfies ...string) (* if fc == nil { return gr, nil } - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := gr.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return gr, nil } -func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (gr *GroupQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -513,6 +530,7 @@ func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.Operation ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "users": var ( alias = field.Alias @@ -585,19 +603,23 @@ func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.Operation } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(group.UsersPrimaryKey[1], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(group.UsersPrimaryKey[1], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -626,7 +648,7 @@ type groupPaginateArgs struct { opts []GroupPaginateOption } -func newGroupPaginateArgs(rv map[string]interface{}) *groupPaginateArgs { +func newGroupPaginateArgs(rv map[string]any) *groupPaginateArgs { args := &groupPaginateArgs{} if rv == nil { return args @@ -649,13 +671,13 @@ func (t *TodoQuery) CollectFields(ctx context.Context, satisfies ...string) (*To if fc == nil { return t, nil } - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := t.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return t, nil } -func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (t *TodoQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -664,16 +686,18 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "parent": var ( alias = field.Alias path = append(path, alias) query = (&TodoClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, todoImplementors)...); err != nil { return err } t.withParent = query + case "children": var ( alias = field.Alias @@ -742,32 +766,37 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(todo.ChildrenColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(todo.ChildrenColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } t.WithNamedChildren(alias, func(wq *TodoQuery) { *wq = *query }) + case "category": var ( alias = field.Alias path = append(path, alias) query = (&CategoryClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, categoryImplementors)...); err != nil { return err } t.withCategory = query @@ -832,7 +861,7 @@ type todoPaginateArgs struct { opts []TodoPaginateOption } -func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { +func newTodoPaginateArgs(rv map[string]any) *todoPaginateArgs { args := &todoPaginateArgs{} if rv == nil { return args @@ -845,24 +874,30 @@ func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: - var ( - err1, err2 error - order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithTodoOrder(order)) - } - case *TodoOrder: - if v != nil { - args.opts = append(args.opts, WithTodoOrder(v)) + case []*TodoOrder: + args.opts = append(args.opts, WithTodoOrder(v)) + case []any: + var orders []*TodoOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} + ) + if d, ok := mv[directionField]; ok { + err1 = order.Direction.UnmarshalGQL(d) + } + if f, ok := mv[fieldField]; ok { + err2 = order.Field.UnmarshalGQL(f) + } + if err1 == nil && err2 == nil { + orders = append(orders, order) + } } + args.opts = append(args.opts, WithTodoOrder(orders)) } } if v, ok := rv[whereField].(*TodoWhereInput); ok { @@ -877,13 +912,13 @@ func (u *UserQuery) CollectFields(ctx context.Context, satisfies ...string) (*Us if fc == nil { return u, nil } - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := u.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return u, nil } -func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (u *UserQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -892,6 +927,7 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "groups": var ( alias = field.Alias @@ -964,44 +1000,50 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Group")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Group"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Group")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Group"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(user.GroupsPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(user.GroupsPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } u.WithNamedGroups(alias, func(wq *GroupQuery) { *wq = *query }) + case "friends": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: u.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } u.WithNamedFriends(alias, func(wq *UserQuery) { *wq = *query }) + case "friendships": var ( alias = field.Alias path = append(path, alias) query = (&FriendshipClient{config: u.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, friendshipImplementors)...); err != nil { return err } u.WithNamedFriendships(alias, func(wq *FriendshipQuery) { @@ -1017,6 +1059,11 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo selectedFields = append(selectedFields, user.FieldUsername) fieldSeen[user.FieldUsername] = struct{}{} } + case "requiredMetadata": + if _, ok := fieldSeen[user.FieldRequiredMetadata]; !ok { + selectedFields = append(selectedFields, user.FieldRequiredMetadata) + fieldSeen[user.FieldRequiredMetadata] = struct{}{} + } case "metadata": if _, ok := fieldSeen[user.FieldMetadata]; !ok { selectedFields = append(selectedFields, user.FieldMetadata) @@ -1039,7 +1086,7 @@ type userPaginateArgs struct { opts []UserPaginateOption } -func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { +func newUserPaginateArgs(rv map[string]any) *userPaginateArgs { args := &userPaginateArgs{} if rv == nil { return args @@ -1052,7 +1099,7 @@ func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: + case map[string]any: var ( err1, err2 error order = &UserOrder{Field: &UserOrderField{}, Direction: entgql.OrderDirectionAsc} @@ -1087,35 +1134,18 @@ const ( whereField = "where" ) -func fieldArgs(ctx context.Context, whereInput interface{}, path ...string) map[string]interface{} { - fc := graphql.GetFieldContext(ctx) - if fc == nil { +func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { + field := collectedField(ctx, path...) + if field == nil || field.Arguments == nil { return nil } oc := graphql.GetOperationContext(ctx) - for _, name := range path { - var field *graphql.CollectedField - for _, f := range graphql.CollectFields(oc, fc.Field.Selections, nil) { - if f.Alias == name { - field = &f - break - } - } - if field == nil { - return nil - } - cf, err := fc.Child(ctx, *field) - if err != nil { - args := field.ArgumentMap(oc.Variables) - return unmarshalArgs(ctx, whereInput, args) - } - fc = cf - } - return fc.Args + args := field.ArgumentMap(oc.Variables) + return unmarshalArgs(ctx, whereInput, args) } // unmarshalArgs allows extracting the field arguments from their raw representation. -func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string]interface{}) map[string]interface{} { +func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{limitField, offsetField} { v, ok := args[k] if !ok { @@ -1135,39 +1165,17 @@ func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string] return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } diff --git a/entgql/internal/todopulid/ent/gql_edge.go b/entgql/internal/todopulid/ent/gql_edge.go index c53f3aa9c..8bd234169 100644 --- a/entgql/internal/todopulid/ent/gql_edge.go +++ b/entgql/internal/todopulid/ent/gql_edge.go @@ -23,7 +23,7 @@ import ( ) func (c *Category) Todos( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), @@ -110,7 +110,7 @@ func (t *Todo) Parent(ctx context.Context) (*Todo, error) { } func (t *Todo) Children( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), diff --git a/entgql/internal/todopulid/ent/gql_mutation_input.go b/entgql/internal/todopulid/ent/gql_mutation_input.go index b76b78e69..b7a86e8be 100644 --- a/entgql/internal/todopulid/ent/gql_mutation_input.go +++ b/entgql/internal/todopulid/ent/gql_mutation_input.go @@ -31,6 +31,7 @@ type CreateCategoryInput struct { Text string Status category.Status Config *schematype.CategoryConfig + Types *schematype.CategoryTypes Duration *time.Duration Count *uint64 Strings []string @@ -45,6 +46,9 @@ func (i *CreateCategoryInput) Mutate(m *CategoryMutation) { if v := i.Config; v != nil { m.SetConfig(v) } + if v := i.Types; v != nil { + m.SetTypes(v) + } if v := i.Duration; v != nil { m.SetDuration(*v) } @@ -74,6 +78,8 @@ type UpdateCategoryInput struct { Status *category.Status ClearConfig bool Config *schematype.CategoryConfig + ClearTypes bool + Types *schematype.CategoryTypes ClearDuration bool Duration *time.Duration ClearCount bool @@ -103,6 +109,12 @@ func (i *UpdateCategoryInput) Mutate(m *CategoryMutation) { if v := i.Config; v != nil { m.SetConfig(v) } + if i.ClearTypes { + m.ClearTypes() + } + if v := i.Types; v != nil { + m.SetTypes(v) + } if i.ClearDuration { m.ClearDuration() } @@ -268,12 +280,13 @@ func (c *TodoUpdateOne) SetInput(i UpdateTodoInput) *TodoUpdateOne { // CreateUserInput represents a mutation input for creating users. type CreateUserInput struct { - Name *string - Username *uuid.UUID - Password *string - Metadata map[string]interface{} - GroupIDs []pulid.ID - FriendIDs []pulid.ID + Name *string + Username *uuid.UUID + Password *string + RequiredMetadata map[string]interface{} + Metadata map[string]interface{} + GroupIDs []pulid.ID + FriendIDs []pulid.ID } // Mutate applies the CreateUserInput on the UserMutation builder. @@ -287,6 +300,9 @@ func (i *CreateUserInput) Mutate(m *UserMutation) { if v := i.Password; v != nil { m.SetPassword(*v) } + if v := i.RequiredMetadata; v != nil { + m.SetRequiredMetadata(v) + } if v := i.Metadata; v != nil { m.SetMetadata(v) } @@ -306,18 +322,19 @@ func (c *UserCreate) SetInput(i CreateUserInput) *UserCreate { // UpdateUserInput represents a mutation input for updating users. type UpdateUserInput struct { - Name *string - Username *uuid.UUID - ClearPassword bool - Password *string - ClearMetadata bool - Metadata map[string]interface{} - ClearGroups bool - AddGroupIDs []pulid.ID - RemoveGroupIDs []pulid.ID - ClearFriends bool - AddFriendIDs []pulid.ID - RemoveFriendIDs []pulid.ID + Name *string + Username *uuid.UUID + ClearPassword bool + Password *string + RequiredMetadata map[string]interface{} + ClearMetadata bool + Metadata map[string]interface{} + ClearGroups bool + AddGroupIDs []pulid.ID + RemoveGroupIDs []pulid.ID + ClearFriends bool + AddFriendIDs []pulid.ID + RemoveFriendIDs []pulid.ID } // Mutate applies the UpdateUserInput on the UserMutation builder. @@ -334,6 +351,9 @@ func (i *UpdateUserInput) Mutate(m *UserMutation) { if v := i.Password; v != nil { m.SetPassword(*v) } + if v := i.RequiredMetadata; v != nil { + m.SetRequiredMetadata(v) + } if i.ClearMetadata { m.ClearMetadata() } diff --git a/entgql/internal/todopulid/ent/gql_node.go b/entgql/internal/todopulid/ent/gql_node.go index 0bac8fd12..e2cc76613 100644 --- a/entgql/internal/todopulid/ent/gql_node.go +++ b/entgql/internal/todopulid/ent/gql_node.go @@ -37,23 +37,38 @@ type Noder interface { IsNode() } +var billproductImplementors = []string{"BillProduct", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *BillProduct) IsNode() {} +func (*BillProduct) IsNode() {} + +var categoryImplementors = []string{"Category", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Category) IsNode() {} +func (*Category) IsNode() {} + +var friendshipImplementors = []string{"Friendship", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Friendship) IsNode() {} +func (*Friendship) IsNode() {} + +var groupImplementors = []string{"Group", "Node", "NamedNode"} // IsNode implements the Node interface check for GQLGen. -func (n *Group) IsNode() {} +func (*Group) IsNode() {} + +// IsNamedNode implements the NamedNode interface check for GQLGen. +func (*Group) IsNamedNode() {} + +var todoImplementors = []string{"Todo", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Todo) IsNode() {} +func (*Todo) IsNode() {} + +var userImplementors = []string{"User", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *User) IsNode() {} +func (*User) IsNode() {} var errNodeInvalidID = &NotFoundError{"node"} @@ -120,15 +135,12 @@ func (c *Client) noder(ctx context.Context, table string, id pulid.ID) (Noder, e } query := c.BillProduct.Query(). Where(billproduct.ID(uid)) - query, err := query.CollectFields(ctx, "BillProduct") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, billproductImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case category.Table: var uid pulid.ID if err := uid.UnmarshalGQL(id); err != nil { @@ -136,15 +148,12 @@ func (c *Client) noder(ctx context.Context, table string, id pulid.ID) (Noder, e } query := c.Category.Query(). Where(category.ID(uid)) - query, err := query.CollectFields(ctx, "Category") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, categoryImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case friendship.Table: var uid pulid.ID if err := uid.UnmarshalGQL(id); err != nil { @@ -152,15 +161,12 @@ func (c *Client) noder(ctx context.Context, table string, id pulid.ID) (Noder, e } query := c.Friendship.Query(). Where(friendship.ID(uid)) - query, err := query.CollectFields(ctx, "Friendship") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, friendshipImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case group.Table: var uid pulid.ID if err := uid.UnmarshalGQL(id); err != nil { @@ -168,15 +174,12 @@ func (c *Client) noder(ctx context.Context, table string, id pulid.ID) (Noder, e } query := c.Group.Query(). Where(group.ID(uid)) - query, err := query.CollectFields(ctx, "Group") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, groupImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case todo.Table: var uid pulid.ID if err := uid.UnmarshalGQL(id); err != nil { @@ -184,15 +187,12 @@ func (c *Client) noder(ctx context.Context, table string, id pulid.ID) (Noder, e } query := c.Todo.Query(). Where(todo.ID(uid)) - query, err := query.CollectFields(ctx, "Todo") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, todoImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case user.Table: var uid pulid.ID if err := uid.UnmarshalGQL(id); err != nil { @@ -200,15 +200,12 @@ func (c *Client) noder(ctx context.Context, table string, id pulid.ID) (Noder, e } query := c.User.Query(). Where(user.ID(uid)) - query, err := query.CollectFields(ctx, "User") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, userImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) } @@ -285,7 +282,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []pulid.ID) ([]No case billproduct.Table: query := c.BillProduct.Query(). Where(billproduct.IDIn(ids...)) - query, err := query.CollectFields(ctx, "BillProduct") + query, err := query.CollectFields(ctx, billproductImplementors...) if err != nil { return nil, err } @@ -301,7 +298,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []pulid.ID) ([]No case category.Table: query := c.Category.Query(). Where(category.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Category") + query, err := query.CollectFields(ctx, categoryImplementors...) if err != nil { return nil, err } @@ -317,7 +314,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []pulid.ID) ([]No case friendship.Table: query := c.Friendship.Query(). Where(friendship.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Friendship") + query, err := query.CollectFields(ctx, friendshipImplementors...) if err != nil { return nil, err } @@ -333,7 +330,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []pulid.ID) ([]No case group.Table: query := c.Group.Query(). Where(group.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Group") + query, err := query.CollectFields(ctx, groupImplementors...) if err != nil { return nil, err } @@ -349,7 +346,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []pulid.ID) ([]No case todo.Table: query := c.Todo.Query(). Where(todo.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Todo") + query, err := query.CollectFields(ctx, todoImplementors...) if err != nil { return nil, err } @@ -365,7 +362,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []pulid.ID) ([]No case user.Table: query := c.User.Query(). Where(user.IDIn(ids...)) - query, err := query.CollectFields(ctx, "User") + query, err := query.CollectFields(ctx, userImplementors...) if err != nil { return nil, err } diff --git a/entgql/internal/todopulid/ent/gql_pagination.go b/entgql/internal/todopulid/ent/gql_pagination.go index 878032f27..b894abb0e 100644 --- a/entgql/internal/todopulid/ent/gql_pagination.go +++ b/entgql/internal/todopulid/ent/gql_pagination.go @@ -337,12 +337,12 @@ func (bp *BillProductQuery) PaginateLimitOffset( bp.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bp.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := bp.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -375,7 +375,9 @@ func (bp *BillProductQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = bp.Clone().Count(ctx); err != nil { + c := bp.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -388,16 +390,17 @@ func (bp *BillProductQuery) Paginate( if bp, err = pager.applyCursors(bp, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { bp.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -571,11 +574,11 @@ func (p *categoryPager) applyFilter(query *CategoryQuery) (*CategoryQuery, error } func (p *categoryPager) toCursor(c *Category) Cursor { - cs := make([]any, 0, len(p.order)) - for _, o := range p.order { - cs = append(cs, o.Field.toCursor(c).Value) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(c).Value) } - return Cursor{ID: c.ID, Value: cs} + return Cursor{ID: c.ID, Value: cs_} } func (p *categoryPager) applyCursors(query *CategoryQuery, after, before *Cursor) (*CategoryQuery, error) { @@ -702,12 +705,12 @@ func (c *CategoryQuery) PaginateLimitOffset( c.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -740,7 +743,9 @@ func (c *CategoryQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = c.Clone().Count(ctx); err != nil { + c := c.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -753,16 +758,17 @@ func (c *CategoryQuery) Paginate( if c, err = pager.applyCursors(c, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { c.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -790,6 +796,20 @@ var ( } }, } + // CategoryOrderFieldStatus orders Category by status. + CategoryOrderFieldStatus = &CategoryOrderField{ + Value: func(c *Category) (ent.Value, error) { + return c.Status, nil + }, + column: category.FieldStatus, + toTerm: category.ByStatus, + toCursor: func(c *Category) Cursor { + return Cursor{ + ID: c.ID, + Value: c.Status, + } + }, + } // CategoryOrderFieldDuration orders Category by duration. CategoryOrderFieldDuration = &CategoryOrderField{ Value: func(c *Category) (ent.Value, error) { @@ -845,6 +865,8 @@ func (f CategoryOrderField) String() string { switch f.column { case CategoryOrderFieldText.column: str = "TEXT" + case CategoryOrderFieldStatus.column: + str = "STATUS" case CategoryOrderFieldDuration.column: str = "DURATION" case CategoryOrderFieldCount.column: @@ -869,6 +891,8 @@ func (f *CategoryOrderField) UnmarshalGQL(v interface{}) error { switch str { case "TEXT": *f = *CategoryOrderFieldText + case "STATUS": + *f = *CategoryOrderFieldStatus case "DURATION": *f = *CategoryOrderFieldDuration case "COUNT": @@ -1124,12 +1148,12 @@ func (f *FriendshipQuery) PaginateLimitOffset( f.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := f.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1162,7 +1186,9 @@ func (f *FriendshipQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = f.Clone().Count(ctx); err != nil { + c := f.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1175,16 +1201,17 @@ func (f *FriendshipQuery) Paginate( if f, err = pager.applyCursors(f, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { f.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1358,11 +1385,11 @@ func (p *groupPager) applyFilter(query *GroupQuery) (*GroupQuery, error) { } func (p *groupPager) toCursor(gr *Group) Cursor { - cs := make([]any, 0, len(p.order)) - for _, o := range p.order { - cs = append(cs, o.Field.toCursor(gr).Value) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(gr).Value) } - return Cursor{ID: gr.ID, Value: cs} + return Cursor{ID: gr.ID, Value: cs_} } func (p *groupPager) applyCursors(query *GroupQuery, after, before *Cursor) (*GroupQuery, error) { @@ -1476,12 +1503,12 @@ func (gr *GroupQuery) PaginateLimitOffset( gr.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := gr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := gr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1514,7 +1541,9 @@ func (gr *GroupQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = gr.Clone().Count(ctx); err != nil { + c := gr.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1527,16 +1556,17 @@ func (gr *GroupQuery) Paginate( if gr, err = pager.applyCursors(gr, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { gr.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1658,19 +1688,14 @@ func (c *TodoList) build(nodes []*Todo, pager *todoPager, after *Cursor, first * type TodoPaginateOption func(*todoPager) error // WithTodoOrder configures pagination ordering. -func WithTodoOrder(order *TodoOrder) TodoPaginateOption { - if order == nil { - order = DefaultTodoOrder - } - o := *order +func WithTodoOrder(order []*TodoOrder) TodoPaginateOption { return func(pager *todoPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultTodoOrder.Field + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } } - pager.order = &o + pager.order = append(pager.order, order...) return nil } } @@ -1688,7 +1713,7 @@ func WithTodoFilter(filter func(*TodoQuery) (*TodoQuery, error)) TodoPaginateOpt type todoPager struct { reverse bool - order *TodoOrder + order []*TodoOrder filter func(*TodoQuery) (*TodoQuery, error) } @@ -1699,8 +1724,10 @@ func newTodoPager(opts []TodoPaginateOption, reverse bool) (*todoPager, error) { return nil, err } } - if pager.order == nil { - pager.order = DefaultTodoOrder + for i, o := range pager.order { + if i > 0 && o.Field == pager.order[i-1].Field { + return nil, fmt.Errorf("duplicate order direction %q", o.Direction) + } } return pager, nil } @@ -1713,57 +1740,100 @@ func (p *todoPager) applyFilter(query *TodoQuery) (*TodoQuery, error) { } func (p *todoPager) toCursor(t *Todo) Cursor { - return p.order.Field.toCursor(t) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(t).Value) + } + return Cursor{ID: t.ID, Value: cs_} } func (p *todoPager) applyCursors(query *TodoQuery, after, before *Cursor) (*TodoQuery, error) { - direction := p.order.Direction + idDirection := entgql.OrderDirectionAsc if p.reverse { - direction = direction.Reverse() + idDirection = entgql.OrderDirectionDesc + } + fields, directions := make([]string, 0, len(p.order)), make([]OrderDirection, 0, len(p.order)) + for _, o := range p.order { + fields = append(fields, o.Field.column) + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + directions = append(directions, direction) } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultTodoOrder.Field.column, p.order.Field.column, direction) { + predicates, err := entgql.MultiCursorsPredicate(after, before, &entgql.MultiCursorsOptions{ + FieldID: DefaultTodoOrder.Field.column, + DirectionID: idDirection, + Fields: fields, + Directions: directions, + }) + if err != nil { + return nil, err + } + for _, predicate := range predicates { query = query.Where(predicate) } return query, nil } func (p *todoPager) applyOrder(query *TodoQuery) *TodoQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultTodoOrder.Field { - query = query.Order(DefaultTodoOrder.Field.toTerm(direction.OrderTermOption())) + var defaultOrdered bool + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + if o.Field.column == DefaultTodoOrder.Field.column { + defaultOrdered = true + } + switch o.Field.column { + case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, TodoOrderFieldCategoryText.column: + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } + } } - switch p.order.Field.column { - case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, CategoryOrderFieldCategoryText.column: - default: - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) + if !defaultOrdered { + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() } + query = query.Order(DefaultTodoOrder.Field.toTerm(direction.OrderTermOption())) } return query } func (p *todoPager) orderExpr(query *TodoQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - switch p.order.Field.column { - case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, CategoryOrderFieldCategoryText.column: - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - default: - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) + for _, o := range p.order { + switch o.Field.column { + case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, TodoOrderFieldCategoryText.column: + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } } } return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultTodoOrder.Field { - b.Comma().Ident(DefaultTodoOrder.Field.column).Pad().WriteString(string(direction)) + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + b.Ident(o.Field.column).Pad().WriteString(string(direction)) + b.Comma() } + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + b.Ident(DefaultTodoOrder.Field.column).Pad().WriteString(string(direction)) }) } @@ -1801,12 +1871,12 @@ func (t *TodoQuery) PaginateLimitOffset( t.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1839,7 +1909,9 @@ func (t *TodoQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = t.Clone().Count(ctx); err != nil { + c := t.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1852,16 +1924,17 @@ func (t *TodoQuery) Paginate( if t, err = pager.applyCursors(t, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { t.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1970,8 +2043,8 @@ var ( } }, } - // CategoryOrderFieldCategoryText orders by CATEGORY_TEXT. - CategoryOrderFieldCategoryText = &TodoOrderField{ + // TodoOrderFieldCategoryText orders by CATEGORY_TEXT. + TodoOrderFieldCategoryText = &TodoOrderField{ Value: func(t *Todo) (ent.Value, error) { return t.Value("category_text") }, @@ -2008,7 +2081,7 @@ func (f TodoOrderField) String() string { str = "PARENT_STATUS" case TodoOrderFieldChildrenCount.column: str = "CHILDREN_COUNT" - case CategoryOrderFieldCategoryText.column: + case TodoOrderFieldCategoryText.column: str = "CATEGORY_TEXT" } return str @@ -2039,7 +2112,7 @@ func (f *TodoOrderField) UnmarshalGQL(v interface{}) error { case "CHILDREN_COUNT": *f = *TodoOrderFieldChildrenCount case "CATEGORY_TEXT": - *f = *CategoryOrderFieldCategoryText + *f = *TodoOrderFieldCategoryText default: return fmt.Errorf("%s is not a valid TodoOrderField", str) } @@ -2298,12 +2371,12 @@ func (u *UserQuery) PaginateLimitOffset( u.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := u.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := u.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2336,7 +2409,9 @@ func (u *UserQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = u.Clone().Count(ctx); err != nil { + c := u.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2349,16 +2424,17 @@ func (u *UserQuery) Paginate( if u, err = pager.applyCursors(u, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { u.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } diff --git a/entgql/internal/todopulid/ent/group/where.go b/entgql/internal/todopulid/ent/group/where.go index bf8e03bfb..3bac7053e 100644 --- a/entgql/internal/todopulid/ent/group/where.go +++ b/entgql/internal/todopulid/ent/group/where.go @@ -163,32 +163,15 @@ func HasUsersWith(preds ...predicate.User) predicate.Group { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Group(sql.NotPredicates(p)) } diff --git a/entgql/internal/todopulid/ent/group_create.go b/entgql/internal/todopulid/ent/group_create.go index d2d161739..12dbed4a4 100644 --- a/entgql/internal/todopulid/ent/group_create.go +++ b/entgql/internal/todopulid/ent/group_create.go @@ -86,7 +86,7 @@ func (gc *GroupCreate) Mutation() *GroupMutation { // Save creates the Group in the database. func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) { gc.defaults() - return withHooks[*Group, GroupMutation](ctx, gc.sqlSave, gc.mutation, gc.hooks) + return withHooks(ctx, gc.sqlSave, gc.mutation, gc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -189,11 +189,15 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { // GroupCreateBulk is the builder for creating many Group entities in bulk. type GroupCreateBulk struct { config + err error builders []*GroupCreate } // Save creates the Group entities in the database. func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { + if gcb.err != nil { + return nil, gcb.err + } specs := make([]*sqlgraph.CreateSpec, len(gcb.builders)) nodes := make([]*Group, len(gcb.builders)) mutators := make([]Mutator, len(gcb.builders)) diff --git a/entgql/internal/todopulid/ent/group_delete.go b/entgql/internal/todopulid/ent/group_delete.go index e551c5498..5ed976e25 100644 --- a/entgql/internal/todopulid/ent/group_delete.go +++ b/entgql/internal/todopulid/ent/group_delete.go @@ -41,7 +41,7 @@ func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (gd *GroupDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gd.sqlExec, gd.mutation, gd.hooks) + return withHooks(ctx, gd.sqlExec, gd.mutation, gd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/group_update.go b/entgql/internal/todopulid/ent/group_update.go index 9ccc7215a..521856ca0 100644 --- a/entgql/internal/todopulid/ent/group_update.go +++ b/entgql/internal/todopulid/ent/group_update.go @@ -100,7 +100,7 @@ func (gu *GroupUpdate) RemoveUsers(u ...*User) *GroupUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (gu *GroupUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gu.sqlSave, gu.mutation, gu.hooks) + return withHooks(ctx, gu.sqlSave, gu.mutation, gu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -272,7 +272,7 @@ func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOn // Save executes the query and returns the updated Group entity. func (guo *GroupUpdateOne) Save(ctx context.Context) (*Group, error) { - return withHooks[*Group, GroupMutation](ctx, guo.sqlSave, guo.mutation, guo.hooks) + return withHooks(ctx, guo.sqlSave, guo.mutation, guo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/migrate/schema.go b/entgql/internal/todopulid/ent/migrate/schema.go index ac848e9c0..61ba9b39c 100644 --- a/entgql/internal/todopulid/ent/migrate/schema.go +++ b/entgql/internal/todopulid/ent/migrate/schema.go @@ -41,6 +41,7 @@ var ( {Name: "text", Type: field.TypeString, Size: 2147483647}, {Name: "status", Type: field.TypeEnum, Enums: []string{"ENABLED", "DISABLED"}}, {Name: "config", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"sqlite3": "json"}}, + {Name: "types", Type: field.TypeJSON, Nullable: true}, {Name: "duration", Type: field.TypeInt64, Nullable: true}, {Name: "count", Type: field.TypeUint64, Nullable: true}, {Name: "strings", Type: field.TypeJSON, Nullable: true}, @@ -143,6 +144,7 @@ var ( {Name: "name", Type: field.TypeString, Default: "Anonymous"}, {Name: "username", Type: field.TypeUUID}, {Name: "password", Type: field.TypeString, Nullable: true}, + {Name: "required_metadata", Type: field.TypeJSON}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, } // UsersTable holds the schema information for the "users" table. diff --git a/entgql/internal/todopulid/ent/mutation.go b/entgql/internal/todopulid/ent/mutation.go index 44e270c07..5989c6ff2 100644 --- a/entgql/internal/todopulid/ent/mutation.go +++ b/entgql/internal/todopulid/ent/mutation.go @@ -542,6 +542,7 @@ type CategoryMutation struct { text *string status *category.Status _config **schematype.CategoryConfig + types **schematype.CategoryTypes duration *time.Duration addduration *time.Duration count *uint64 @@ -785,6 +786,55 @@ func (m *CategoryMutation) ResetConfig() { delete(m.clearedFields, category.FieldConfig) } +// SetTypes sets the "types" field. +func (m *CategoryMutation) SetTypes(st *schematype.CategoryTypes) { + m.types = &st +} + +// Types returns the value of the "types" field in the mutation. +func (m *CategoryMutation) Types() (r *schematype.CategoryTypes, exists bool) { + v := m.types + if v == nil { + return + } + return *v, true +} + +// OldTypes returns the old "types" field's value of the Category entity. +// If the Category object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CategoryMutation) OldTypes(ctx context.Context) (v *schematype.CategoryTypes, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTypes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTypes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTypes: %w", err) + } + return oldValue.Types, nil +} + +// ClearTypes clears the value of the "types" field. +func (m *CategoryMutation) ClearTypes() { + m.types = nil + m.clearedFields[category.FieldTypes] = struct{}{} +} + +// TypesCleared returns if the "types" field was cleared in this mutation. +func (m *CategoryMutation) TypesCleared() bool { + _, ok := m.clearedFields[category.FieldTypes] + return ok +} + +// ResetTypes resets all changes to the "types" field. +func (m *CategoryMutation) ResetTypes() { + m.types = nil + delete(m.clearedFields, category.FieldTypes) +} + // SetDuration sets the "duration" field. func (m *CategoryMutation) SetDuration(t time.Duration) { m.duration = &t @@ -1132,7 +1182,7 @@ func (m *CategoryMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *CategoryMutation) Fields() []string { - fields := make([]string, 0, 6) + fields := make([]string, 0, 7) if m.text != nil { fields = append(fields, category.FieldText) } @@ -1142,6 +1192,9 @@ func (m *CategoryMutation) Fields() []string { if m._config != nil { fields = append(fields, category.FieldConfig) } + if m.types != nil { + fields = append(fields, category.FieldTypes) + } if m.duration != nil { fields = append(fields, category.FieldDuration) } @@ -1165,6 +1218,8 @@ func (m *CategoryMutation) Field(name string) (ent.Value, bool) { return m.Status() case category.FieldConfig: return m.Config() + case category.FieldTypes: + return m.Types() case category.FieldDuration: return m.Duration() case category.FieldCount: @@ -1186,6 +1241,8 @@ func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldStatus(ctx) case category.FieldConfig: return m.OldConfig(ctx) + case category.FieldTypes: + return m.OldTypes(ctx) case category.FieldDuration: return m.OldDuration(ctx) case category.FieldCount: @@ -1222,6 +1279,13 @@ func (m *CategoryMutation) SetField(name string, value ent.Value) error { } m.SetConfig(v) return nil + case category.FieldTypes: + v, ok := value.(*schematype.CategoryTypes) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTypes(v) + return nil case category.FieldDuration: v, ok := value.(time.Duration) if !ok { @@ -1303,6 +1367,9 @@ func (m *CategoryMutation) ClearedFields() []string { if m.FieldCleared(category.FieldConfig) { fields = append(fields, category.FieldConfig) } + if m.FieldCleared(category.FieldTypes) { + fields = append(fields, category.FieldTypes) + } if m.FieldCleared(category.FieldDuration) { fields = append(fields, category.FieldDuration) } @@ -1329,6 +1396,9 @@ func (m *CategoryMutation) ClearField(name string) error { case category.FieldConfig: m.ClearConfig() return nil + case category.FieldTypes: + m.ClearTypes() + return nil case category.FieldDuration: m.ClearDuration() return nil @@ -1355,6 +1425,9 @@ func (m *CategoryMutation) ResetField(name string) error { case category.FieldConfig: m.ResetConfig() return nil + case category.FieldTypes: + m.ResetTypes() + return nil case category.FieldDuration: m.ResetDuration() return nil @@ -1710,6 +1783,7 @@ func (m *FriendshipMutation) ResetFriendID() { // ClearUser clears the "user" edge to the User entity. func (m *FriendshipMutation) ClearUser() { m.cleareduser = true + m.clearedFields[friendship.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. @@ -1736,6 +1810,7 @@ func (m *FriendshipMutation) ResetUser() { // ClearFriend clears the "friend" edge to the User entity. func (m *FriendshipMutation) ClearFriend() { m.clearedfriend = true + m.clearedFields[friendship.FieldFriendID] = struct{}{} } // FriendCleared reports if the "friend" edge to the User entity was cleared. @@ -3114,6 +3189,7 @@ func (m *TodoMutation) ResetChildren() { // ClearCategory clears the "category" edge to the Category entity. func (m *TodoMutation) ClearCategory() { m.clearedcategory = true + m.clearedFields[todo.FieldCategoryID] = struct{}{} } // CategoryCleared reports if the "category" edge to the Category entity was cleared. @@ -3638,6 +3714,7 @@ type UserMutation struct { name *string username *uuid.UUID password *string + required_metadata *map[string]interface{} metadata *map[string]interface{} clearedFields map[string]struct{} groups map[pulid.ID]struct{} @@ -3879,6 +3956,42 @@ func (m *UserMutation) ResetPassword() { delete(m.clearedFields, user.FieldPassword) } +// SetRequiredMetadata sets the "required_metadata" field. +func (m *UserMutation) SetRequiredMetadata(value map[string]interface{}) { + m.required_metadata = &value +} + +// RequiredMetadata returns the value of the "required_metadata" field in the mutation. +func (m *UserMutation) RequiredMetadata() (r map[string]interface{}, exists bool) { + v := m.required_metadata + if v == nil { + return + } + return *v, true +} + +// OldRequiredMetadata returns the old "required_metadata" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldRequiredMetadata(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRequiredMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRequiredMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRequiredMetadata: %w", err) + } + return oldValue.RequiredMetadata, nil +} + +// ResetRequiredMetadata resets all changes to the "required_metadata" field. +func (m *UserMutation) ResetRequiredMetadata() { + m.required_metadata = nil +} + // SetMetadata sets the "metadata" field. func (m *UserMutation) SetMetadata(value map[string]interface{}) { m.metadata = &value @@ -4124,7 +4237,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 4) + fields := make([]string, 0, 5) if m.name != nil { fields = append(fields, user.FieldName) } @@ -4134,6 +4247,9 @@ func (m *UserMutation) Fields() []string { if m.password != nil { fields = append(fields, user.FieldPassword) } + if m.required_metadata != nil { + fields = append(fields, user.FieldRequiredMetadata) + } if m.metadata != nil { fields = append(fields, user.FieldMetadata) } @@ -4151,6 +4267,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.Username() case user.FieldPassword: return m.Password() + case user.FieldRequiredMetadata: + return m.RequiredMetadata() case user.FieldMetadata: return m.Metadata() } @@ -4168,6 +4286,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldUsername(ctx) case user.FieldPassword: return m.OldPassword(ctx) + case user.FieldRequiredMetadata: + return m.OldRequiredMetadata(ctx) case user.FieldMetadata: return m.OldMetadata(ctx) } @@ -4200,6 +4320,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetPassword(v) return nil + case user.FieldRequiredMetadata: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRequiredMetadata(v) + return nil case user.FieldMetadata: v, ok := value.(map[string]interface{}) if !ok { @@ -4280,6 +4407,9 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldPassword: m.ResetPassword() return nil + case user.FieldRequiredMetadata: + m.ResetRequiredMetadata() + return nil case user.FieldMetadata: m.ResetMetadata() return nil diff --git a/entgql/internal/todopulid/ent/runtime/runtime.go b/entgql/internal/todopulid/ent/runtime/runtime.go index 27d6af690..0746010c5 100644 --- a/entgql/internal/todopulid/ent/runtime/runtime.go +++ b/entgql/internal/todopulid/ent/runtime/runtime.go @@ -19,6 +19,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entgql/internal/todopulid/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entgql/internal/todopulid/ent/todo/where.go b/entgql/internal/todopulid/ent/todo/where.go index 6983db1a8..305ac1136 100644 --- a/entgql/internal/todopulid/ent/todo/where.go +++ b/entgql/internal/todopulid/ent/todo/where.go @@ -514,32 +514,15 @@ func HasSecretWith(preds ...predicate.VerySecret) predicate.Todo { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Todo(sql.NotPredicates(p)) } diff --git a/entgql/internal/todopulid/ent/todo_create.go b/entgql/internal/todopulid/ent/todo_create.go index 9d250fb76..cfcee90ca 100644 --- a/entgql/internal/todopulid/ent/todo_create.go +++ b/entgql/internal/todopulid/ent/todo_create.go @@ -196,7 +196,7 @@ func (tc *TodoCreate) Mutation() *TodoMutation { // Save creates the Todo in the database. func (tc *TodoCreate) Save(ctx context.Context) (*Todo, error) { tc.defaults() - return withHooks[*Todo, TodoMutation](ctx, tc.sqlSave, tc.mutation, tc.hooks) + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -401,11 +401,15 @@ func (tc *TodoCreate) createSpec() (*Todo, *sqlgraph.CreateSpec) { // TodoCreateBulk is the builder for creating many Todo entities in bulk. type TodoCreateBulk struct { config + err error builders []*TodoCreate } // Save creates the Todo entities in the database. func (tcb *TodoCreateBulk) Save(ctx context.Context) ([]*Todo, error) { + if tcb.err != nil { + return nil, tcb.err + } specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) nodes := make([]*Todo, len(tcb.builders)) mutators := make([]Mutator, len(tcb.builders)) diff --git a/entgql/internal/todopulid/ent/todo_delete.go b/entgql/internal/todopulid/ent/todo_delete.go index c0a83d6b0..530240061 100644 --- a/entgql/internal/todopulid/ent/todo_delete.go +++ b/entgql/internal/todopulid/ent/todo_delete.go @@ -41,7 +41,7 @@ func (td *TodoDelete) Where(ps ...predicate.Todo) *TodoDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (td *TodoDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, td.sqlExec, td.mutation, td.hooks) + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/todo_update.go b/entgql/internal/todopulid/ent/todo_update.go index 1d59bbf43..c9932eefa 100644 --- a/entgql/internal/todopulid/ent/todo_update.go +++ b/entgql/internal/todopulid/ent/todo_update.go @@ -51,6 +51,14 @@ func (tu *TodoUpdate) SetStatus(t todo.Status) *TodoUpdate { return tu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableStatus(t *todo.Status) *TodoUpdate { + if t != nil { + tu.SetStatus(*t) + } + return tu +} + // SetPriority sets the "priority" field. func (tu *TodoUpdate) SetPriority(i int) *TodoUpdate { tu.mutation.ResetPriority() @@ -78,6 +86,14 @@ func (tu *TodoUpdate) SetText(s string) *TodoUpdate { return tu } +// SetNillableText sets the "text" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableText(s *string) *TodoUpdate { + if s != nil { + tu.SetText(*s) + } + return tu +} + // SetBlob sets the "blob" field. func (tu *TodoUpdate) SetBlob(b []byte) *TodoUpdate { tu.mutation.SetBlob(b) @@ -231,7 +247,7 @@ func (tu *TodoUpdate) ClearSecret() *TodoUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TodoUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, tu.sqlSave, tu.mutation, tu.hooks) + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -458,6 +474,14 @@ func (tuo *TodoUpdateOne) SetStatus(t todo.Status) *TodoUpdateOne { return tuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableStatus(t *todo.Status) *TodoUpdateOne { + if t != nil { + tuo.SetStatus(*t) + } + return tuo +} + // SetPriority sets the "priority" field. func (tuo *TodoUpdateOne) SetPriority(i int) *TodoUpdateOne { tuo.mutation.ResetPriority() @@ -485,6 +509,14 @@ func (tuo *TodoUpdateOne) SetText(s string) *TodoUpdateOne { return tuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableText(s *string) *TodoUpdateOne { + if s != nil { + tuo.SetText(*s) + } + return tuo +} + // SetBlob sets the "blob" field. func (tuo *TodoUpdateOne) SetBlob(b []byte) *TodoUpdateOne { tuo.mutation.SetBlob(b) @@ -651,7 +683,7 @@ func (tuo *TodoUpdateOne) Select(field string, fields ...string) *TodoUpdateOne // Save executes the query and returns the updated Todo entity. func (tuo *TodoUpdateOne) Save(ctx context.Context) (*Todo, error) { - return withHooks[*Todo, TodoMutation](ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/user.go b/entgql/internal/todopulid/ent/user.go index 3eb52d61c..67a5c4ac6 100644 --- a/entgql/internal/todopulid/ent/user.go +++ b/entgql/internal/todopulid/ent/user.go @@ -39,6 +39,8 @@ type User struct { Username uuid.UUID `json:"username,omitempty"` // Password holds the value of the "password" field. Password string `json:"-"` + // RequiredMetadata holds the value of the "required_metadata" field. + RequiredMetadata map[string]interface{} `json:"required_metadata,omitempty"` // Metadata holds the value of the "metadata" field. Metadata map[string]interface{} `json:"metadata,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -98,7 +100,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case user.FieldMetadata: + case user.FieldRequiredMetadata, user.FieldMetadata: values[i] = new([]byte) case user.FieldID: values[i] = new(pulid.ID) @@ -145,6 +147,14 @@ func (u *User) assignValues(columns []string, values []any) error { } else if value.Valid { u.Password = value.String } + case user.FieldRequiredMetadata: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field required_metadata", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &u.RequiredMetadata); err != nil { + return fmt.Errorf("unmarshal field required_metadata: %w", err) + } + } case user.FieldMetadata: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field metadata", values[i]) @@ -212,6 +222,9 @@ func (u *User) String() string { builder.WriteString(", ") builder.WriteString("password=") builder.WriteString(", ") + builder.WriteString("required_metadata=") + builder.WriteString(fmt.Sprintf("%v", u.RequiredMetadata)) + builder.WriteString(", ") builder.WriteString("metadata=") builder.WriteString(fmt.Sprintf("%v", u.Metadata)) builder.WriteByte(')') diff --git a/entgql/internal/todopulid/ent/user/user.go b/entgql/internal/todopulid/ent/user/user.go index 4a50dc3c5..545a6e839 100644 --- a/entgql/internal/todopulid/ent/user/user.go +++ b/entgql/internal/todopulid/ent/user/user.go @@ -34,6 +34,8 @@ const ( FieldUsername = "username" // FieldPassword holds the string denoting the password field in the database. FieldPassword = "password" + // FieldRequiredMetadata holds the string denoting the required_metadata field in the database. + FieldRequiredMetadata = "required_metadata" // FieldMetadata holds the string denoting the metadata field in the database. FieldMetadata = "metadata" // EdgeGroups holds the string denoting the groups edge name in mutations. @@ -66,6 +68,7 @@ var Columns = []string{ FieldName, FieldUsername, FieldPassword, + FieldRequiredMetadata, FieldMetadata, } diff --git a/entgql/internal/todopulid/ent/user/where.go b/entgql/internal/todopulid/ent/user/where.go index ecc0d0b42..0d29124f2 100644 --- a/entgql/internal/todopulid/ent/user/where.go +++ b/entgql/internal/todopulid/ent/user/where.go @@ -345,32 +345,15 @@ func HasFriendshipsWith(preds ...predicate.Friendship) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entgql/internal/todopulid/ent/user_create.go b/entgql/internal/todopulid/ent/user_create.go index 5d65a5d33..eed7a4cc3 100644 --- a/entgql/internal/todopulid/ent/user_create.go +++ b/entgql/internal/todopulid/ent/user_create.go @@ -79,6 +79,12 @@ func (uc *UserCreate) SetNillablePassword(s *string) *UserCreate { return uc } +// SetRequiredMetadata sets the "required_metadata" field. +func (uc *UserCreate) SetRequiredMetadata(m map[string]interface{}) *UserCreate { + uc.mutation.SetRequiredMetadata(m) + return uc +} + // SetMetadata sets the "metadata" field. func (uc *UserCreate) SetMetadata(m map[string]interface{}) *UserCreate { uc.mutation.SetMetadata(m) @@ -152,7 +158,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { uc.defaults() - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -201,6 +207,9 @@ func (uc *UserCreate) check() error { if _, ok := uc.mutation.Username(); !ok { return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} } + if _, ok := uc.mutation.RequiredMetadata(); !ok { + return &ValidationError{Name: "required_metadata", err: errors.New(`ent: missing required field "User.required_metadata"`)} + } return nil } @@ -248,6 +257,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldPassword, field.TypeString, value) _node.Password = value } + if value, ok := uc.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + _node.RequiredMetadata = value + } if value, ok := uc.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) _node.Metadata = value @@ -313,11 +326,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entgql/internal/todopulid/ent/user_delete.go b/entgql/internal/todopulid/ent/user_delete.go index b597b22b2..5ef2acad7 100644 --- a/entgql/internal/todopulid/ent/user_delete.go +++ b/entgql/internal/todopulid/ent/user_delete.go @@ -41,7 +41,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/user_update.go b/entgql/internal/todopulid/ent/user_update.go index 1124be2bb..b0af0a967 100644 --- a/entgql/internal/todopulid/ent/user_update.go +++ b/entgql/internal/todopulid/ent/user_update.go @@ -93,6 +93,12 @@ func (uu *UserUpdate) ClearPassword() *UserUpdate { return uu } +// SetRequiredMetadata sets the "required_metadata" field. +func (uu *UserUpdate) SetRequiredMetadata(m map[string]interface{}) *UserUpdate { + uu.mutation.SetRequiredMetadata(m) + return uu +} + // SetMetadata sets the "metadata" field. func (uu *UserUpdate) SetMetadata(m map[string]interface{}) *UserUpdate { uu.mutation.SetMetadata(m) @@ -220,7 +226,7 @@ func (uu *UserUpdate) RemoveFriendships(f ...*Friendship) *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -266,6 +272,9 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if uu.mutation.PasswordCleared() { _spec.ClearField(user.FieldPassword, field.TypeString) } + if value, ok := uu.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + } if value, ok := uu.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) } @@ -496,6 +505,12 @@ func (uuo *UserUpdateOne) ClearPassword() *UserUpdateOne { return uuo } +// SetRequiredMetadata sets the "required_metadata" field. +func (uuo *UserUpdateOne) SetRequiredMetadata(m map[string]interface{}) *UserUpdateOne { + uuo.mutation.SetRequiredMetadata(m) + return uuo +} + // SetMetadata sets the "metadata" field. func (uuo *UserUpdateOne) SetMetadata(m map[string]interface{}) *UserUpdateOne { uuo.mutation.SetMetadata(m) @@ -636,7 +651,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -699,6 +714,9 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if uuo.mutation.PasswordCleared() { _spec.ClearField(user.FieldPassword, field.TypeString) } + if value, ok := uuo.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + } if value, ok := uuo.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) } diff --git a/entgql/internal/todopulid/ent/verysecret/where.go b/entgql/internal/todopulid/ent/verysecret/where.go index 867bcab90..ff85605e8 100644 --- a/entgql/internal/todopulid/ent/verysecret/where.go +++ b/entgql/internal/todopulid/ent/verysecret/where.go @@ -139,32 +139,15 @@ func PasswordContainsFold(v string) predicate.VerySecret { // And groups predicates with the AND operator between them. func And(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.VerySecret(sql.NotPredicates(p)) } diff --git a/entgql/internal/todopulid/ent/verysecret_create.go b/entgql/internal/todopulid/ent/verysecret_create.go index 186098579..75f31c958 100644 --- a/entgql/internal/todopulid/ent/verysecret_create.go +++ b/entgql/internal/todopulid/ent/verysecret_create.go @@ -62,7 +62,7 @@ func (vsc *VerySecretCreate) Mutation() *VerySecretMutation { // Save creates the VerySecret in the database. func (vsc *VerySecretCreate) Save(ctx context.Context) (*VerySecret, error) { vsc.defaults() - return withHooks[*VerySecret, VerySecretMutation](ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) + return withHooks(ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -145,11 +145,15 @@ func (vsc *VerySecretCreate) createSpec() (*VerySecret, *sqlgraph.CreateSpec) { // VerySecretCreateBulk is the builder for creating many VerySecret entities in bulk. type VerySecretCreateBulk struct { config + err error builders []*VerySecretCreate } // Save creates the VerySecret entities in the database. func (vscb *VerySecretCreateBulk) Save(ctx context.Context) ([]*VerySecret, error) { + if vscb.err != nil { + return nil, vscb.err + } specs := make([]*sqlgraph.CreateSpec, len(vscb.builders)) nodes := make([]*VerySecret, len(vscb.builders)) mutators := make([]Mutator, len(vscb.builders)) diff --git a/entgql/internal/todopulid/ent/verysecret_delete.go b/entgql/internal/todopulid/ent/verysecret_delete.go index bf7b6d0fe..26cd459ba 100644 --- a/entgql/internal/todopulid/ent/verysecret_delete.go +++ b/entgql/internal/todopulid/ent/verysecret_delete.go @@ -41,7 +41,7 @@ func (vsd *VerySecretDelete) Where(ps ...predicate.VerySecret) *VerySecretDelete // Exec executes the deletion query and returns how many vertices were deleted. func (vsd *VerySecretDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) + return withHooks(ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todopulid/ent/verysecret_update.go b/entgql/internal/todopulid/ent/verysecret_update.go index e462c3057..d3592e533 100644 --- a/entgql/internal/todopulid/ent/verysecret_update.go +++ b/entgql/internal/todopulid/ent/verysecret_update.go @@ -47,6 +47,14 @@ func (vsu *VerySecretUpdate) SetPassword(s string) *VerySecretUpdate { return vsu } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsu *VerySecretUpdate) SetNillablePassword(s *string) *VerySecretUpdate { + if s != nil { + vsu.SetPassword(*s) + } + return vsu +} + // Mutation returns the VerySecretMutation object of the builder. func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { return vsu.mutation @@ -54,7 +62,7 @@ func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (vsu *VerySecretUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) + return withHooks(ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -117,6 +125,14 @@ func (vsuo *VerySecretUpdateOne) SetPassword(s string) *VerySecretUpdateOne { return vsuo } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsuo *VerySecretUpdateOne) SetNillablePassword(s *string) *VerySecretUpdateOne { + if s != nil { + vsuo.SetPassword(*s) + } + return vsuo +} + // Mutation returns the VerySecretMutation object of the builder. func (vsuo *VerySecretUpdateOne) Mutation() *VerySecretMutation { return vsuo.mutation @@ -137,7 +153,7 @@ func (vsuo *VerySecretUpdateOne) Select(field string, fields ...string) *VerySec // Save executes the query and returns the updated VerySecret entity. func (vsuo *VerySecretUpdateOne) Save(ctx context.Context) (*VerySecret, error) { - return withHooks[*VerySecret, VerySecretMutation](ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) + return withHooks(ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todopulid/generated.go b/entgql/internal/todopulid/generated.go index 52a0408c4..1cf8fa7dc 100644 --- a/entgql/internal/todopulid/generated.go +++ b/entgql/internal/todopulid/generated.go @@ -13,6 +13,7 @@ import ( "time" "entgo.io/contrib/entgql" + ent1 "entgo.io/contrib/entgql/internal/todo/ent" "entgo.io/contrib/entgql/internal/todo/ent/schema/customstruct" "entgo.io/contrib/entgql/internal/todo/ent/schema/durationgql" "entgo.io/contrib/entgql/internal/todo/ent/schema/schematype" @@ -31,6 +32,7 @@ import ( // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ + schema: cfg.Schema, resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, @@ -38,6 +40,7 @@ func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { } type Config struct { + Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot @@ -46,6 +49,7 @@ type Config struct { type ResolverRoot interface { Category() CategoryResolver Mutation() MutationResolver + Organization() OrganizationResolver Query() QueryResolver Todo() TodoResolver User() UserResolver @@ -53,6 +57,7 @@ type ResolverRoot interface { CreateTodoInput() CreateTodoInputResolver CreateUserInput() CreateUserInputResolver TodoWhereInput() TodoWhereInputResolver + UpdateCategoryInput() UpdateCategoryInputResolver UpdateTodoInput() UpdateTodoInputResolver UpdateUserInput() UpdateUserInputResolver UserWhereInput() UserWhereInputResolver @@ -79,8 +84,9 @@ type ComplexityRoot struct { Strings func(childComplexity int) int SubCategories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int Text func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int TodosCount func(childComplexity int) int + Types func(childComplexity int) int } CategoryConfig struct { @@ -92,6 +98,10 @@ type ComplexityRoot struct { TotalCount func(childComplexity int) int } + CategoryTypes struct { + Public func(childComplexity int) int + } + Custom struct { Info func(childComplexity int) int } @@ -142,6 +152,11 @@ type ComplexityRoot struct { TotalCount func(childComplexity int) int } + Organization struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int @@ -151,25 +166,26 @@ type ComplexityRoot struct { Project struct { ID func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int } Query struct { - BillProducts func(childComplexity int) int - Categories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int - Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int - Node func(childComplexity int, id pulid.ID) int - Nodes func(childComplexity int, ids []pulid.ID) int - OneToMany func(childComplexity int, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) int - Ping func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int - Users func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int + BillProducts func(childComplexity int) int + Categories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int + Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int + Node func(childComplexity int, id pulid.ID) int + Nodes func(childComplexity int, ids []pulid.ID) int + OneToMany func(childComplexity int, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) int + Ping func(childComplexity int) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int + TodosWithJoins func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int + Users func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int } Todo struct { Category func(childComplexity int) int CategoryID func(childComplexity int) int - Children func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Children func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int CreatedAt func(childComplexity int) int Custom func(childComplexity int) int Customp func(childComplexity int) int @@ -188,13 +204,14 @@ type ComplexityRoot struct { } User struct { - Friends func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int - Friendships func(childComplexity int, limit *int, offset *int, where *ent.FriendshipWhereInput) int - Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int - ID func(childComplexity int) int - Metadata func(childComplexity int) int - Name func(childComplexity int) int - Username func(childComplexity int) int + Friends func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int + Friendships func(childComplexity int, limit *int, offset *int, where *ent.FriendshipWhereInput) int + Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int + ID func(childComplexity int) int + Metadata func(childComplexity int) int + Name func(childComplexity int) int + RequiredMetadata func(childComplexity int) int + Username func(childComplexity int) int } UserList struct { @@ -204,6 +221,8 @@ type ComplexityRoot struct { } type CategoryResolver interface { + Types(ctx context.Context, obj *ent.Category) (*CategoryTypes, error) + TodosCount(ctx context.Context, obj *ent.Category) (*int, error) } type MutationResolver interface { @@ -213,6 +232,9 @@ type MutationResolver interface { ClearTodos(ctx context.Context) (int, error) UpdateFriendship(ctx context.Context, id pulid.ID, input UpdateFriendshipInput) (*ent.Friendship, error) } +type OrganizationResolver interface { + ID(ctx context.Context, obj *ent1.Workspace) (pulid.ID, error) +} type QueryResolver interface { Node(ctx context.Context, id pulid.ID) (ent.Noder, error) Nodes(ctx context.Context, ids []pulid.ID) ([]ent.Noder, error) @@ -220,9 +242,10 @@ type QueryResolver interface { Categories(ctx context.Context, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryList, error) Groups(ctx context.Context, limit *int, offset *int, where *ent.GroupWhereInput) (*ent.GroupList, error) OneToMany(ctx context.Context, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) (*OneToManyList, error) - Todos(ctx context.Context, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) + Todos(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) Users(ctx context.Context, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) Ping(ctx context.Context) (string, error) + TodosWithJoins(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) } type TodoResolver interface { Status(ctx context.Context, obj *ent.Todo) (todo.Status, error) @@ -237,6 +260,8 @@ type UserResolver interface { } type CreateCategoryInputResolver interface { + Types(ctx context.Context, obj *ent.CreateCategoryInput, data *CategoryTypesInput) error + CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error } type CreateTodoInputResolver interface { @@ -253,6 +278,9 @@ type TodoWhereInputResolver interface { CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error } +type UpdateCategoryInputResolver interface { + Types(ctx context.Context, obj *ent.UpdateCategoryInput, data *CategoryTypesInput) error +} type UpdateTodoInputResolver interface { Status(ctx context.Context, obj *ent.UpdateTodoInput, data *todo.Status) error } @@ -271,17 +299,21 @@ type UserWhereInputResolver interface { } type executableSchema struct { + schema *ast.Schema resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} + ec := executionContext{nil, e, 0, 0, nil} _ = ec switch typeName + "." + field { @@ -384,7 +416,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Category.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Category.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Category.todosCount": if e.complexity.Category.TodosCount == nil { @@ -393,6 +425,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Category.TodosCount(childComplexity), true + case "Category.types": + if e.complexity.Category.Types == nil { + break + } + + return e.complexity.Category.Types(childComplexity), true + case "CategoryConfig.maxMembers": if e.complexity.CategoryConfig.MaxMembers == nil { break @@ -414,6 +453,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CategoryList.TotalCount(childComplexity), true + case "CategoryTypes.public": + if e.complexity.CategoryTypes.Public == nil { + break + } + + return e.complexity.CategoryTypes.Public(childComplexity), true + case "Custom.info": if e.complexity.Custom.Info == nil { break @@ -621,6 +667,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OneToManyList.TotalCount(childComplexity), true + case "Organization.id": + if e.complexity.Organization.ID == nil { + break + } + + return e.complexity.Organization.ID(childComplexity), true + + case "Organization.name": + if e.complexity.Organization.Name == nil { + break + } + + return e.complexity.Organization.Name(childComplexity), true + case "PageInfo.endCursor": if e.complexity.PageInfo.EndCursor == nil { break @@ -666,7 +726,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Project.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Project.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Query.billProducts": if e.complexity.Query.BillProducts == nil { @@ -752,7 +812,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Query.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + + case "Query.todosWithJoins": + if e.complexity.Query.TodosWithJoins == nil { + break + } + + args, err := ec.field_Query_todosWithJoins_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.TodosWithJoins(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Query.users": if e.complexity.Query.Users == nil { @@ -790,7 +862,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Todo.Children(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Todo.Children(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Todo.createdAt": if e.complexity.Todo.CreatedAt == nil { @@ -933,6 +1005,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Name(childComplexity), true + case "User.requiredMetadata": + if e.complexity.User.RequiredMetadata == nil { + break + } + + return e.complexity.User.RequiredMetadata(childComplexity), true + case "User.username": if e.complexity.User.Username == nil { break @@ -960,11 +1039,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputBillProductWhereInput, ec.unmarshalInputCategoryConfigInput, ec.unmarshalInputCategoryOrder, + ec.unmarshalInputCategoryTypesInput, ec.unmarshalInputCategoryWhereInput, ec.unmarshalInputCreateCategoryInput, ec.unmarshalInputCreateTodoInput, @@ -973,6 +1053,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputGroupWhereInput, ec.unmarshalInputOneToManyOrder, ec.unmarshalInputOneToManyWhereInput, + ec.unmarshalInputOrganizationWhereInput, ec.unmarshalInputProjectWhereInput, ec.unmarshalInputTodoOrder, ec.unmarshalInputTodoWhereInput, @@ -988,18 +1069,33 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { - if !first { - return nil + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext } + + return &response } case ast.Mutation: return func(ctx context.Context) *graphql.Response { @@ -1025,20 +1121,42 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { type executionContext struct { *graphql.OperationContext *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } var sources = []*ast.Source{ @@ -1052,6 +1170,14 @@ input CategoryConfigInput { maxMembers: Int } +type CategoryTypes { + public: Boolean +} + +input CategoryTypesInput { + public: Boolean +} + scalar Duration scalar UUID @@ -1075,6 +1201,21 @@ extend type Query { This field is an example of extending the built-in Query type from Ent. """ ping: String! + + """This is the todo item""" + todosWithJoins( + """Pagination limit.""" + limit: Int = 100 + + """Pagination offset.""" + offset: Int = 0 + + """Ordering options for Todos returned from the connection.""" + orderBy: [TodoOrder!] + + """Filtering options for Todos returned from the connection.""" + where: TodoWhereInput +): TodoList } type Mutation { @@ -1092,22 +1233,31 @@ type Custom { extend input CreateCategoryInput { createTodos: [CreateTodoInput!] } -`, BuiltIn: false}, - {Name: "../todo/ent.graphql", Input: `directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -"""Represents BillProduct object""" + +interface NamedNode { + name: String! +}`, BuiltIn: false}, + {Name: "../todo/ent.graphql", Input: `directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @goModel(model: String, models: [String!], forceGenerate: Boolean) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +""" +Represents BillProduct object +""" type BillProduct implements Node { id: ID! name: String! sku: String! quantity: Uint64! } -"""BillProductWhereInput is used for filtering BillProduct objects.""" +""" +BillProductWhereInput is used for filtering BillProduct objects. +""" input BillProductWhereInput { not: BillProductWhereInput and: [BillProductWhereInput!] or: [BillProductWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1116,7 +1266,9 @@ input BillProductWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1130,7 +1282,9 @@ input BillProductWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """sku field predicates""" + """ + sku field predicates + """ sku: String skuNEQ: String skuIn: [String!] @@ -1144,7 +1298,9 @@ input BillProductWhereInput { skuHasSuffix: String skuEqualFold: String skuContainsFold: String - """quantity field predicates""" + """ + quantity field predicates + """ quantity: Uint64 quantityNEQ: Uint64 quantityIn: [Uint64!] @@ -1154,75 +1310,115 @@ input BillProductWhereInput { quantityLT: Uint64 quantityLTE: Uint64 } -"""Represents Category object""" +""" +Represents Category object +""" type Category implements Node { id: ID! text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList subCategories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type CategoryList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Category]! } -"""Ordering options for Category connections""" +""" +Ordering options for Category connections +""" input CategoryOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Categories.""" + """ + The field by which to order Categories. + """ field: CategoryOrderField! } -"""Properties by which Category connections can be ordered.""" +""" +Properties by which Category connections can be ordered. +""" enum CategoryOrderField { ID TEXT + STATUS DURATION COUNT TODOS_COUNT } -"""CategoryStatus is enum for the field status""" +""" +CategoryStatus is enum for the field status +""" enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { ENABLED DISABLED } -"""CategoryWhereInput is used for filtering Category objects.""" +""" +CategoryWhereInput is used for filtering Category objects. +""" input CategoryWhereInput { not: CategoryWhereInput and: [CategoryWhereInput!] or: [CategoryWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1231,7 +1427,9 @@ input CategoryWhereInput { idGTE: ID idLT: ID idLTE: ID - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -1245,12 +1443,16 @@ input CategoryWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """status field predicates""" + """ + status field predicates + """ status: CategoryStatus statusNEQ: CategoryStatus statusIn: [CategoryStatus!] statusNotIn: [CategoryStatus!] - """config field predicates""" + """ + config field predicates + """ config: CategoryConfigInput configNEQ: CategoryConfigInput configIn: [CategoryConfigInput!] @@ -1261,7 +1463,9 @@ input CategoryWhereInput { configLTE: CategoryConfigInput configIsNil: Boolean configNotNil: Boolean - """duration field predicates""" + """ + duration field predicates + """ duration: Duration durationNEQ: Duration durationIn: [Duration!] @@ -1272,7 +1476,9 @@ input CategoryWhereInput { durationLTE: Duration durationIsNil: Boolean durationNotNil: Boolean - """count field predicates""" + """ + count field predicates + """ count: Uint64 countNEQ: Uint64 countIn: [Uint64!] @@ -1283,25 +1489,34 @@ input CategoryWhereInput { countLTE: Uint64 countIsNil: Boolean countNotNil: Boolean - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] - """sub_categories edge predicates""" + """ + sub_categories edge predicates + """ hasSubCategories: Boolean hasSubCategoriesWith: [CategoryWhereInput!] } -"""CreateCategoryInput is used for create Category object.""" +""" +CreateCategoryInput is used for create Category object. +""" input CreateCategoryInput { text: String! status: CategoryStatus! config: CategoryConfigInput + types: CategoryTypesInput duration: Duration count: Uint64 strings: [String!] todoIDs: [ID!] subCategoryIDs: [ID!] } -"""CreateTodoInput is used for create Todo object.""" +""" +CreateTodoInput is used for create Todo object. +""" input CreateTodoInput { status: TodoStatus! priority: Int @@ -1312,11 +1527,14 @@ input CreateTodoInput { categoryID: ID secretID: ID } -"""CreateUserInput is used for create User object.""" +""" +CreateUserInput is used for create User object. +""" input CreateUserInput { name: String username: UUID password: String + requiredMetadata: Map! metadata: Map groupIDs: [ID!] friendIDs: [ID!] @@ -1334,19 +1552,29 @@ type Friendship implements Node { user: User! friend: User! } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type FriendshipList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Friendship]! } -"""FriendshipWhereInput is used for filtering Friendship objects.""" +""" +FriendshipWhereInput is used for filtering Friendship objects. +""" input FriendshipWhereInput { not: FriendshipWhereInput and: [FriendshipWhereInput!] or: [FriendshipWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1355,7 +1583,9 @@ input FriendshipWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -1365,36 +1595,54 @@ input FriendshipWhereInput { createdAtLT: Time createdAtLTE: Time } -type Group implements Node @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { +type Group implements Node & NamedNode @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { id: ID! name: String! users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type GroupList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Group]! } -"""GroupWhereInput is used for filtering Group objects.""" +""" +GroupWhereInput is used for filtering Group objects. +""" input GroupWhereInput { not: GroupWhereInput and: [GroupWhereInput!] or: [GroupWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1403,7 +1651,9 @@ input GroupWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1417,18 +1667,24 @@ input GroupWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """users edge predicates""" + """ + users edge predicates + """ hasUsers: Boolean hasUsersWith: [UserWhereInput!] } -"""The builtin Map type""" +""" +The builtin Map type +""" scalar Map """ An object with an ID. Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) """ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder") { - """The id of the object.""" + """ + The id of the object. + """ id: ID! } type OneToMany implements Node { @@ -1438,30 +1694,48 @@ type OneToMany implements Node { parent: OneToMany children: [OneToMany!] } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type OneToManyList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [OneToMany]! } -"""Ordering options for OneToMany connections""" +""" +Ordering options for OneToMany connections +""" input OneToManyOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" + """ + The field by which to order OneToManies. + """ field: OneToManyOrderField! } -"""Properties by which OneToMany connections can be ordered.""" +""" +Properties by which OneToMany connections can be ordered. +""" enum OneToManyOrderField { NAME } -"""OneToManyWhereInput is used for filtering OneToMany objects.""" +""" +OneToManyWhereInput is used for filtering OneToMany objects. +""" input OneToManyWhereInput { not: OneToManyWhereInput and: [OneToManyWhereInput!] or: [OneToManyWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1470,7 +1744,9 @@ input OneToManyWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1484,7 +1760,9 @@ input OneToManyWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """field2 field predicates""" + """ + field2 field predicates + """ field2: String field2NEQ: String field2In: [String!] @@ -1500,56 +1778,125 @@ input OneToManyWhereInput { field2NotNil: Boolean field2EqualFold: String field2ContainsFold: String - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [OneToManyWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [OneToManyWhereInput!] } -"""Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument.""" +""" +Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument. +""" enum OrderDirection { - """Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument.""" + """ + Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument. + """ ASC - """Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument.""" + """ + Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument. + """ DESC } +type Organization implements Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Workspace") { + id: ID! + name: String! +} +""" +OrganizationWhereInput is used for filtering Workspace objects. +""" +input OrganizationWhereInput { + not: OrganizationWhereInput + and: [OrganizationWhereInput!] + or: [OrganizationWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String +} """ Information about pagination in a connection. https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo """ type PageInfo { - """When paginating forwards, are there more items?""" + """ + When paginating forwards, are there more items? + """ hasNextPage: Boolean! - """When paginating backwards, are there more items?""" + """ + When paginating backwards, are there more items? + """ hasPreviousPage: Boolean! - """When paginating backwards, the cursor to continue.""" + """ + When paginating backwards, the cursor to continue. + """ startCursor: Cursor - """When paginating forwards, the cursor to continue.""" + """ + When paginating forwards, the cursor to continue. + """ endCursor: Cursor } type Project implements Node { id: ID! todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList } -"""ProjectWhereInput is used for filtering Project objects.""" +""" +ProjectWhereInput is used for filtering Project objects. +""" input ProjectWhereInput { not: ProjectWhereInput and: [ProjectWhereInput!] or: [ProjectWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1558,87 +1905,139 @@ input ProjectWhereInput { idGTE: ID idLT: ID idLTE: ID - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] } type Query { - """Fetches an object given its ID.""" + """ + Fetches an object given its ID. + """ node( - """ID of the object.""" + """ + ID of the object. + """ id: ID! ): Node - """Lookup nodes by a list of IDs.""" + """ + Lookup nodes by a list of IDs. + """ nodes( - """The list of node IDs.""" + """ + The list of node IDs. + """ ids: [ID!]! ): [Node]! billProducts: [BillProduct!]! categories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList oneToMany( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for OneToManies returned from the connection.""" + """ + Ordering options for OneToManies returned from the connection. + """ orderBy: OneToManyOrder - """Filtering options for OneToManies returned from the connection.""" + """ + Filtering options for OneToManies returned from the connection. + """ where: OneToManyWhereInput ): OneToManyList - """This is the todo item""" + """ + This is the todo item + """ todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""The builtin Time type""" +""" +The builtin Time type +""" scalar Time type Todo implements Node { id: ID! @@ -1652,39 +2051,65 @@ type Todo implements Node { init: Map custom: [Custom!] customp: [Custom] - """Todo parent""" + """ + Todo parent + """ parent: Todo - """Todo children""" + """ + Todo children + """ children( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList category: Category } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type TodoList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Todo]! } -"""Ordering options for Todo connections""" +""" +Ordering options for Todo connections +""" input TodoOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Todos.""" + """ + The field by which to order Todos. + """ field: TodoOrderField! } -"""Properties by which Todo connections can be ordered.""" +""" +Properties by which Todo connections can be ordered. +""" enum TodoOrderField { CREATED_AT STATUS @@ -1694,18 +2119,24 @@ enum TodoOrderField { CHILDREN_COUNT CATEGORY_TEXT } -"""TodoStatus is enum for the field status""" +""" +TodoStatus is enum for the field status +""" enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { IN_PROGRESS COMPLETED PENDING } -"""TodoWhereInput is used for filtering Todo objects.""" +""" +TodoWhereInput is used for filtering Todo objects. +""" input TodoWhereInput { not: TodoWhereInput and: [TodoWhereInput!] or: [TodoWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1714,7 +2145,9 @@ input TodoWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -1723,12 +2156,16 @@ input TodoWhereInput { createdAtGTE: Time createdAtLT: Time createdAtLTE: Time - """status field predicates""" + """ + status field predicates + """ status: TodoStatus statusNEQ: TodoStatus statusIn: [TodoStatus!] statusNotIn: [TodoStatus!] - """priority field predicates""" + """ + priority field predicates + """ priority: Int priorityNEQ: Int priorityIn: [Int!] @@ -1737,7 +2174,9 @@ input TodoWhereInput { priorityGTE: Int priorityLT: Int priorityLTE: Int - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -1751,31 +2190,45 @@ input TodoWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """category_id field predicates""" + """ + category_id field predicates + """ categoryID: ID categoryIDNEQ: ID categoryIDIn: [ID!] categoryIDNotIn: [ID!] categoryIDIsNil: Boolean categoryIDNotNil: Boolean - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [TodoWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [TodoWhereInput!] - """category edge predicates""" + """ + category edge predicates + """ hasCategory: Boolean hasCategoryWith: [CategoryWhereInput!] } -"""The builtin Uint64 type""" +""" +The builtin Uint64 type +""" scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" +""" +UpdateCategoryInput is used for update Category object. +""" input UpdateCategoryInput { text: String status: CategoryStatus config: CategoryConfigInput clearConfig: Boolean + types: CategoryTypesInput + clearTypes: Boolean duration: Duration clearDuration: Boolean count: Uint64 @@ -1790,13 +2243,17 @@ input UpdateCategoryInput { removeSubCategoryIDs: [ID!] clearSubCategories: Boolean } -"""UpdateFriendshipInput is used for update Friendship object.""" +""" +UpdateFriendshipInput is used for update Friendship object. +""" input UpdateFriendshipInput { createdAt: Time userID: ID friendID: ID } -"""UpdateTodoInput is used for update Todo object.""" +""" +UpdateTodoInput is used for update Todo object. +""" input UpdateTodoInput { status: TodoStatus priority: Int @@ -1811,12 +2268,15 @@ input UpdateTodoInput { secretID: ID clearSecret: Boolean } -"""UpdateUserInput is used for update User object.""" +""" +UpdateUserInput is used for update User object. +""" input UpdateUserInput { name: String username: UUID password: String clearPassword: Boolean + requiredMetadata: Map metadata: Map clearMetadata: Boolean addGroupIDs: [ID!] @@ -1830,66 +2290,107 @@ type User implements Node { id: ID! name: String! username: UUID! + requiredMetadata: Map! metadata: Map - """The groups of the user""" + """ + The groups of the user + """ groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList friends( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList friendships( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Friendships returned from the connection.""" + """ + Filtering options for Friendships returned from the connection. + """ where: FriendshipWhereInput ): FriendshipList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type UserList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [User]! } -"""Ordering options for User connections""" +""" +Ordering options for User connections +""" input UserOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Users.""" + """ + The field by which to order Users. + """ field: UserOrderField! } -"""Properties by which User connections can be ordered.""" +""" +Properties by which User connections can be ordered. +""" enum UserOrderField { GROUPS_COUNT } -"""UserWhereInput is used for filtering User objects.""" +""" +UserWhereInput is used for filtering User objects. +""" input UserWhereInput { not: UserWhereInput and: [UserWhereInput!] or: [UserWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1898,7 +2399,9 @@ input UserWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1912,7 +2415,9 @@ input UserWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """username field predicates""" + """ + username field predicates + """ username: UUID usernameNEQ: UUID usernameIn: [UUID!] @@ -1921,13 +2426,19 @@ input UserWhereInput { usernameGTE: UUID usernameLT: UUID usernameLTE: UUID - """groups edge predicates""" + """ + groups edge predicates + """ hasGroups: Boolean hasGroupsWith: [GroupWhereInput!] - """friends edge predicates""" + """ + friends edge predicates + """ hasFriends: Boolean hasFriendsWith: [UserWhereInput!] - """friendships edge predicates""" + """ + friendships edge predicates + """ hasFriendships: Boolean hasFriendshipsWith: [FriendshipWhereInput!] } @@ -2017,10 +2528,10 @@ func (ec *executionContext) field_Category_todos_args(ctx context.Context, rawAr } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2179,10 +2690,10 @@ func (ec *executionContext) field_Project_todos_args(ctx context.Context, rawArg } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2362,6 +2873,48 @@ func (ec *executionContext) field_Query_oneToMany_args(ctx context.Context, rawA return args, nil } +func (ec *executionContext) field_Query_todosWithJoins_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["offset"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset")) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["offset"] = arg1 + var arg2 []*ent.TodoOrder + if tmp, ok := rawArgs["orderBy"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["orderBy"] = arg2 + var arg3 *ent.TodoWhereInput + if tmp, ok := rawArgs["where"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) + arg3, err = ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["where"] = arg3 + return args, nil +} + func (ec *executionContext) field_Query_todos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2383,10 +2936,10 @@ func (ec *executionContext) field_Query_todos_args(ctx context.Context, rawArgs } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2467,10 +3020,10 @@ func (ec *executionContext) field_Todo_children_args(ctx context.Context, rawArg } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2987,6 +3540,51 @@ func (ec *executionContext) fieldContext_Category_config(ctx context.Context, fi return fc, nil } +func (ec *executionContext) _Category_types(ctx context.Context, field graphql.CollectedField, obj *ent.Category) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Category_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Category().Types(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*CategoryTypes) + fc.Result = res + return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypes(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Category_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Category", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "public": + return ec.fieldContext_CategoryTypes_public(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CategoryTypes", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Category_duration(ctx context.Context, field graphql.CollectedField, obj *ent.Category) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Category_duration(ctx, field) if err != nil { @@ -3124,7 +3722,7 @@ func (ec *executionContext) _Category_todos(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -3163,7 +3761,7 @@ func (ec *executionContext) fieldContext_Category_todos(ctx context.Context, fie ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Category_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3221,7 +3819,7 @@ func (ec *executionContext) fieldContext_Category_subCategories(ctx context.Cont ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Category_subCategories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3399,6 +3997,8 @@ func (ec *executionContext) fieldContext_CategoryList_items(ctx context.Context, return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -3418,6 +4018,47 @@ func (ec *executionContext) fieldContext_CategoryList_items(ctx context.Context, return fc, nil } +func (ec *executionContext) _CategoryTypes_public(ctx context.Context, field graphql.CollectedField, obj *CategoryTypes) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CategoryTypes_public(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Public, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CategoryTypes_public(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CategoryTypes", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Custom_info(ctx context.Context, field graphql.CollectedField, obj *customstruct.Custom) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Custom_info(ctx, field) if err != nil { @@ -3683,6 +4324,8 @@ func (ec *executionContext) fieldContext_Friendship_user(ctx context.Context, fi return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -3743,6 +4386,8 @@ func (ec *executionContext) fieldContext_Friendship_friend(ctx context.Context, return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -4001,7 +4646,7 @@ func (ec *executionContext) fieldContext_Group_users(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Group_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4173,6 +4818,8 @@ func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Con return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -4198,7 +4845,7 @@ func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Con ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createCategory_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4285,7 +4932,7 @@ func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4372,7 +5019,7 @@ func (ec *executionContext) fieldContext_Mutation_updateTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4485,7 +5132,7 @@ func (ec *executionContext) fieldContext_Mutation_updateFriendship(ctx context.C ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateFriendship_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4825,6 +5472,94 @@ func (ec *executionContext) fieldContext_OneToManyList_items(ctx context.Context return fc, nil } +func (ec *executionContext) _Organization_id(ctx context.Context, field graphql.CollectedField, obj *ent1.Workspace) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Organization().ID(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(pulid.ID) + fc.Result = res + return ec.marshalNID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Organization_name(ctx context.Context, field graphql.CollectedField, obj *ent1.Workspace) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[pulid.ID]) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { @@ -5092,7 +5827,7 @@ func (ec *executionContext) fieldContext_Project_todos(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Project_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5144,7 +5879,7 @@ func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5199,7 +5934,7 @@ func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5311,7 +6046,7 @@ func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_categories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5369,7 +6104,7 @@ func (ec *executionContext) fieldContext_Query_groups(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_groups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5427,7 +6162,7 @@ func (ec *executionContext) fieldContext_Query_oneToMany(ctx context.Context, fi ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_oneToMany_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5446,7 +6181,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Todos(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return ec.resolvers.Query().Todos(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5485,7 +6220,7 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5543,7 +6278,7 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5592,8 +6327,8 @@ func (ec *executionContext) fieldContext_Query_ping(ctx context.Context, field g return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _Query_todosWithJoins(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_todosWithJoins(ctx, field) if err != nil { return graphql.Null } @@ -5606,7 +6341,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return ec.resolvers.Query().TodosWithJoins(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5615,21 +6350,79 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*ent.TodoList) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOTodoList2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoList(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_todosWithJoins(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) + case "totalCount": + return ec.fieldContext_TodoList_totalCount(ctx, field) + case "items": + return ec.fieldContext_TodoList_items(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TodoList", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_todosWithJoins_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) case "name": return ec.fieldContext___Type_name(ctx, field) case "description": @@ -5661,7 +6454,7 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6282,7 +7075,7 @@ func (ec *executionContext) _Todo_children(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Children(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Children(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -6321,7 +7114,7 @@ func (ec *executionContext) fieldContext_Todo_children(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Todo_children_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6370,6 +7163,8 @@ func (ec *executionContext) fieldContext_Todo_category(ctx context.Context, fiel return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -6682,6 +7477,50 @@ func (ec *executionContext) fieldContext_User_username(ctx context.Context, fiel return fc, nil } +func (ec *executionContext) _User_requiredMetadata(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_requiredMetadata(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RequiredMetadata, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(map[string]interface{}) + fc.Result = res + return ec.marshalNMap2map(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_requiredMetadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Map does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_metadata(ctx, field) if err != nil { @@ -6776,7 +7615,7 @@ func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_groups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6834,7 +7673,7 @@ func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_friends_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6892,7 +7731,7 @@ func (ec *executionContext) fieldContext_User_friendships(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_friendships_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6986,6 +7825,8 @@ func (ec *executionContext) fieldContext_UserList_items(ctx context.Context, fie return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -8422,7 +9263,7 @@ func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -8610,7 +9451,7 @@ func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -8781,368 +9622,328 @@ func (ec *executionContext) unmarshalInputBillProductWhereInput(ctx context.Cont asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "sku", "skuNEQ", "skuIn", "skuNotIn", "skuGT", "skuGTE", "skuLT", "skuLTE", "skuContains", "skuHasPrefix", "skuHasSuffix", "skuEqualFold", "skuContainsFold", "quantity", "quantityNEQ", "quantityIn", "quantityNotIn", "quantityGT", "quantityGTE", "quantityLT", "quantityLTE"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOBillProductWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐBillProductWhereInput(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐBillProductWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐBillProductWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐBillProductWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐBillProductWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐBillProductWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "sku": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sku")) - it.Sku, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Sku = data case "skuNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuNEQ")) - it.SkuNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuNEQ = data case "skuIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuIn")) - it.SkuIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.SkuIn = data case "skuNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuNotIn")) - it.SkuNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.SkuNotIn = data case "skuGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuGT")) - it.SkuGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuGT = data case "skuGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuGTE")) - it.SkuGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuGTE = data case "skuLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuLT")) - it.SkuLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuLT = data case "skuLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuLTE")) - it.SkuLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuLTE = data case "skuContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuContains")) - it.SkuContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuContains = data case "skuHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuHasPrefix")) - it.SkuHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuHasPrefix = data case "skuHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuHasSuffix")) - it.SkuHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuHasSuffix = data case "skuEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuEqualFold")) - it.SkuEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuEqualFold = data case "skuContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuContainsFold")) - it.SkuContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuContainsFold = data case "quantity": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantity")) - it.Quantity, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Quantity = data case "quantityNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityNEQ")) - it.QuantityNEQ, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityNEQ = data case "quantityIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityIn")) - it.QuantityIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.QuantityIn = data case "quantityNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityNotIn")) - it.QuantityNotIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.QuantityNotIn = data case "quantityGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityGT")) - it.QuantityGT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityGT = data case "quantityGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityGTE")) - it.QuantityGTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityGTE = data case "quantityLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityLT")) - it.QuantityLT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityLT = data case "quantityLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityLTE")) - it.QuantityLTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityLTE = data } } @@ -9156,16 +9957,20 @@ func (ec *executionContext) unmarshalInputCategoryConfigInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"maxMembers"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "maxMembers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("maxMembers")) - it.MaxMembers, err = ec.unmarshalOInt2int(ctx, v) + data, err := ec.unmarshalOInt2int(ctx, v) if err != nil { return it, err } + it.MaxMembers = data } } @@ -9183,24 +9988,54 @@ func (ec *executionContext) unmarshalInputCategoryOrder(ctx context.Context, obj asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNCategoryOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryOrderField(ctx, v) + data, err := ec.unmarshalNCategoryOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCategoryTypesInput(ctx context.Context, obj interface{}) (CategoryTypesInput, error) { + var it CategoryTypesInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"public"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Public = data } } @@ -9214,504 +10049,447 @@ func (ec *executionContext) unmarshalInputCategoryWhereInput(ctx context.Context asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "text", "textNEQ", "textIn", "textNotIn", "textGT", "textGTE", "textLT", "textLTE", "textContains", "textHasPrefix", "textHasSuffix", "textEqualFold", "textContainsFold", "status", "statusNEQ", "statusIn", "statusNotIn", "config", "configNEQ", "configIn", "configNotIn", "configGT", "configGTE", "configLT", "configLTE", "configIsNil", "configNotNil", "duration", "durationNEQ", "durationIn", "durationNotIn", "durationGT", "durationGTE", "durationLT", "durationLTE", "durationIsNil", "durationNotNil", "count", "countNEQ", "countIn", "countNotIn", "countGT", "countGTE", "countLT", "countLTE", "countIsNil", "countNotNil", "hasTodos", "hasTodosWith", "hasSubCategories", "hasSubCategoriesWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInput(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "textNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNEQ")) - it.TextNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextNEQ = data case "textIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textIn")) - it.TextIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextIn = data case "textNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNotIn")) - it.TextNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextNotIn = data case "textGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGT")) - it.TextGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGT = data case "textGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGTE")) - it.TextGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGTE = data case "textLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLT")) - it.TextLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLT = data case "textLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLTE")) - it.TextLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLTE = data case "textContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContains")) - it.TextContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContains = data case "textHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasPrefix")) - it.TextHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasPrefix = data case "textHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasSuffix")) - it.TextHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasSuffix = data case "textEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textEqualFold")) - it.TextEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextEqualFold = data case "textContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContainsFold")) - it.TextContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContainsFold = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "statusNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) - it.StatusNEQ, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.StatusNEQ = data case "statusIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) - it.StatusIn, err = ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusIn = data case "statusNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) - it.StatusNotIn, err = ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusNotIn = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.Config = data case "configNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNEQ")) - it.ConfigNEQ, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigNEQ = data case "configIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configIn")) - it.ConfigIn, err = ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) if err != nil { return it, err } + it.ConfigIn = data case "configNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNotIn")) - it.ConfigNotIn, err = ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) if err != nil { return it, err } + it.ConfigNotIn = data case "configGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configGT")) - it.ConfigGT, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigGT = data case "configGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configGTE")) - it.ConfigGTE, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigGTE = data case "configLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configLT")) - it.ConfigLT, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigLT = data case "configLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configLTE")) - it.ConfigLTE, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigLTE = data case "configIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configIsNil")) - it.ConfigIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ConfigIsNil = data case "configNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNotNil")) - it.ConfigNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ConfigNotNil = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "durationNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNEQ")) - it.DurationNEQ, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationNEQ = data case "durationIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationIn")) - it.DurationIn, err = ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) + data, err := ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) if err != nil { return it, err } + it.DurationIn = data case "durationNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNotIn")) - it.DurationNotIn, err = ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) + data, err := ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) if err != nil { return it, err } + it.DurationNotIn = data case "durationGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationGT")) - it.DurationGT, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationGT = data case "durationGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationGTE")) - it.DurationGTE, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationGTE = data case "durationLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationLT")) - it.DurationLT, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationLT = data case "durationLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationLTE")) - it.DurationLTE, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationLTE = data case "durationIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationIsNil")) - it.DurationIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.DurationIsNil = data case "durationNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNotNil")) - it.DurationNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.DurationNotNil = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "countNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNEQ")) - it.CountNEQ, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountNEQ = data case "countIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countIn")) - it.CountIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.CountIn = data case "countNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNotIn")) - it.CountNotIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.CountNotIn = data case "countGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countGT")) - it.CountGT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountGT = data case "countGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countGTE")) - it.CountGTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountGTE = data case "countLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countLT")) - it.CountLT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountLT = data case "countLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countLTE")) - it.CountLTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountLTE = data case "countIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countIsNil")) - it.CountIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CountIsNil = data case "countNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNotNil")) - it.CountNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CountNotNil = data case "hasTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) - it.HasTodos, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasTodos = data case "hasTodosWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) - it.HasTodosWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasTodosWith = data case "hasSubCategories": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSubCategories")) - it.HasSubCategories, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasSubCategories = data case "hasSubCategoriesWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSubCategoriesWith")) - it.HasSubCategoriesWith, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasSubCategoriesWith = data } } @@ -9725,75 +10503,79 @@ func (ec *executionContext) unmarshalInputCreateCategoryInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"text", "status", "config", "types", "duration", "count", "strings", "todoIDs", "subCategoryIDs", "createTodos"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalNCategoryStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalNCategoryStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + if err != nil { + return it, err + } + it.Config = data + case "types": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("types")) + data, err := ec.unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypesInput(ctx, v) if err != nil { return it, err } + if err = ec.resolvers.CreateCategoryInput().Types(ctx, &it, data); err != nil { + return it, err + } case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "strings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strings")) - it.Strings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Strings = data case "todoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("todoIDs")) - it.TodoIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.TodoIDs = data case "subCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subCategoryIDs")) - it.SubCategoryIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.SubCategoryIDs = data case "createTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTodos")) data, err := ec.unmarshalOCreateTodoInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCreateTodoInputᚄ(ctx, v) if err != nil { @@ -9815,11 +10597,14 @@ func (ec *executionContext) unmarshalInputCreateTodoInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "init", "parentID", "childIDs", "categoryID", "secretID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalNTodoStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -9829,61 +10614,54 @@ func (ec *executionContext) unmarshalInputCreateTodoInput(ctx context.Context, o return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "init": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("init")) - it.Init, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Init = data case "parentID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) - it.ParentID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ParentID = data case "childIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("childIDs")) - it.ChildIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.ChildIDs = data case "categoryID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryID")) - it.CategoryID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.CategoryID = data case "secretID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretID")) - it.SecretID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.SecretID = data } } @@ -9897,19 +10675,21 @@ func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "username", "password", "requiredMetadata", "metadata", "groupIDs", "friendIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -9919,37 +10699,40 @@ func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, o return it, err } case "password": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Password = data + case "requiredMetadata": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requiredMetadata")) + data, err := ec.unmarshalNMap2map(ctx, v) + if err != nil { + return it, err + } + it.RequiredMetadata = data case "metadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadata")) - it.Metadata, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Metadata = data case "groupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIDs")) - it.GroupIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.GroupIDs = data case "friendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("friendIDs")) - it.FriendIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.FriendIDs = data } } @@ -9963,160 +10746,146 @@ func (ec *executionContext) unmarshalInputFriendshipWhereInput(ctx context.Conte asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendshipWhereInput(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendshipWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "createdAt": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAt = data case "createdAtNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtNEQ = data case "createdAtIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtIn = data case "createdAtNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtNotIn = data case "createdAtGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGT = data case "createdAtGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGTE = data case "createdAtLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLT = data case "createdAtLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLTE = data } } @@ -10130,216 +10899,195 @@ func (ec *executionContext) unmarshalInputGroupWhereInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasUsers", "hasUsersWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroupWhereInput(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroupWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "hasUsers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUsers")) - it.HasUsers, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasUsers = data case "hasUsersWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUsersWith")) - it.HasUsersWith, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasUsersWith = data } } @@ -10357,24 +11105,27 @@ func (ec *executionContext) unmarshalInputOneToManyOrder(ctx context.Context, ob asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNOneToManyOrderField2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyOrderField(ctx, v) + data, err := ec.unmarshalNOneToManyOrderField2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -10388,676 +11139,805 @@ func (ec *executionContext) unmarshalInputOneToManyWhereInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "field2", "field2NEQ", "field2In", "field2NotIn", "field2GT", "field2GTE", "field2LT", "field2LTE", "field2Contains", "field2HasPrefix", "field2HasSuffix", "field2IsNil", "field2NotNil", "field2EqualFold", "field2ContainsFold", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInput(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNeq, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGt, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGte, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLt, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLte, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLte = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNeq, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNeq = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGt = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGte = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLt = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLte = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "field2": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2")) - it.Field2, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2 = data case "field2NEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NEQ")) - it.Field2neq, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2neq = data case "field2In": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2In")) - it.Field2In, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Field2In = data case "field2NotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NotIn")) - it.Field2NotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Field2NotIn = data case "field2GT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2GT")) - it.Field2gt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2gt = data case "field2GTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2GTE")) - it.Field2gte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2gte = data case "field2LT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2LT")) - it.Field2lt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2lt = data case "field2LTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2LTE")) - it.Field2lte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2lte = data case "field2Contains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2Contains")) - it.Field2Contains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2Contains = data case "field2HasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2HasPrefix")) - it.Field2HasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2HasPrefix = data case "field2HasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2HasSuffix")) - it.Field2HasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2HasSuffix = data case "field2IsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2IsNil")) - it.Field2IsNil, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Field2IsNil = data case "field2NotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NotNil")) - it.Field2NotNil, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Field2NotNil = data case "field2EqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2EqualFold")) - it.Field2EqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2EqualFold = data case "field2ContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2ContainsFold")) - it.Field2ContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2ContainsFold = data case "hasParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParent")) - it.HasParent, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasParent = data case "hasParentWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParentWith")) - it.HasParentWith, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasParentWith = data case "hasChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildren")) - it.HasChildren, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasChildren = data case "hasChildrenWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildrenWith")) - it.HasChildrenWith, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasChildrenWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputProjectWhereInput(ctx context.Context, obj interface{}) (ProjectWhereInput, error) { - var it ProjectWhereInput +func (ec *executionContext) unmarshalInputOrganizationWhereInput(ctx context.Context, obj interface{}) (OrganizationWhereInput, error) { + var it OrganizationWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐProjectWhereInput(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOrganizationWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐProjectWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOrganizationWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐProjectWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOrganizationWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNeq, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGt, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGte, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLt, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLte, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } - case "hasTodos": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) - it.HasTodos, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.IDLte = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hasTodosWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) - it.HasTodosWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj interface{}) (ent.TodoOrder, error) { - var it ent.TodoOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - for k, v := range asMap { - switch k { - case "direction": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + it.NameNeq = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "field": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderField(ctx, v) + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGt = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGte = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLt = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLte = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data } } return it, nil } -func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, obj interface{}) (ent.TodoWhereInput, error) { - var it ent.TodoWhereInput +func (ec *executionContext) unmarshalInputProjectWhereInput(ctx context.Context, obj interface{}) (ProjectWhereInput, error) { + var it ProjectWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "hasTodos", "hasTodosWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInput(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐProjectWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐProjectWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐProjectWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } - case "createdAt": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IDLte = data + case "hasTodos": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "createdAtNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.HasTodos = data + case "hasTodosWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "createdAtIn": - var err error + it.HasTodosWith = data + } + } - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + return it, nil +} + +func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj interface{}) (ent.TodoOrder, error) { + var it ent.TodoOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - case "createdAtNotIn": - var err error + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, obj interface{}) (ent.TodoWhereInput, error) { + var it ent.TodoWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "status", "statusNEQ", "statusIn", "statusNotIn", "priority", "priorityNEQ", "priorityIn", "priorityNotIn", "priorityGT", "priorityGTE", "priorityLT", "priorityLTE", "text", "textNEQ", "textIn", "textNotIn", "textGT", "textGTE", "textLT", "textLTE", "textContains", "textHasPrefix", "textHasSuffix", "textEqualFold", "textContainsFold", "categoryID", "categoryIDNEQ", "categoryIDIn", "categoryIDNotIn", "categoryIDIsNil", "categoryIDNotNil", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith", "hasCategory", "hasCategoryWith", "createdToday"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtNotIn = data case "createdAtGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGT = data case "createdAtGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGTE = data case "createdAtLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLT = data case "createdAtLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLTE = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11067,8 +11947,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11078,8 +11956,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) data, err := ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) if err != nil { @@ -11089,8 +11965,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) data, err := ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) if err != nil { @@ -11100,272 +11974,237 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "priorityNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityNEQ")) - it.PriorityNEQ, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityNEQ = data case "priorityIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityIn")) - it.PriorityIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.PriorityIn = data case "priorityNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityNotIn")) - it.PriorityNotIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.PriorityNotIn = data case "priorityGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityGT")) - it.PriorityGT, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityGT = data case "priorityGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityGTE")) - it.PriorityGTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityGTE = data case "priorityLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityLT")) - it.PriorityLT, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityLT = data case "priorityLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityLTE")) - it.PriorityLTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityLTE = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "textNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNEQ")) - it.TextNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextNEQ = data case "textIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textIn")) - it.TextIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextIn = data case "textNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNotIn")) - it.TextNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextNotIn = data case "textGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGT")) - it.TextGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGT = data case "textGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGTE")) - it.TextGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGTE = data case "textLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLT")) - it.TextLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLT = data case "textLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLTE")) - it.TextLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLTE = data case "textContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContains")) - it.TextContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContains = data case "textHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasPrefix")) - it.TextHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasPrefix = data case "textHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasSuffix")) - it.TextHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasSuffix = data case "textEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textEqualFold")) - it.TextEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextEqualFold = data case "textContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContainsFold")) - it.TextContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContainsFold = data case "categoryID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryID")) - it.CategoryID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.CategoryID = data case "categoryIDNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNEQ")) - it.CategoryIDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.CategoryIDNEQ = data case "categoryIDIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDIn")) - it.CategoryIDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.CategoryIDIn = data case "categoryIDNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNotIn")) - it.CategoryIDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.CategoryIDNotIn = data case "categoryIDIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDIsNil")) - it.CategoryIDIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CategoryIDIsNil = data case "categoryIDNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNotNil")) - it.CategoryIDNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CategoryIDNotNil = data case "hasParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParent")) - it.HasParent, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasParent = data case "hasParentWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParentWith")) - it.HasParentWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasParentWith = data case "hasChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildren")) - it.HasChildren, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasChildren = data case "hasChildrenWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildrenWith")) - it.HasChildrenWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasChildrenWith = data case "hasCategory": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCategory")) - it.HasCategory, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasCategory = data case "hasCategoryWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCategoryWith")) - it.HasCategoryWith, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasCategoryWith = data case "createdToday": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdToday")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { @@ -11387,144 +12226,148 @@ func (ec *executionContext) unmarshalInputUpdateCategoryInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"text", "status", "config", "clearConfig", "types", "clearTypes", "duration", "clearDuration", "count", "clearCount", "strings", "appendStrings", "clearStrings", "addTodoIDs", "removeTodoIDs", "clearTodos", "addSubCategoryIDs", "removeSubCategoryIDs", "clearSubCategories"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.Config = data case "clearConfig": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearConfig")) - it.ClearConfig, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearConfig = data + case "types": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("types")) + data, err := ec.unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypesInput(ctx, v) if err != nil { return it, err } + if err = ec.resolvers.UpdateCategoryInput().Types(ctx, &it, data); err != nil { + return it, err + } + case "clearTypes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTypes")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearTypes = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "clearDuration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearDuration")) - it.ClearDuration, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearDuration = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "clearCount": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearCount")) - it.ClearCount, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearCount = data case "strings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strings")) - it.Strings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Strings = data case "appendStrings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("appendStrings")) - it.AppendStrings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.AppendStrings = data case "clearStrings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearStrings")) - it.ClearStrings, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearStrings = data case "addTodoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addTodoIDs")) - it.AddTodoIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.AddTodoIDs = data case "removeTodoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeTodoIDs")) - it.RemoveTodoIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveTodoIDs = data case "clearTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTodos")) - it.ClearTodos, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearTodos = data case "addSubCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addSubCategoryIDs")) - it.AddSubCategoryIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.AddSubCategoryIDs = data case "removeSubCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeSubCategoryIDs")) - it.RemoveSubCategoryIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveSubCategoryIDs = data case "clearSubCategories": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSubCategories")) - it.ClearSubCategories, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearSubCategories = data } } @@ -11538,32 +12381,34 @@ func (ec *executionContext) unmarshalInputUpdateFriendshipInput(ctx context.Cont asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"createdAt", "userID", "friendID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "createdAt": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAt = data case "userID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - it.UserID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.UserID = data case "friendID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("friendID")) - it.FriendID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.FriendID = data } } @@ -11577,11 +12422,14 @@ func (ec *executionContext) unmarshalInputUpdateTodoInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "init", "clearInit", "parentID", "clearParent", "addChildIDs", "removeChildIDs", "clearChildren", "secretID", "clearSecret"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11591,93 +12439,82 @@ func (ec *executionContext) unmarshalInputUpdateTodoInput(ctx context.Context, o return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "init": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("init")) - it.Init, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Init = data case "clearInit": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearInit")) - it.ClearInit, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearInit = data case "parentID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) - it.ParentID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ParentID = data case "clearParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearParent")) - it.ClearParent, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearParent = data case "addChildIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addChildIDs")) - it.AddChildIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.AddChildIDs = data case "removeChildIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeChildIDs")) - it.RemoveChildIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveChildIDs = data case "clearChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearChildren")) - it.ClearChildren, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearChildren = data case "secretID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretID")) - it.SecretID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.SecretID = data case "clearSecret": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSecret")) - it.ClearSecret, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearSecret = data } } @@ -11691,19 +12528,21 @@ func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "username", "password", "clearPassword", "requiredMetadata", "metadata", "clearMetadata", "addGroupIDs", "removeGroupIDs", "clearGroups", "addFriendIDs", "removeFriendIDs", "clearFriends"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -11713,85 +12552,82 @@ func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, o return it, err } case "password": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Password = data case "clearPassword": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearPassword")) - it.ClearPassword, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearPassword = data + case "requiredMetadata": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requiredMetadata")) + data, err := ec.unmarshalOMap2map(ctx, v) + if err != nil { + return it, err + } + it.RequiredMetadata = data case "metadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadata")) - it.Metadata, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Metadata = data case "clearMetadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearMetadata")) - it.ClearMetadata, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearMetadata = data case "addGroupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addGroupIDs")) - it.AddGroupIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.AddGroupIDs = data case "removeGroupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeGroupIDs")) - it.RemoveGroupIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveGroupIDs = data case "clearGroups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearGroups")) - it.ClearGroups, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearGroups = data case "addFriendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addFriendIDs")) - it.AddFriendIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.AddFriendIDs = data case "removeFriendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeFriendIDs")) - it.RemoveFriendIDs, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveFriendIDs = data case "clearFriends": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearFriends")) - it.ClearFriends, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearFriends = data } } @@ -11809,24 +12645,27 @@ func (ec *executionContext) unmarshalInputUserOrder(ctx context.Context, obj int asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNUserOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserOrderField(ctx, v) + data, err := ec.unmarshalNUserOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -11840,203 +12679,182 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "username", "usernameNEQ", "usernameIn", "usernameNotIn", "usernameGT", "usernameGTE", "usernameLT", "usernameLTE", "hasGroups", "hasGroupsWith", "hasFriends", "hasFriendsWith", "hasFriendships", "hasFriendshipsWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOUserWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInput(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) + data, err := ec.unmarshalOID2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12046,8 +12864,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameNEQ")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12057,8 +12873,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameIn")) data, err := ec.unmarshalOUUID2ᚕstringᚄ(ctx, v) if err != nil { @@ -12068,8 +12882,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameNotIn")) data, err := ec.unmarshalOUUID2ᚕstringᚄ(ctx, v) if err != nil { @@ -12079,8 +12891,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameGT")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12090,8 +12900,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameGTE")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12101,8 +12909,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameLT")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12112,8 +12918,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameLTE")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12123,53 +12927,47 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "hasGroups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasGroups")) - it.HasGroups, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasGroups = data case "hasGroupsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasGroupsWith")) - it.HasGroupsWith, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasGroupsWith = data case "hasFriends": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriends")) - it.HasFriends, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasFriends = data case "hasFriendsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendsWith")) - it.HasFriendsWith, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasFriendsWith = data case "hasFriendships": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendships")) - it.HasFriendships, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasFriendships = data case "hasFriendshipsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendshipsWith")) - it.HasFriendshipsWith, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasFriendshipsWith = data } } @@ -12180,30 +12978,44 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob // region ************************** interface.gotpl *************************** -func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { +func (ec *executionContext) _NamedNode(ctx context.Context, sel ast.SelectionSet, obj NamedNode) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null - case *ent.BillProduct: + case *ent.Group: if obj == nil { return graphql.Null } - return ec._BillProduct(ctx, sel, obj) - case *ent.Category: + return ec._Group(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case *ent.Group: if obj == nil { return graphql.Null } - return ec._Category(ctx, sel, obj) - case *ent.Friendship: + return ec._Group(ctx, sel, obj) + case *ent.BillProduct: if obj == nil { return graphql.Null } - return ec._Friendship(ctx, sel, obj) - case *ent.Group: + return ec._BillProduct(ctx, sel, obj) + case *ent.Category: if obj == nil { return graphql.Null } - return ec._Group(ctx, sel, obj) + return ec._Category(ctx, sel, obj) + case *ent.Friendship: + if obj == nil { + return graphql.Null + } + return ec._Friendship(ctx, sel, obj) case OneToMany: return ec._OneToMany(ctx, sel, &obj) case *OneToMany: @@ -12211,6 +13023,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._OneToMany(ctx, sel, obj) + case *ent1.Workspace: + if obj == nil { + return graphql.Null + } + return ec._Organization(ctx, sel, obj) case Project: return ec._Project(ctx, sel, &obj) case *Project: @@ -12241,48 +13058,53 @@ var billProductImplementors = []string{"BillProduct", "Node"} func (ec *executionContext) _BillProduct(ctx context.Context, sel ast.SelectionSet, obj *ent.BillProduct) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, billProductImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("BillProduct") case "id": - out.Values[i] = ec._BillProduct_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec._BillProduct_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "sku": - out.Values[i] = ec._BillProduct_sku(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "quantity": - out.Values[i] = ec._BillProduct_quantity(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12290,53 +13112,73 @@ var categoryImplementors = []string{"Category", "Node"} func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, obj *ent.Category) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Category") case "id": - out.Values[i] = ec._Category_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Category_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "status": - out.Values[i] = ec._Category_status(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "config": - out.Values[i] = ec._Category_config(ctx, field, obj) + case "types": + field := field - case "duration": + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Category_types(ctx, field, obj) + return res + } - out.Values[i] = ec._Category_duration(ctx, field, obj) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - case "count": + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "duration": + out.Values[i] = ec._Category_duration(ctx, field, obj) + case "count": out.Values[i] = ec._Category_count(ctx, field, obj) - case "strings": - out.Values[i] = ec._Category_strings(ctx, field, obj) - case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12346,14 +13188,30 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "subCategories": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12363,14 +13221,30 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "todosCount": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12380,18 +13254,46 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12399,24 +13301,35 @@ var categoryConfigImplementors = []string{"CategoryConfig"} func (ec *executionContext) _CategoryConfig(ctx context.Context, sel ast.SelectionSet, obj *schematype.CategoryConfig) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryConfigImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryConfig") case "maxMembers": - out.Values[i] = ec._CategoryConfig_maxMembers(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12424,34 +13337,79 @@ var categoryListImplementors = []string{"CategoryList"} func (ec *executionContext) _CategoryList(ctx context.Context, sel ast.SelectionSet, obj *ent.CategoryList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryList") case "totalCount": - out.Values[i] = ec._CategoryList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._CategoryList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var categoryTypesImplementors = []string{"CategoryTypes"} + +func (ec *executionContext) _CategoryTypes(ctx context.Context, sel ast.SelectionSet, obj *CategoryTypes) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, categoryTypesImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CategoryTypes") + case "public": + out.Values[i] = ec._CategoryTypes_public(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12459,27 +13417,38 @@ var customImplementors = []string{"Custom"} func (ec *executionContext) _Custom(ctx context.Context, sel ast.SelectionSet, obj *customstruct.Custom) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, customImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Custom") case "info": - out.Values[i] = ec._Custom_info(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12487,44 +13456,37 @@ var friendshipImplementors = []string{"Friendship", "Node"} func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSet, obj *ent.Friendship) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendshipImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Friendship") case "id": - out.Values[i] = ec._Friendship_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Friendship_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "userID": - out.Values[i] = ec._Friendship_userID(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "friendID": - out.Values[i] = ec._Friendship_friendID(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "user": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12532,19 +13494,35 @@ func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSe }() res = ec._Friendship_user(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friend": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12552,23 +13530,51 @@ func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSe }() res = ec._Friendship_friend(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12576,65 +13582,71 @@ var friendshipListImplementors = []string{"FriendshipList"} func (ec *executionContext) _FriendshipList(ctx context.Context, sel ast.SelectionSet, obj *ent.FriendshipList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendshipListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FriendshipList") case "totalCount": - out.Values[i] = ec._FriendshipList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._FriendshipList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } -var groupImplementors = []string{"Group", "Node"} +var groupImplementors = []string{"Group", "Node", "NamedNode"} func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, obj *ent.Group) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, groupImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Group") case "id": - out.Values[i] = ec._Group_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._Group_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "users": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12644,18 +13656,46 @@ func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, ob return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12663,34 +13703,43 @@ var groupListImplementors = []string{"GroupList"} func (ec *executionContext) _GroupList(ctx context.Context, sel ast.SelectionSet, obj *ent.GroupList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, groupListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("GroupList") case "totalCount": - out.Values[i] = ec._GroupList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._GroupList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12703,7 +13752,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -12714,58 +13763,60 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createCategory": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createCategory(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "createTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "updateTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "clearTodos": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_clearTodos(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "updateFriendship": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateFriendship(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12773,46 +13824,49 @@ var oneToManyImplementors = []string{"OneToMany", "Node"} func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet, obj *OneToMany) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, oneToManyImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OneToMany") case "id": - out.Values[i] = ec._OneToMany_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec._OneToMany_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "field2": - out.Values[i] = ec._OneToMany_field2(ctx, field, obj) - case "parent": - out.Values[i] = ec._OneToMany_parent(ctx, field, obj) - case "children": - out.Values[i] = ec._OneToMany_children(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12820,34 +13874,118 @@ var oneToManyListImplementors = []string{"OneToManyList"} func (ec *executionContext) _OneToManyList(ctx context.Context, sel ast.SelectionSet, obj *OneToManyList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, oneToManyListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OneToManyList") case "totalCount": - out.Values[i] = ec._OneToManyList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._OneToManyList_items(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var organizationImplementors = []string{"Organization", "Node"} + +func (ec *executionContext) _Organization(ctx context.Context, sel ast.SelectionSet, obj *ent1.Workspace) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, organizationImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Organization") + case "id": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Organization_id(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "name": + out.Values[i] = ec._Organization_name(ctx, field, obj) if out.Values[i] == graphql.Null { - invalids++ + atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12855,42 +13993,47 @@ var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[pulid.ID]) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12898,31 +14041,40 @@ var projectImplementors = []string{"Project", "Node"} func (ec *executionContext) _Project(ctx context.Context, sel ast.SelectionSet, obj *Project) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, projectImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Project") case "id": - out.Values[i] = ec._Project_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "todos": - out.Values[i] = ec._Project_todos(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12935,7 +14087,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -12948,7 +14100,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "node": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12959,16 +14111,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nodes": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12976,22 +14127,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_nodes(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "billProducts": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12999,22 +14149,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_billProducts(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "categories": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13025,16 +14174,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "groups": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13045,16 +14193,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "oneToMany": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13065,16 +14212,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13085,16 +14231,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "users": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13105,16 +14250,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "ping": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13122,38 +14266,64 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_ping(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "__type": + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "todosWithJoins": + field := field + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_todosWithJoins(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) - case "__schema": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13161,30 +14331,27 @@ var todoImplementors = []string{"Todo", "Node"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *ent.Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Todo_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "status": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13192,57 +14359,57 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj }() res = ec._Todo_status(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) - case "priorityOrder": + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "priorityOrder": out.Values[i] = ec._Todo_priorityOrder(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "categoryID": - out.Values[i] = ec._Todo_categoryID(ctx, field, obj) - case "category_id": - out.Values[i] = ec._Todo_category_id(ctx, field, obj) - case "categoryX": - out.Values[i] = ec._Todo_categoryX(ctx, field, obj) - case "init": - out.Values[i] = ec._Todo_init(ctx, field, obj) - case "custom": - out.Values[i] = ec._Todo_custom(ctx, field, obj) - case "customp": - out.Values[i] = ec._Todo_customp(ctx, field, obj) - case "parent": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13252,14 +14419,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "children": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13269,14 +14452,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "category": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13286,14 +14485,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "extendedField": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13303,18 +14518,46 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13322,34 +14565,43 @@ var todoListImplementors = []string{"TodoList"} func (ec *executionContext) _TodoList(ctx context.Context, sel ast.SelectionSet, obj *ent.TodoList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("TodoList") case "totalCount": - out.Values[i] = ec._TodoList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._TodoList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13357,30 +14609,27 @@ var userImplementors = []string{"User", "Node"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *ent.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "username": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13388,23 +14637,42 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj }() res = ec._User_username(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) - case "metadata": + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "requiredMetadata": + out.Values[i] = ec._User_requiredMetadata(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "metadata": out.Values[i] = ec._User_metadata(ctx, field, obj) - case "groups": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13414,14 +14682,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friends": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13431,14 +14715,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friendships": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13448,18 +14748,46 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13467,34 +14795,43 @@ var userListImplementors = []string{"UserList"} func (ec *executionContext) _UserList(ctx context.Context, sel ast.SelectionSet, obj *ent.UserList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("UserList") case "totalCount": - out.Values[i] = ec._UserList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._UserList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13502,52 +14839,55 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isRepeatable": - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13555,42 +14895,47 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13598,56 +14943,57 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13655,42 +15001,47 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13698,53 +15049,54 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "description": - out.Values[i] = ec.___Schema_description(ctx, field, obj) - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13752,63 +15104,56 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - case "specifiedByURL": - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -14174,6 +15519,27 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } +func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + func (ec *executionContext) marshalNNode2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v []ent.Noder) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -14285,6 +15651,11 @@ func (ec *executionContext) marshalNOrderDirection2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) unmarshalNOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOrganizationWhereInput(ctx context.Context, v interface{}) (*OrganizationWhereInput, error) { + res, err := ec.unmarshalInputOrganizationWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐProjectWhereInput(ctx context.Context, v interface{}) (*ProjectWhereInput, error) { res, err := ec.unmarshalInputProjectWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -14404,6 +15775,11 @@ func (ec *executionContext) marshalNTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinte return ec._Todo(ctx, sel, v) } +func (ec *executionContext) unmarshalNTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrder(ctx context.Context, v interface{}) (*ent.TodoOrder, error) { + res, err := ec.unmarshalInputTodoOrder(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderField(ctx context.Context, v interface{}) (*ent.TodoOrderField, error) { var res = new(ent.TodoOrderField) err := res.UnmarshalGQL(v) @@ -15003,6 +16379,21 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } +func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypesInput(ctx context.Context, v interface{}) (*CategoryTypesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputCategoryTypesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.CategoryWhereInput, error) { if v == nil { return nil, nil @@ -15558,6 +16949,34 @@ func (ec *executionContext) unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontri return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOrganizationWhereInputᚄ(ctx context.Context, v interface{}) ([]*OrganizationWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*OrganizationWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOrganizationWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOrganizationWhereInput(ctx context.Context, v interface{}) (*OrganizationWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputOrganizationWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐProjectWhereInputᚄ(ctx context.Context, v interface{}) ([]*ProjectWhereInput, error) { if v == nil { return nil, nil @@ -15708,12 +17127,24 @@ func (ec *executionContext) marshalOTodoList2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._TodoList(ctx, sel, v) } -func (ec *executionContext) unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrder(ctx context.Context, v interface{}) (*ent.TodoOrder, error) { +func (ec *executionContext) unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrderᚄ(ctx context.Context, v interface{}) ([]*ent.TodoOrder, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalInputTodoOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.TodoOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodoOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil } func (ec *executionContext) unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx context.Context, v interface{}) ([]todo.Status, error) { diff --git a/entgql/internal/todopulid/gqlgen.yml b/entgql/internal/todopulid/gqlgen.yml index b03e76372..e40f6e2e5 100644 --- a/entgql/internal/todopulid/gqlgen.yml +++ b/entgql/internal/todopulid/gqlgen.yml @@ -17,6 +17,8 @@ autobind: - entgo.io/contrib/entgql/internal/todopulid/ent/todo - entgo.io/contrib/entgql/internal/todo/ent/schema/customstruct +# Disable the generated getters for all models and interfaces. +omit_getters: true models: ID: model: diff --git a/entgql/internal/todopulid/models_gen.go b/entgql/internal/todopulid/models_gen.go index 7f1213107..cb9d35774 100644 --- a/entgql/internal/todopulid/models_gen.go +++ b/entgql/internal/todopulid/models_gen.go @@ -13,12 +13,24 @@ import ( "entgo.io/contrib/entgql/internal/todopulid/ent/schema/pulid" ) +type NamedNode interface { + IsNamedNode() +} + +type CategoryTypes struct { + Public *bool `json:"public,omitempty"` +} + +type CategoryTypesInput struct { + Public *bool `json:"public,omitempty"` +} + type OneToMany struct { ID pulid.ID `json:"id"` Name string `json:"name"` - Field2 *string `json:"field2"` - Parent *OneToMany `json:"parent"` - Children []*OneToMany `json:"children"` + Field2 *string `json:"field2,omitempty"` + Parent *OneToMany `json:"parent,omitempty"` + Children []*OneToMany `json:"children,omitempty"` } func (OneToMany) IsNode() {} @@ -41,87 +53,117 @@ type OneToManyOrder struct { // OneToManyWhereInput is used for filtering OneToMany objects. type OneToManyWhereInput struct { - Not *OneToManyWhereInput `json:"not"` - And []*OneToManyWhereInput `json:"and"` - Or []*OneToManyWhereInput `json:"or"` + Not *OneToManyWhereInput `json:"not,omitempty"` + And []*OneToManyWhereInput `json:"and,omitempty"` + Or []*OneToManyWhereInput `json:"or,omitempty"` // id field predicates - ID *pulid.ID `json:"id"` - IDNeq *pulid.ID `json:"idNEQ"` - IDIn []pulid.ID `json:"idIn"` - IDNotIn []pulid.ID `json:"idNotIn"` - IDGt *pulid.ID `json:"idGT"` - IDGte *pulid.ID `json:"idGTE"` - IDLt *pulid.ID `json:"idLT"` - IDLte *pulid.ID `json:"idLTE"` + ID *pulid.ID `json:"id,omitempty"` + IDNeq *pulid.ID `json:"idNEQ,omitempty"` + IDIn []pulid.ID `json:"idIn,omitempty"` + IDNotIn []pulid.ID `json:"idNotIn,omitempty"` + IDGt *pulid.ID `json:"idGT,omitempty"` + IDGte *pulid.ID `json:"idGTE,omitempty"` + IDLt *pulid.ID `json:"idLT,omitempty"` + IDLte *pulid.ID `json:"idLTE,omitempty"` // name field predicates - Name *string `json:"name"` - NameNeq *string `json:"nameNEQ"` - NameIn []string `json:"nameIn"` - NameNotIn []string `json:"nameNotIn"` - NameGt *string `json:"nameGT"` - NameGte *string `json:"nameGTE"` - NameLt *string `json:"nameLT"` - NameLte *string `json:"nameLTE"` - NameContains *string `json:"nameContains"` - NameHasPrefix *string `json:"nameHasPrefix"` - NameHasSuffix *string `json:"nameHasSuffix"` - NameEqualFold *string `json:"nameEqualFold"` - NameContainsFold *string `json:"nameContainsFold"` + Name *string `json:"name,omitempty"` + NameNeq *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGt *string `json:"nameGT,omitempty"` + NameGte *string `json:"nameGTE,omitempty"` + NameLt *string `json:"nameLT,omitempty"` + NameLte *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` // field2 field predicates - Field2 *string `json:"field2"` - Field2neq *string `json:"field2NEQ"` - Field2In []string `json:"field2In"` - Field2NotIn []string `json:"field2NotIn"` - Field2gt *string `json:"field2GT"` - Field2gte *string `json:"field2GTE"` - Field2lt *string `json:"field2LT"` - Field2lte *string `json:"field2LTE"` - Field2Contains *string `json:"field2Contains"` - Field2HasPrefix *string `json:"field2HasPrefix"` - Field2HasSuffix *string `json:"field2HasSuffix"` - Field2IsNil *bool `json:"field2IsNil"` - Field2NotNil *bool `json:"field2NotNil"` - Field2EqualFold *string `json:"field2EqualFold"` - Field2ContainsFold *string `json:"field2ContainsFold"` + Field2 *string `json:"field2,omitempty"` + Field2neq *string `json:"field2NEQ,omitempty"` + Field2In []string `json:"field2In,omitempty"` + Field2NotIn []string `json:"field2NotIn,omitempty"` + Field2gt *string `json:"field2GT,omitempty"` + Field2gte *string `json:"field2GTE,omitempty"` + Field2lt *string `json:"field2LT,omitempty"` + Field2lte *string `json:"field2LTE,omitempty"` + Field2Contains *string `json:"field2Contains,omitempty"` + Field2HasPrefix *string `json:"field2HasPrefix,omitempty"` + Field2HasSuffix *string `json:"field2HasSuffix,omitempty"` + Field2IsNil *bool `json:"field2IsNil,omitempty"` + Field2NotNil *bool `json:"field2NotNil,omitempty"` + Field2EqualFold *string `json:"field2EqualFold,omitempty"` + Field2ContainsFold *string `json:"field2ContainsFold,omitempty"` // parent edge predicates - HasParent *bool `json:"hasParent"` - HasParentWith []*OneToManyWhereInput `json:"hasParentWith"` + HasParent *bool `json:"hasParent,omitempty"` + HasParentWith []*OneToManyWhereInput `json:"hasParentWith,omitempty"` // children edge predicates - HasChildren *bool `json:"hasChildren"` - HasChildrenWith []*OneToManyWhereInput `json:"hasChildrenWith"` + HasChildren *bool `json:"hasChildren,omitempty"` + HasChildrenWith []*OneToManyWhereInput `json:"hasChildrenWith,omitempty"` +} + +// OrganizationWhereInput is used for filtering Workspace objects. +type OrganizationWhereInput struct { + Not *OrganizationWhereInput `json:"not,omitempty"` + And []*OrganizationWhereInput `json:"and,omitempty"` + Or []*OrganizationWhereInput `json:"or,omitempty"` + // id field predicates + ID *pulid.ID `json:"id,omitempty"` + IDNeq *pulid.ID `json:"idNEQ,omitempty"` + IDIn []pulid.ID `json:"idIn,omitempty"` + IDNotIn []pulid.ID `json:"idNotIn,omitempty"` + IDGt *pulid.ID `json:"idGT,omitempty"` + IDGte *pulid.ID `json:"idGTE,omitempty"` + IDLt *pulid.ID `json:"idLT,omitempty"` + IDLte *pulid.ID `json:"idLTE,omitempty"` + // name field predicates + Name *string `json:"name,omitempty"` + NameNeq *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGt *string `json:"nameGT,omitempty"` + NameGte *string `json:"nameGTE,omitempty"` + NameLt *string `json:"nameLT,omitempty"` + NameLte *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` } type Project struct { ID pulid.ID `json:"id"` - Todos *ent.TodoList `json:"todos"` + Todos *ent.TodoList `json:"todos,omitempty"` } func (Project) IsNode() {} // ProjectWhereInput is used for filtering Project objects. type ProjectWhereInput struct { - Not *ProjectWhereInput `json:"not"` - And []*ProjectWhereInput `json:"and"` - Or []*ProjectWhereInput `json:"or"` + Not *ProjectWhereInput `json:"not,omitempty"` + And []*ProjectWhereInput `json:"and,omitempty"` + Or []*ProjectWhereInput `json:"or,omitempty"` // id field predicates - ID *pulid.ID `json:"id"` - IDNeq *pulid.ID `json:"idNEQ"` - IDIn []pulid.ID `json:"idIn"` - IDNotIn []pulid.ID `json:"idNotIn"` - IDGt *pulid.ID `json:"idGT"` - IDGte *pulid.ID `json:"idGTE"` - IDLt *pulid.ID `json:"idLT"` - IDLte *pulid.ID `json:"idLTE"` + ID *pulid.ID `json:"id,omitempty"` + IDNeq *pulid.ID `json:"idNEQ,omitempty"` + IDIn []pulid.ID `json:"idIn,omitempty"` + IDNotIn []pulid.ID `json:"idNotIn,omitempty"` + IDGt *pulid.ID `json:"idGT,omitempty"` + IDGte *pulid.ID `json:"idGTE,omitempty"` + IDLt *pulid.ID `json:"idLT,omitempty"` + IDLte *pulid.ID `json:"idLTE,omitempty"` // todos edge predicates - HasTodos *bool `json:"hasTodos"` - HasTodosWith []*ent.TodoWhereInput `json:"hasTodosWith"` + HasTodos *bool `json:"hasTodos,omitempty"` + HasTodosWith []*ent.TodoWhereInput `json:"hasTodosWith,omitempty"` } // UpdateFriendshipInput is used for update Friendship object. type UpdateFriendshipInput struct { - CreatedAt *time.Time `json:"createdAt"` - UserID *pulid.ID `json:"userID"` - FriendID *pulid.ID `json:"friendID"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + UserID *pulid.ID `json:"userID,omitempty"` + FriendID *pulid.ID `json:"friendID,omitempty"` } // Properties by which OneToMany connections can be ordered. diff --git a/entgql/internal/todopulid/server/server.go b/entgql/internal/todopulid/server/server.go index 92e758f1b..22208d555 100644 --- a/entgql/internal/todopulid/server/server.go +++ b/entgql/internal/todopulid/server/server.go @@ -11,11 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package main import ( "context" "net/http" + "time" "entgo.io/contrib/entgql" todopulid "entgo.io/contrib/entgql/internal/todopulid" @@ -78,7 +80,11 @@ func main() { http.Handle("/query", srv) log.Info("listening on", zap.String("address", cli.Addr)) - if err := http.ListenAndServe(cli.Addr, nil); err != nil { + server := &http.Server{ + Addr: cli.Addr, + ReadHeaderTimeout: 30 * time.Second, + } + if err := server.ListenAndServe(); err != nil { log.Error("http server terminated", zap.Error(err)) } } diff --git a/entgql/internal/todopulid/todo.resolvers.go b/entgql/internal/todopulid/todo.resolvers.go index 8719eee9d..240784a6e 100644 --- a/entgql/internal/todopulid/todo.resolvers.go +++ b/entgql/internal/todopulid/todo.resolvers.go @@ -16,6 +16,7 @@ package todopulid // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" @@ -27,14 +28,17 @@ import ( "entgo.io/contrib/entgql/internal/todopulid/ent/todo" ) +// TodosCount is the resolver for the todosCount field. func (r *categoryResolver) TodosCount(ctx context.Context, obj *ent.Category) (*int, error) { panic(fmt.Errorf("not implemented")) } +// CreateCategory is the resolver for the createCategory field. func (r *mutationResolver) CreateCategory(ctx context.Context, input ent.CreateCategoryInput) (*ent.Category, error) { panic(fmt.Errorf("not implemented")) } +// CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo(ctx context.Context, input ent.CreateTodoInput) (*ent.Todo, error) { return ent.FromContext(ctx).Todo. Create(). @@ -42,10 +46,12 @@ func (r *mutationResolver) CreateTodo(ctx context.Context, input ent.CreateTodoI Save(ctx) } +// UpdateTodo is the resolver for the updateTodo field. func (r *mutationResolver) UpdateTodo(ctx context.Context, id pulid.ID, input ent.UpdateTodoInput) (*ent.Todo, error) { panic(fmt.Errorf("not implemented")) } +// ClearTodos is the resolver for the clearTodos field. func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { client := ent.FromContext(ctx) return client.Todo. @@ -53,22 +59,32 @@ func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { Exec(ctx) } +// UpdateFriendship is the resolver for the updateFriendship field. func (r *mutationResolver) UpdateFriendship(ctx context.Context, id pulid.ID, input UpdateFriendshipInput) (*ent.Friendship, error) { panic(fmt.Errorf("not implemented")) } +// Ping is the resolver for the ping field. func (r *queryResolver) Ping(ctx context.Context) (string, error) { panic(fmt.Errorf("not implemented")) } +// TodosWithJoins is the resolver for the todosWithJoins field. +func (r *queryResolver) TodosWithJoins(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { + panic(fmt.Errorf("not implemented")) +} + +// ExtendedField is the resolver for the extendedField field. func (r *todoResolver) ExtendedField(ctx context.Context, obj *ent.Todo) (*string, error) { panic(fmt.Errorf("not implemented")) } +// CreateTodos is the resolver for the createTodos field. func (r *createCategoryInputResolver) CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error { panic(fmt.Errorf("not implemented")) } +// CreatedToday is the resolver for the createdToday field. func (r *todoWhereInputResolver) CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error { if data == nil { return nil diff --git a/entgql/internal/todouuid/ent.resolvers.go b/entgql/internal/todouuid/ent.resolvers.go index 5e1f98c35..399f5ee50 100644 --- a/entgql/internal/todouuid/ent.resolvers.go +++ b/entgql/internal/todouuid/ent.resolvers.go @@ -16,32 +16,49 @@ package todo // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" "fmt" + ent1 "entgo.io/contrib/entgql/internal/todo/ent" "entgo.io/contrib/entgql/internal/todo/ent/todo" "entgo.io/contrib/entgql/internal/todouuid/ent" "github.com/google/uuid" ) +// Types is the resolver for the types field. +func (r *categoryResolver) Types(ctx context.Context, obj *ent.Category) (*CategoryTypes, error) { + panic(fmt.Errorf("not implemented")) +} + +// ID is the resolver for the id field. +func (r *organizationResolver) ID(ctx context.Context, obj *ent1.Workspace) (uuid.UUID, error) { + panic(fmt.Errorf("not implemented")) +} + +// Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id uuid.UUID) (ent.Noder, error) { return r.client.Noder(ctx, id, ent.WithFixedNodeType(todo.Table)) } +// Nodes is the resolver for the nodes field. func (r *queryResolver) Nodes(ctx context.Context, ids []uuid.UUID) ([]ent.Noder, error) { return r.client.Noders(ctx, ids, ent.WithFixedNodeType(todo.Table)) } +// BillProducts is the resolver for the billProducts field. func (r *queryResolver) BillProducts(ctx context.Context) ([]*ent.BillProduct, error) { return r.client.BillProduct.Query().All(ctx) } +// Categories is the resolver for the categories field. func (r *queryResolver) Categories(ctx context.Context, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryList, error) { panic(fmt.Errorf("not implemented")) } +// Groups is the resolver for the groups field. func (r *queryResolver) Groups(ctx context.Context, limit *int, offset *int, where *ent.GroupWhereInput) (*ent.GroupList, error) { return r.client.Group.Query(). PaginateLimitOffset(ctx, limit, offset, @@ -49,11 +66,13 @@ func (r *queryResolver) Groups(ctx context.Context, limit *int, offset *int, whe ) } +// OneToMany is the resolver for the oneToMany field. func (r *queryResolver) OneToMany(ctx context.Context, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) (*OneToManyList, error) { panic(fmt.Errorf("not implemented")) } -func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { +// Todos is the resolver for the todos field. +func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { return r.client.Todo.Query(). PaginateLimitOffset(ctx, limit, offset, ent.WithTodoOrder(orderBy), @@ -61,6 +80,7 @@ func (r *queryResolver) Todos(ctx context.Context, limit *int, offset *int, orde ) } +// Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) { return r.client.User.Query(). PaginateLimitOffset(ctx, limit, offset, @@ -68,82 +88,112 @@ func (r *queryResolver) Users(ctx context.Context, limit *int, offset *int, orde ) } +// Status is the resolver for the status field. func (r *todoResolver) Status(ctx context.Context, obj *ent.Todo) (todo.Status, error) { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *userResolver) Username(ctx context.Context, obj *ent.User) (string, error) { panic(fmt.Errorf("not implemented")) } +// Friends is the resolver for the friends field. func (r *userResolver) Friends(ctx context.Context, obj *ent.User, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) { panic(fmt.Errorf("not implemented")) } +// Friendships is the resolver for the friendships field. func (r *userResolver) Friendships(ctx context.Context, obj *ent.User, limit *int, offset *int, where *ent.FriendshipWhereInput) (*ent.FriendshipList, error) { panic(fmt.Errorf("not implemented")) } +// Types is the resolver for the types field. +func (r *createCategoryInputResolver) Types(ctx context.Context, obj *ent.CreateCategoryInput, data *CategoryTypesInput) error { + panic(fmt.Errorf("not implemented")) +} + +// Status is the resolver for the status field. func (r *createTodoInputResolver) Status(ctx context.Context, obj *ent.CreateTodoInput, data todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *createUserInputResolver) Username(ctx context.Context, obj *ent.CreateUserInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// Status is the resolver for the status field. func (r *todoWhereInputResolver) Status(ctx context.Context, obj *ent.TodoWhereInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusNeq is the resolver for the statusNEQ field. func (r *todoWhereInputResolver) StatusNeq(ctx context.Context, obj *ent.TodoWhereInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusIn is the resolver for the statusIn field. func (r *todoWhereInputResolver) StatusIn(ctx context.Context, obj *ent.TodoWhereInput, data []todo.Status) error { panic(fmt.Errorf("not implemented")) } +// StatusNotIn is the resolver for the statusNotIn field. func (r *todoWhereInputResolver) StatusNotIn(ctx context.Context, obj *ent.TodoWhereInput, data []todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Types is the resolver for the types field. +func (r *updateCategoryInputResolver) Types(ctx context.Context, obj *ent.UpdateCategoryInput, data *CategoryTypesInput) error { + panic(fmt.Errorf("not implemented")) +} + +// Status is the resolver for the status field. func (r *updateTodoInputResolver) Status(ctx context.Context, obj *ent.UpdateTodoInput, data *todo.Status) error { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *updateUserInputResolver) Username(ctx context.Context, obj *ent.UpdateUserInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// Username is the resolver for the username field. func (r *userWhereInputResolver) Username(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameNeq is the resolver for the usernameNEQ field. func (r *userWhereInputResolver) UsernameNeq(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameIn is the resolver for the usernameIn field. func (r *userWhereInputResolver) UsernameIn(ctx context.Context, obj *ent.UserWhereInput, data []string) error { panic(fmt.Errorf("not implemented")) } +// UsernameNotIn is the resolver for the usernameNotIn field. func (r *userWhereInputResolver) UsernameNotIn(ctx context.Context, obj *ent.UserWhereInput, data []string) error { panic(fmt.Errorf("not implemented")) } +// UsernameGt is the resolver for the usernameGT field. func (r *userWhereInputResolver) UsernameGt(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameGte is the resolver for the usernameGTE field. func (r *userWhereInputResolver) UsernameGte(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameLt is the resolver for the usernameLT field. func (r *userWhereInputResolver) UsernameLt(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } +// UsernameLte is the resolver for the usernameLTE field. func (r *userWhereInputResolver) UsernameLte(ctx context.Context, obj *ent.UserWhereInput, data *string) error { panic(fmt.Errorf("not implemented")) } @@ -151,6 +201,9 @@ func (r *userWhereInputResolver) UsernameLte(ctx context.Context, obj *ent.UserW // Category returns CategoryResolver implementation. func (r *Resolver) Category() CategoryResolver { return &categoryResolver{r} } +// Organization returns OrganizationResolver implementation. +func (r *Resolver) Organization() OrganizationResolver { return &organizationResolver{r} } + // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } @@ -174,6 +227,11 @@ func (r *Resolver) CreateUserInput() CreateUserInputResolver { return &createUse // TodoWhereInput returns TodoWhereInputResolver implementation. func (r *Resolver) TodoWhereInput() TodoWhereInputResolver { return &todoWhereInputResolver{r} } +// UpdateCategoryInput returns UpdateCategoryInputResolver implementation. +func (r *Resolver) UpdateCategoryInput() UpdateCategoryInputResolver { + return &updateCategoryInputResolver{r} +} + // UpdateTodoInput returns UpdateTodoInputResolver implementation. func (r *Resolver) UpdateTodoInput() UpdateTodoInputResolver { return &updateTodoInputResolver{r} } @@ -184,6 +242,7 @@ func (r *Resolver) UpdateUserInput() UpdateUserInputResolver { return &updateUse func (r *Resolver) UserWhereInput() UserWhereInputResolver { return &userWhereInputResolver{r} } type categoryResolver struct{ *Resolver } +type organizationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } type todoResolver struct{ *Resolver } type userResolver struct{ *Resolver } @@ -191,6 +250,7 @@ type createCategoryInputResolver struct{ *Resolver } type createTodoInputResolver struct{ *Resolver } type createUserInputResolver struct{ *Resolver } type todoWhereInputResolver struct{ *Resolver } +type updateCategoryInputResolver struct{ *Resolver } type updateTodoInputResolver struct{ *Resolver } type updateUserInputResolver struct{ *Resolver } type userWhereInputResolver struct{ *Resolver } diff --git a/entgql/internal/todouuid/ent/billproduct/where.go b/entgql/internal/todouuid/ent/billproduct/where.go index bcd6dab8a..7bfdeadbb 100644 --- a/entgql/internal/todouuid/ent/billproduct/where.go +++ b/entgql/internal/todouuid/ent/billproduct/where.go @@ -254,32 +254,15 @@ func QuantityLTE(v uint64) predicate.BillProduct { // And groups predicates with the AND operator between them. func And(predicates ...predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BillProduct(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BillProduct(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.BillProduct) predicate.BillProduct { - return predicate.BillProduct(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.BillProduct(sql.NotPredicates(p)) } diff --git a/entgql/internal/todouuid/ent/billproduct_create.go b/entgql/internal/todouuid/ent/billproduct_create.go index 10fd33d12..0605a357c 100644 --- a/entgql/internal/todouuid/ent/billproduct_create.go +++ b/entgql/internal/todouuid/ent/billproduct_create.go @@ -74,7 +74,7 @@ func (bpc *BillProductCreate) Mutation() *BillProductMutation { // Save creates the BillProduct in the database. func (bpc *BillProductCreate) Save(ctx context.Context) (*BillProduct, error) { bpc.defaults() - return withHooks[*BillProduct, BillProductMutation](ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) + return withHooks(ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -171,11 +171,15 @@ func (bpc *BillProductCreate) createSpec() (*BillProduct, *sqlgraph.CreateSpec) // BillProductCreateBulk is the builder for creating many BillProduct entities in bulk. type BillProductCreateBulk struct { config + err error builders []*BillProductCreate } // Save creates the BillProduct entities in the database. func (bpcb *BillProductCreateBulk) Save(ctx context.Context) ([]*BillProduct, error) { + if bpcb.err != nil { + return nil, bpcb.err + } specs := make([]*sqlgraph.CreateSpec, len(bpcb.builders)) nodes := make([]*BillProduct, len(bpcb.builders)) mutators := make([]Mutator, len(bpcb.builders)) diff --git a/entgql/internal/todouuid/ent/billproduct_delete.go b/entgql/internal/todouuid/ent/billproduct_delete.go index 8a23432ca..5fb26a5e8 100644 --- a/entgql/internal/todouuid/ent/billproduct_delete.go +++ b/entgql/internal/todouuid/ent/billproduct_delete.go @@ -41,7 +41,7 @@ func (bpd *BillProductDelete) Where(ps ...predicate.BillProduct) *BillProductDel // Exec executes the deletion query and returns how many vertices were deleted. func (bpd *BillProductDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, BillProductMutation](ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) + return withHooks(ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/billproduct_update.go b/entgql/internal/todouuid/ent/billproduct_update.go index 2522268f0..6ef33d9cc 100644 --- a/entgql/internal/todouuid/ent/billproduct_update.go +++ b/entgql/internal/todouuid/ent/billproduct_update.go @@ -47,12 +47,28 @@ func (bpu *BillProductUpdate) SetName(s string) *BillProductUpdate { return bpu } +// SetNillableName sets the "name" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableName(s *string) *BillProductUpdate { + if s != nil { + bpu.SetName(*s) + } + return bpu +} + // SetSku sets the "sku" field. func (bpu *BillProductUpdate) SetSku(s string) *BillProductUpdate { bpu.mutation.SetSku(s) return bpu } +// SetNillableSku sets the "sku" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableSku(s *string) *BillProductUpdate { + if s != nil { + bpu.SetSku(*s) + } + return bpu +} + // SetQuantity sets the "quantity" field. func (bpu *BillProductUpdate) SetQuantity(u uint64) *BillProductUpdate { bpu.mutation.ResetQuantity() @@ -60,6 +76,14 @@ func (bpu *BillProductUpdate) SetQuantity(u uint64) *BillProductUpdate { return bpu } +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (bpu *BillProductUpdate) SetNillableQuantity(u *uint64) *BillProductUpdate { + if u != nil { + bpu.SetQuantity(*u) + } + return bpu +} + // AddQuantity adds u to the "quantity" field. func (bpu *BillProductUpdate) AddQuantity(u int64) *BillProductUpdate { bpu.mutation.AddQuantity(u) @@ -73,7 +97,7 @@ func (bpu *BillProductUpdate) Mutation() *BillProductMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (bpu *BillProductUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, BillProductMutation](ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) + return withHooks(ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -145,12 +169,28 @@ func (bpuo *BillProductUpdateOne) SetName(s string) *BillProductUpdateOne { return bpuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableName(s *string) *BillProductUpdateOne { + if s != nil { + bpuo.SetName(*s) + } + return bpuo +} + // SetSku sets the "sku" field. func (bpuo *BillProductUpdateOne) SetSku(s string) *BillProductUpdateOne { bpuo.mutation.SetSku(s) return bpuo } +// SetNillableSku sets the "sku" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableSku(s *string) *BillProductUpdateOne { + if s != nil { + bpuo.SetSku(*s) + } + return bpuo +} + // SetQuantity sets the "quantity" field. func (bpuo *BillProductUpdateOne) SetQuantity(u uint64) *BillProductUpdateOne { bpuo.mutation.ResetQuantity() @@ -158,6 +198,14 @@ func (bpuo *BillProductUpdateOne) SetQuantity(u uint64) *BillProductUpdateOne { return bpuo } +// SetNillableQuantity sets the "quantity" field if the given value is not nil. +func (bpuo *BillProductUpdateOne) SetNillableQuantity(u *uint64) *BillProductUpdateOne { + if u != nil { + bpuo.SetQuantity(*u) + } + return bpuo +} + // AddQuantity adds u to the "quantity" field. func (bpuo *BillProductUpdateOne) AddQuantity(u int64) *BillProductUpdateOne { bpuo.mutation.AddQuantity(u) @@ -184,7 +232,7 @@ func (bpuo *BillProductUpdateOne) Select(field string, fields ...string) *BillPr // Save executes the query and returns the updated BillProduct entity. func (bpuo *BillProductUpdateOne) Save(ctx context.Context) (*BillProduct, error) { - return withHooks[*BillProduct, BillProductMutation](ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) + return withHooks(ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/category.go b/entgql/internal/todouuid/ent/category.go index 2d03eaffa..d00f6f9d0 100644 --- a/entgql/internal/todouuid/ent/category.go +++ b/entgql/internal/todouuid/ent/category.go @@ -40,6 +40,8 @@ type Category struct { Status category.Status `json:"status,omitempty"` // Config holds the value of the "config" field. Config *schematype.CategoryConfig `json:"config,omitempty"` + // Types holds the value of the "types" field. + Types *schematype.CategoryTypes `json:"types,omitempty"` // Duration holds the value of the "duration" field. Duration time.Duration `json:"duration,omitempty"` // Count holds the value of the "count" field. @@ -91,7 +93,7 @@ func (*Category) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case category.FieldStrings: + case category.FieldTypes, category.FieldStrings: values[i] = new([]byte) case category.FieldConfig: values[i] = new(schematype.CategoryConfig) @@ -140,6 +142,14 @@ func (c *Category) assignValues(columns []string, values []any) error { } else if value != nil { c.Config = value } + case category.FieldTypes: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field types", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &c.Types); err != nil { + return fmt.Errorf("unmarshal field types: %w", err) + } + } case category.FieldDuration: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field duration", values[i]) @@ -215,6 +225,9 @@ func (c *Category) String() string { builder.WriteString("config=") builder.WriteString(fmt.Sprintf("%v", c.Config)) builder.WriteString(", ") + builder.WriteString("types=") + builder.WriteString(fmt.Sprintf("%v", c.Types)) + builder.WriteString(", ") builder.WriteString("duration=") builder.WriteString(fmt.Sprintf("%v", c.Duration)) builder.WriteString(", ") diff --git a/entgql/internal/todouuid/ent/category/category.go b/entgql/internal/todouuid/ent/category/category.go index bf3fb90ad..87e83cd8d 100644 --- a/entgql/internal/todouuid/ent/category/category.go +++ b/entgql/internal/todouuid/ent/category/category.go @@ -37,6 +37,8 @@ const ( FieldStatus = "status" // FieldConfig holds the string denoting the config field in the database. FieldConfig = "config" + // FieldTypes holds the string denoting the types field in the database. + FieldTypes = "types" // FieldDuration holds the string denoting the duration field in the database. FieldDuration = "duration" // FieldCount holds the string denoting the count field in the database. @@ -66,6 +68,7 @@ var Columns = []string{ FieldText, FieldStatus, FieldConfig, + FieldTypes, FieldDuration, FieldCount, FieldStrings, diff --git a/entgql/internal/todouuid/ent/category/where.go b/entgql/internal/todouuid/ent/category/where.go index e4a039a25..1f3dd26dd 100644 --- a/entgql/internal/todouuid/ent/category/where.go +++ b/entgql/internal/todouuid/ent/category/where.go @@ -227,6 +227,16 @@ func ConfigNotNil() predicate.Category { return predicate.Category(sql.FieldNotNull(FieldConfig)) } +// TypesIsNil applies the IsNil predicate on the "types" field. +func TypesIsNil() predicate.Category { + return predicate.Category(sql.FieldIsNull(FieldTypes)) +} + +// TypesNotNil applies the NotNil predicate on the "types" field. +func TypesNotNil() predicate.Category { + return predicate.Category(sql.FieldNotNull(FieldTypes)) +} + // DurationEQ applies the EQ predicate on the "duration" field. func DurationEQ(v time.Duration) predicate.Category { vc := int64(v) @@ -399,32 +409,15 @@ func HasSubCategoriesWith(preds ...predicate.Category) predicate.Category { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Category(sql.NotPredicates(p)) } diff --git a/entgql/internal/todouuid/ent/category_create.go b/entgql/internal/todouuid/ent/category_create.go index 80507970b..0ff102496 100644 --- a/entgql/internal/todouuid/ent/category_create.go +++ b/entgql/internal/todouuid/ent/category_create.go @@ -55,6 +55,12 @@ func (cc *CategoryCreate) SetConfig(sc *schematype.CategoryConfig) *CategoryCrea return cc } +// SetTypes sets the "types" field. +func (cc *CategoryCreate) SetTypes(st *schematype.CategoryTypes) *CategoryCreate { + cc.mutation.SetTypes(st) + return cc +} + // SetDuration sets the "duration" field. func (cc *CategoryCreate) SetDuration(t time.Duration) *CategoryCreate { cc.mutation.SetDuration(t) @@ -141,7 +147,7 @@ func (cc *CategoryCreate) Mutation() *CategoryMutation { // Save creates the Category in the database. func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error) { cc.defaults() - return withHooks[*Category, CategoryMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) + return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -239,6 +245,10 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { _spec.SetField(category.FieldConfig, field.TypeOther, value) _node.Config = value } + if value, ok := cc.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + _node.Types = value + } if value, ok := cc.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) _node.Duration = value @@ -289,11 +299,15 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { // CategoryCreateBulk is the builder for creating many Category entities in bulk. type CategoryCreateBulk struct { config + err error builders []*CategoryCreate } // Save creates the Category entities in the database. func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error) { + if ccb.err != nil { + return nil, ccb.err + } specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) nodes := make([]*Category, len(ccb.builders)) mutators := make([]Mutator, len(ccb.builders)) diff --git a/entgql/internal/todouuid/ent/category_delete.go b/entgql/internal/todouuid/ent/category_delete.go index a7410eea7..4ab41475f 100644 --- a/entgql/internal/todouuid/ent/category_delete.go +++ b/entgql/internal/todouuid/ent/category_delete.go @@ -41,7 +41,7 @@ func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (cd *CategoryDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) + return withHooks(ctx, cd.sqlExec, cd.mutation, cd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/category_update.go b/entgql/internal/todouuid/ent/category_update.go index e10e5ad6b..62c4768e1 100644 --- a/entgql/internal/todouuid/ent/category_update.go +++ b/entgql/internal/todouuid/ent/category_update.go @@ -52,12 +52,28 @@ func (cu *CategoryUpdate) SetText(s string) *CategoryUpdate { return cu } +// SetNillableText sets the "text" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableText(s *string) *CategoryUpdate { + if s != nil { + cu.SetText(*s) + } + return cu +} + // SetStatus sets the "status" field. func (cu *CategoryUpdate) SetStatus(c category.Status) *CategoryUpdate { cu.mutation.SetStatus(c) return cu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableStatus(c *category.Status) *CategoryUpdate { + if c != nil { + cu.SetStatus(*c) + } + return cu +} + // SetConfig sets the "config" field. func (cu *CategoryUpdate) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdate { cu.mutation.SetConfig(sc) @@ -70,6 +86,18 @@ func (cu *CategoryUpdate) ClearConfig() *CategoryUpdate { return cu } +// SetTypes sets the "types" field. +func (cu *CategoryUpdate) SetTypes(st *schematype.CategoryTypes) *CategoryUpdate { + cu.mutation.SetTypes(st) + return cu +} + +// ClearTypes clears the value of the "types" field. +func (cu *CategoryUpdate) ClearTypes() *CategoryUpdate { + cu.mutation.ClearTypes() + return cu +} + // SetDuration sets the "duration" field. func (cu *CategoryUpdate) SetDuration(t time.Duration) *CategoryUpdate { cu.mutation.ResetDuration() @@ -221,7 +249,7 @@ func (cu *CategoryUpdate) RemoveSubCategories(c ...*Category) *CategoryUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) + return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -285,6 +313,12 @@ func (cu *CategoryUpdate) sqlSave(ctx context.Context) (n int, err error) { if cu.mutation.ConfigCleared() { _spec.ClearField(category.FieldConfig, field.TypeOther) } + if value, ok := cu.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + } + if cu.mutation.TypesCleared() { + _spec.ClearField(category.FieldTypes, field.TypeJSON) + } if value, ok := cu.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) } @@ -430,12 +464,28 @@ func (cuo *CategoryUpdateOne) SetText(s string) *CategoryUpdateOne { return cuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableText(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetText(*s) + } + return cuo +} + // SetStatus sets the "status" field. func (cuo *CategoryUpdateOne) SetStatus(c category.Status) *CategoryUpdateOne { cuo.mutation.SetStatus(c) return cuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableStatus(c *category.Status) *CategoryUpdateOne { + if c != nil { + cuo.SetStatus(*c) + } + return cuo +} + // SetConfig sets the "config" field. func (cuo *CategoryUpdateOne) SetConfig(sc *schematype.CategoryConfig) *CategoryUpdateOne { cuo.mutation.SetConfig(sc) @@ -448,6 +498,18 @@ func (cuo *CategoryUpdateOne) ClearConfig() *CategoryUpdateOne { return cuo } +// SetTypes sets the "types" field. +func (cuo *CategoryUpdateOne) SetTypes(st *schematype.CategoryTypes) *CategoryUpdateOne { + cuo.mutation.SetTypes(st) + return cuo +} + +// ClearTypes clears the value of the "types" field. +func (cuo *CategoryUpdateOne) ClearTypes() *CategoryUpdateOne { + cuo.mutation.ClearTypes() + return cuo +} + // SetDuration sets the "duration" field. func (cuo *CategoryUpdateOne) SetDuration(t time.Duration) *CategoryUpdateOne { cuo.mutation.ResetDuration() @@ -612,7 +674,7 @@ func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUp // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) + return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -693,6 +755,12 @@ func (cuo *CategoryUpdateOne) sqlSave(ctx context.Context) (_node *Category, err if cuo.mutation.ConfigCleared() { _spec.ClearField(category.FieldConfig, field.TypeOther) } + if value, ok := cuo.mutation.Types(); ok { + _spec.SetField(category.FieldTypes, field.TypeJSON, value) + } + if cuo.mutation.TypesCleared() { + _spec.ClearField(category.FieldTypes, field.TypeJSON) + } if value, ok := cuo.mutation.Duration(); ok { _spec.SetField(category.FieldDuration, field.TypeInt64, value) } diff --git a/entgql/internal/todouuid/ent/client.go b/entgql/internal/todouuid/ent/client.go index 9efdeeca9..ac019c9b1 100644 --- a/entgql/internal/todouuid/ent/client.go +++ b/entgql/internal/todouuid/ent/client.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entgql/internal/todouuid/ent/migrate" "entgo.io/ent" @@ -61,9 +62,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -97,6 +96,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -144,11 +150,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -292,6 +301,21 @@ func (c *BillProductClient) CreateBulk(builders ...*BillProductCreate) *BillProd return &BillProductCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BillProductClient) MapCreateBulk(slice any, setFunc func(*BillProductCreate, int)) *BillProductCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BillProductCreateBulk{err: fmt.Errorf("calling to BillProductClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BillProductCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BillProductCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for BillProduct. func (c *BillProductClient) Update() *BillProductUpdate { mutation := newBillProductMutation(c.config, OpUpdate) @@ -410,6 +434,21 @@ func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreate return &CategoryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CategoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CategoryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Category. func (c *CategoryClient) Update() *CategoryUpdate { mutation := newCategoryMutation(c.config, OpUpdate) @@ -560,6 +599,21 @@ func (c *FriendshipClient) CreateBulk(builders ...*FriendshipCreate) *Friendship return &FriendshipCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *FriendshipClient) MapCreateBulk(slice any, setFunc func(*FriendshipCreate, int)) *FriendshipCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &FriendshipCreateBulk{err: fmt.Errorf("calling to FriendshipClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*FriendshipCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &FriendshipCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Friendship. func (c *FriendshipClient) Update() *FriendshipUpdate { mutation := newFriendshipMutation(c.config, OpUpdate) @@ -710,6 +764,21 @@ func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk { return &GroupCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GroupCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GroupCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Group. func (c *GroupClient) Update() *GroupUpdate { mutation := newGroupMutation(c.config, OpUpdate) @@ -844,6 +913,21 @@ func (c *TodoClient) CreateBulk(builders ...*TodoCreate) *TodoCreateBulk { return &TodoCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TodoClient) MapCreateBulk(slice any, setFunc func(*TodoCreate, int)) *TodoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TodoCreateBulk{err: fmt.Errorf("calling to TodoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TodoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TodoCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Todo. func (c *TodoClient) Update() *TodoUpdate { mutation := newTodoMutation(c.config, OpUpdate) @@ -1026,6 +1110,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) @@ -1192,6 +1291,21 @@ func (c *VerySecretClient) CreateBulk(builders ...*VerySecretCreate) *VerySecret return &VerySecretCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *VerySecretClient) MapCreateBulk(slice any, setFunc func(*VerySecretCreate, int)) *VerySecretCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &VerySecretCreateBulk{err: fmt.Errorf("calling to VerySecretClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*VerySecretCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &VerySecretCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for VerySecret. func (c *VerySecretClient) Update() *VerySecretUpdate { mutation := newVerySecretMutation(c.config, OpUpdate) diff --git a/entgql/internal/todouuid/ent/friendship/where.go b/entgql/internal/todouuid/ent/friendship/where.go index 923cf1f77..0d9cc3f83 100644 --- a/entgql/internal/todouuid/ent/friendship/where.go +++ b/entgql/internal/todouuid/ent/friendship/where.go @@ -213,32 +213,15 @@ func HasFriendWith(preds ...predicate.User) predicate.Friendship { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Friendship(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Friendship(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Friendship) predicate.Friendship { - return predicate.Friendship(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Friendship(sql.NotPredicates(p)) } diff --git a/entgql/internal/todouuid/ent/friendship_create.go b/entgql/internal/todouuid/ent/friendship_create.go index 18dac8b8e..01a2fc5de 100644 --- a/entgql/internal/todouuid/ent/friendship_create.go +++ b/entgql/internal/todouuid/ent/friendship_create.go @@ -94,7 +94,7 @@ func (fc *FriendshipCreate) Mutation() *FriendshipMutation { // Save creates the Friendship in the database. func (fc *FriendshipCreate) Save(ctx context.Context) (*Friendship, error) { fc.defaults() - return withHooks[*Friendship, FriendshipMutation](ctx, fc.sqlSave, fc.mutation, fc.hooks) + return withHooks(ctx, fc.sqlSave, fc.mutation, fc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -227,11 +227,15 @@ func (fc *FriendshipCreate) createSpec() (*Friendship, *sqlgraph.CreateSpec) { // FriendshipCreateBulk is the builder for creating many Friendship entities in bulk. type FriendshipCreateBulk struct { config + err error builders []*FriendshipCreate } // Save creates the Friendship entities in the database. func (fcb *FriendshipCreateBulk) Save(ctx context.Context) ([]*Friendship, error) { + if fcb.err != nil { + return nil, fcb.err + } specs := make([]*sqlgraph.CreateSpec, len(fcb.builders)) nodes := make([]*Friendship, len(fcb.builders)) mutators := make([]Mutator, len(fcb.builders)) diff --git a/entgql/internal/todouuid/ent/friendship_delete.go b/entgql/internal/todouuid/ent/friendship_delete.go index acad745c3..e720bc5c0 100644 --- a/entgql/internal/todouuid/ent/friendship_delete.go +++ b/entgql/internal/todouuid/ent/friendship_delete.go @@ -41,7 +41,7 @@ func (fd *FriendshipDelete) Where(ps ...predicate.Friendship) *FriendshipDelete // Exec executes the deletion query and returns how many vertices were deleted. func (fd *FriendshipDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, FriendshipMutation](ctx, fd.sqlExec, fd.mutation, fd.hooks) + return withHooks(ctx, fd.sqlExec, fd.mutation, fd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/friendship_update.go b/entgql/internal/todouuid/ent/friendship_update.go index 8818d5023..a6c6b4734 100644 --- a/entgql/internal/todouuid/ent/friendship_update.go +++ b/entgql/internal/todouuid/ent/friendship_update.go @@ -64,12 +64,28 @@ func (fu *FriendshipUpdate) SetUserID(u uuid.UUID) *FriendshipUpdate { return fu } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (fu *FriendshipUpdate) SetNillableUserID(u *uuid.UUID) *FriendshipUpdate { + if u != nil { + fu.SetUserID(*u) + } + return fu +} + // SetFriendID sets the "friend_id" field. func (fu *FriendshipUpdate) SetFriendID(u uuid.UUID) *FriendshipUpdate { fu.mutation.SetFriendID(u) return fu } +// SetNillableFriendID sets the "friend_id" field if the given value is not nil. +func (fu *FriendshipUpdate) SetNillableFriendID(u *uuid.UUID) *FriendshipUpdate { + if u != nil { + fu.SetFriendID(*u) + } + return fu +} + // SetUser sets the "user" edge to the User entity. func (fu *FriendshipUpdate) SetUser(u *User) *FriendshipUpdate { return fu.SetUserID(u.ID) @@ -99,7 +115,7 @@ func (fu *FriendshipUpdate) ClearFriend() *FriendshipUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (fu *FriendshipUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, FriendshipMutation](ctx, fu.sqlSave, fu.mutation, fu.hooks) + return withHooks(ctx, fu.sqlSave, fu.mutation, fu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -248,12 +264,28 @@ func (fuo *FriendshipUpdateOne) SetUserID(u uuid.UUID) *FriendshipUpdateOne { return fuo } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (fuo *FriendshipUpdateOne) SetNillableUserID(u *uuid.UUID) *FriendshipUpdateOne { + if u != nil { + fuo.SetUserID(*u) + } + return fuo +} + // SetFriendID sets the "friend_id" field. func (fuo *FriendshipUpdateOne) SetFriendID(u uuid.UUID) *FriendshipUpdateOne { fuo.mutation.SetFriendID(u) return fuo } +// SetNillableFriendID sets the "friend_id" field if the given value is not nil. +func (fuo *FriendshipUpdateOne) SetNillableFriendID(u *uuid.UUID) *FriendshipUpdateOne { + if u != nil { + fuo.SetFriendID(*u) + } + return fuo +} + // SetUser sets the "user" edge to the User entity. func (fuo *FriendshipUpdateOne) SetUser(u *User) *FriendshipUpdateOne { return fuo.SetUserID(u.ID) @@ -296,7 +328,7 @@ func (fuo *FriendshipUpdateOne) Select(field string, fields ...string) *Friendsh // Save executes the query and returns the updated Friendship entity. func (fuo *FriendshipUpdateOne) Save(ctx context.Context) (*Friendship, error) { - return withHooks[*Friendship, FriendshipMutation](ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) + return withHooks(ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/gql_collection.go b/entgql/internal/todouuid/ent/gql_collection.go index 63e8486fa..900932651 100644 --- a/entgql/internal/todouuid/ent/gql_collection.go +++ b/entgql/internal/todouuid/ent/gql_collection.go @@ -39,13 +39,13 @@ func (bp *BillProductQuery) CollectFields(ctx context.Context, satisfies ...stri if fc == nil { return bp, nil } - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := bp.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return bp, nil } -func (bp *BillProductQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (bp *BillProductQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -86,7 +86,7 @@ type billproductPaginateArgs struct { opts []BillProductPaginateOption } -func newBillProductPaginateArgs(rv map[string]interface{}) *billproductPaginateArgs { +func newBillProductPaginateArgs(rv map[string]any) *billproductPaginateArgs { args := &billproductPaginateArgs{} if rv == nil { return args @@ -109,13 +109,13 @@ func (c *CategoryQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return c, nil } - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := c.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return c, nil } -func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (c *CategoryQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -124,6 +124,7 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "todos": var ( alias = field.Alias @@ -192,25 +193,30 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(category.TodosColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(category.TodosColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } c.WithNamedTodos(alias, func(wq *TodoQuery) { *wq = *query }) + case "subCategories": var ( alias = field.Alias @@ -283,19 +289,23 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Category")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Category"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Category")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Category"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(category.SubCategoriesPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(category.SubCategoriesPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -317,6 +327,11 @@ func (c *CategoryQuery) collectField(ctx context.Context, opCtx *graphql.Operati selectedFields = append(selectedFields, category.FieldConfig) fieldSeen[category.FieldConfig] = struct{}{} } + case "types": + if _, ok := fieldSeen[category.FieldTypes]; !ok { + selectedFields = append(selectedFields, category.FieldTypes) + fieldSeen[category.FieldTypes] = struct{}{} + } case "duration": if _, ok := fieldSeen[category.FieldDuration]; !ok { selectedFields = append(selectedFields, category.FieldDuration) @@ -349,7 +364,7 @@ type categoryPaginateArgs struct { opts []CategoryPaginateOption } -func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { +func newCategoryPaginateArgs(rv map[string]any) *categoryPaginateArgs { args := &categoryPaginateArgs{} if rv == nil { return args @@ -364,10 +379,10 @@ func newCategoryPaginateArgs(rv map[string]interface{}) *categoryPaginateArgs { switch v := v.(type) { case []*CategoryOrder: args.opts = append(args.opts, WithCategoryOrder(v)) - case []interface{}: + case []any: var orders []*CategoryOrder for i := range v { - mv, ok := v[i].(map[string]interface{}) + mv, ok := v[i].(map[string]any) if !ok { continue } @@ -400,13 +415,13 @@ func (f *FriendshipQuery) CollectFields(ctx context.Context, satisfies ...string if fc == nil { return f, nil } - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := f.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return f, nil } -func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (f *FriendshipQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -415,13 +430,14 @@ func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "user": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: f.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } f.withUser = query @@ -429,13 +445,14 @@ func (f *FriendshipQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, friendship.FieldUserID) fieldSeen[friendship.FieldUserID] = struct{}{} } + case "friend": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: f.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } f.withFriend = query @@ -475,7 +492,7 @@ type friendshipPaginateArgs struct { opts []FriendshipPaginateOption } -func newFriendshipPaginateArgs(rv map[string]interface{}) *friendshipPaginateArgs { +func newFriendshipPaginateArgs(rv map[string]any) *friendshipPaginateArgs { args := &friendshipPaginateArgs{} if rv == nil { return args @@ -498,13 +515,13 @@ func (gr *GroupQuery) CollectFields(ctx context.Context, satisfies ...string) (* if fc == nil { return gr, nil } - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := gr.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return gr, nil } -func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (gr *GroupQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -513,6 +530,7 @@ func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.Operation ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "users": var ( alias = field.Alias @@ -585,19 +603,23 @@ func (gr *GroupQuery) collectField(ctx context.Context, opCtx *graphql.Operation } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "User")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"User"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(group.UsersPrimaryKey[1], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(group.UsersPrimaryKey[1], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } @@ -626,7 +648,7 @@ type groupPaginateArgs struct { opts []GroupPaginateOption } -func newGroupPaginateArgs(rv map[string]interface{}) *groupPaginateArgs { +func newGroupPaginateArgs(rv map[string]any) *groupPaginateArgs { args := &groupPaginateArgs{} if rv == nil { return args @@ -649,13 +671,13 @@ func (t *TodoQuery) CollectFields(ctx context.Context, satisfies ...string) (*To if fc == nil { return t, nil } - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := t.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return t, nil } -func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (t *TodoQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -664,16 +686,18 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "parent": var ( alias = field.Alias path = append(path, alias) query = (&TodoClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, todoImplementors)...); err != nil { return err } t.withParent = query + case "children": var ( alias = field.Alias @@ -742,32 +766,37 @@ func (t *TodoQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Todo")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Todo"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(todo.ChildrenColumn, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(todo.ChildrenColumn, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } t.WithNamedChildren(alias, func(wq *TodoQuery) { *wq = *query }) + case "category": var ( alias = field.Alias path = append(path, alias) query = (&CategoryClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, categoryImplementors)...); err != nil { return err } t.withCategory = query @@ -832,7 +861,7 @@ type todoPaginateArgs struct { opts []TodoPaginateOption } -func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { +func newTodoPaginateArgs(rv map[string]any) *todoPaginateArgs { args := &todoPaginateArgs{} if rv == nil { return args @@ -845,24 +874,30 @@ func newTodoPaginateArgs(rv map[string]interface{}) *todoPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: - var ( - err1, err2 error - order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithTodoOrder(order)) - } - case *TodoOrder: - if v != nil { - args.opts = append(args.opts, WithTodoOrder(v)) + case []*TodoOrder: + args.opts = append(args.opts, WithTodoOrder(v)) + case []any: + var orders []*TodoOrder + for i := range v { + mv, ok := v[i].(map[string]any) + if !ok { + continue + } + var ( + err1, err2 error + order = &TodoOrder{Field: &TodoOrderField{}, Direction: entgql.OrderDirectionAsc} + ) + if d, ok := mv[directionField]; ok { + err1 = order.Direction.UnmarshalGQL(d) + } + if f, ok := mv[fieldField]; ok { + err2 = order.Field.UnmarshalGQL(f) + } + if err1 == nil && err2 == nil { + orders = append(orders, order) + } } + args.opts = append(args.opts, WithTodoOrder(orders)) } } if v, ok := rv[whereField].(*TodoWhereInput); ok { @@ -877,13 +912,13 @@ func (u *UserQuery) CollectFields(ctx context.Context, satisfies ...string) (*Us if fc == nil { return u, nil } - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := u.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return u, nil } -func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (u *UserQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -892,6 +927,7 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "groups": var ( alias = field.Alias @@ -964,44 +1000,50 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "Group")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"Group"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "Group")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"Group"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - modify := limitRows(user.GroupsPrimaryKey[0], *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + modify := entgql.LimitPerRow(user.GroupsPrimaryKey[0], *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } u.WithNamedGroups(alias, func(wq *GroupQuery) { *wq = *query }) + case "friends": var ( alias = field.Alias path = append(path, alias) query = (&UserClient{config: u.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, userImplementors)...); err != nil { return err } u.WithNamedFriends(alias, func(wq *UserQuery) { *wq = *query }) + case "friendships": var ( alias = field.Alias path = append(path, alias) query = (&FriendshipClient{config: u.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, friendshipImplementors)...); err != nil { return err } u.WithNamedFriendships(alias, func(wq *FriendshipQuery) { @@ -1017,6 +1059,11 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo selectedFields = append(selectedFields, user.FieldUsername) fieldSeen[user.FieldUsername] = struct{}{} } + case "requiredMetadata": + if _, ok := fieldSeen[user.FieldRequiredMetadata]; !ok { + selectedFields = append(selectedFields, user.FieldRequiredMetadata) + fieldSeen[user.FieldRequiredMetadata] = struct{}{} + } case "metadata": if _, ok := fieldSeen[user.FieldMetadata]; !ok { selectedFields = append(selectedFields, user.FieldMetadata) @@ -1039,7 +1086,7 @@ type userPaginateArgs struct { opts []UserPaginateOption } -func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { +func newUserPaginateArgs(rv map[string]any) *userPaginateArgs { args := &userPaginateArgs{} if rv == nil { return args @@ -1052,7 +1099,7 @@ func newUserPaginateArgs(rv map[string]interface{}) *userPaginateArgs { } if v, ok := rv[orderByField]; ok { switch v := v.(type) { - case map[string]interface{}: + case map[string]any: var ( err1, err2 error order = &UserOrder{Field: &UserOrderField{}, Direction: entgql.OrderDirectionAsc} @@ -1087,35 +1134,18 @@ const ( whereField = "where" ) -func fieldArgs(ctx context.Context, whereInput interface{}, path ...string) map[string]interface{} { - fc := graphql.GetFieldContext(ctx) - if fc == nil { +func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { + field := collectedField(ctx, path...) + if field == nil || field.Arguments == nil { return nil } oc := graphql.GetOperationContext(ctx) - for _, name := range path { - var field *graphql.CollectedField - for _, f := range graphql.CollectFields(oc, fc.Field.Selections, nil) { - if f.Alias == name { - field = &f - break - } - } - if field == nil { - return nil - } - cf, err := fc.Child(ctx, *field) - if err != nil { - args := field.ArgumentMap(oc.Variables) - return unmarshalArgs(ctx, whereInput, args) - } - fc = cf - } - return fc.Args + args := field.ArgumentMap(oc.Variables) + return unmarshalArgs(ctx, whereInput, args) } // unmarshalArgs allows extracting the field arguments from their raw representation. -func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string]interface{}) map[string]interface{} { +func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{limitField, offsetField} { v, ok := args[k] if !ok { @@ -1135,39 +1165,17 @@ func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string] return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } diff --git a/entgql/internal/todouuid/ent/gql_edge.go b/entgql/internal/todouuid/ent/gql_edge.go index c53f3aa9c..8bd234169 100644 --- a/entgql/internal/todouuid/ent/gql_edge.go +++ b/entgql/internal/todouuid/ent/gql_edge.go @@ -23,7 +23,7 @@ import ( ) func (c *Category) Todos( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), @@ -110,7 +110,7 @@ func (t *Todo) Parent(ctx context.Context) (*Todo, error) { } func (t *Todo) Children( - ctx context.Context, limit *int, offset *int, orderBy *TodoOrder, where *TodoWhereInput, + ctx context.Context, limit *int, offset *int, orderBy []*TodoOrder, where *TodoWhereInput, ) (*TodoList, error) { opts := []TodoPaginateOption{ WithTodoOrder(orderBy), diff --git a/entgql/internal/todouuid/ent/gql_mutation_input.go b/entgql/internal/todouuid/ent/gql_mutation_input.go index b3bbe31c6..552752b40 100644 --- a/entgql/internal/todouuid/ent/gql_mutation_input.go +++ b/entgql/internal/todouuid/ent/gql_mutation_input.go @@ -30,6 +30,7 @@ type CreateCategoryInput struct { Text string Status category.Status Config *schematype.CategoryConfig + Types *schematype.CategoryTypes Duration *time.Duration Count *uint64 Strings []string @@ -44,6 +45,9 @@ func (i *CreateCategoryInput) Mutate(m *CategoryMutation) { if v := i.Config; v != nil { m.SetConfig(v) } + if v := i.Types; v != nil { + m.SetTypes(v) + } if v := i.Duration; v != nil { m.SetDuration(*v) } @@ -73,6 +77,8 @@ type UpdateCategoryInput struct { Status *category.Status ClearConfig bool Config *schematype.CategoryConfig + ClearTypes bool + Types *schematype.CategoryTypes ClearDuration bool Duration *time.Duration ClearCount bool @@ -102,6 +108,12 @@ func (i *UpdateCategoryInput) Mutate(m *CategoryMutation) { if v := i.Config; v != nil { m.SetConfig(v) } + if i.ClearTypes { + m.ClearTypes() + } + if v := i.Types; v != nil { + m.SetTypes(v) + } if i.ClearDuration { m.ClearDuration() } @@ -267,12 +279,13 @@ func (c *TodoUpdateOne) SetInput(i UpdateTodoInput) *TodoUpdateOne { // CreateUserInput represents a mutation input for creating users. type CreateUserInput struct { - Name *string - Username *uuid.UUID - Password *string - Metadata map[string]interface{} - GroupIDs []uuid.UUID - FriendIDs []uuid.UUID + Name *string + Username *uuid.UUID + Password *string + RequiredMetadata map[string]interface{} + Metadata map[string]interface{} + GroupIDs []uuid.UUID + FriendIDs []uuid.UUID } // Mutate applies the CreateUserInput on the UserMutation builder. @@ -286,6 +299,9 @@ func (i *CreateUserInput) Mutate(m *UserMutation) { if v := i.Password; v != nil { m.SetPassword(*v) } + if v := i.RequiredMetadata; v != nil { + m.SetRequiredMetadata(v) + } if v := i.Metadata; v != nil { m.SetMetadata(v) } @@ -305,18 +321,19 @@ func (c *UserCreate) SetInput(i CreateUserInput) *UserCreate { // UpdateUserInput represents a mutation input for updating users. type UpdateUserInput struct { - Name *string - Username *uuid.UUID - ClearPassword bool - Password *string - ClearMetadata bool - Metadata map[string]interface{} - ClearGroups bool - AddGroupIDs []uuid.UUID - RemoveGroupIDs []uuid.UUID - ClearFriends bool - AddFriendIDs []uuid.UUID - RemoveFriendIDs []uuid.UUID + Name *string + Username *uuid.UUID + ClearPassword bool + Password *string + RequiredMetadata map[string]interface{} + ClearMetadata bool + Metadata map[string]interface{} + ClearGroups bool + AddGroupIDs []uuid.UUID + RemoveGroupIDs []uuid.UUID + ClearFriends bool + AddFriendIDs []uuid.UUID + RemoveFriendIDs []uuid.UUID } // Mutate applies the UpdateUserInput on the UserMutation builder. @@ -333,6 +350,9 @@ func (i *UpdateUserInput) Mutate(m *UserMutation) { if v := i.Password; v != nil { m.SetPassword(*v) } + if v := i.RequiredMetadata; v != nil { + m.SetRequiredMetadata(v) + } if i.ClearMetadata { m.ClearMetadata() } diff --git a/entgql/internal/todouuid/ent/gql_node.go b/entgql/internal/todouuid/ent/gql_node.go index b3bc13a05..e7badafe5 100644 --- a/entgql/internal/todouuid/ent/gql_node.go +++ b/entgql/internal/todouuid/ent/gql_node.go @@ -37,23 +37,38 @@ type Noder interface { IsNode() } +var billproductImplementors = []string{"BillProduct", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *BillProduct) IsNode() {} +func (*BillProduct) IsNode() {} + +var categoryImplementors = []string{"Category", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Category) IsNode() {} +func (*Category) IsNode() {} + +var friendshipImplementors = []string{"Friendship", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Friendship) IsNode() {} +func (*Friendship) IsNode() {} + +var groupImplementors = []string{"Group", "Node", "NamedNode"} // IsNode implements the Node interface check for GQLGen. -func (n *Group) IsNode() {} +func (*Group) IsNode() {} + +// IsNamedNode implements the NamedNode interface check for GQLGen. +func (*Group) IsNamedNode() {} + +var todoImplementors = []string{"Todo", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Todo) IsNode() {} +func (*Todo) IsNode() {} + +var userImplementors = []string{"User", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *User) IsNode() {} +func (*User) IsNode() {} var errNodeInvalidID = &NotFoundError{"node"} @@ -116,75 +131,57 @@ func (c *Client) noder(ctx context.Context, table string, id uuid.UUID) (Noder, case billproduct.Table: query := c.BillProduct.Query(). Where(billproduct.ID(id)) - query, err := query.CollectFields(ctx, "BillProduct") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, billproductImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case category.Table: query := c.Category.Query(). Where(category.ID(id)) - query, err := query.CollectFields(ctx, "Category") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, categoryImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case friendship.Table: query := c.Friendship.Query(). Where(friendship.ID(id)) - query, err := query.CollectFields(ctx, "Friendship") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, friendshipImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case group.Table: query := c.Group.Query(). Where(group.ID(id)) - query, err := query.CollectFields(ctx, "Group") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, groupImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case todo.Table: query := c.Todo.Query(). Where(todo.ID(id)) - query, err := query.CollectFields(ctx, "Todo") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, todoImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case user.Table: query := c.User.Query(). Where(user.ID(id)) - query, err := query.CollectFields(ctx, "User") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, userImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) } @@ -261,7 +258,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case billproduct.Table: query := c.BillProduct.Query(). Where(billproduct.IDIn(ids...)) - query, err := query.CollectFields(ctx, "BillProduct") + query, err := query.CollectFields(ctx, billproductImplementors...) if err != nil { return nil, err } @@ -277,7 +274,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case category.Table: query := c.Category.Query(). Where(category.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Category") + query, err := query.CollectFields(ctx, categoryImplementors...) if err != nil { return nil, err } @@ -293,7 +290,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case friendship.Table: query := c.Friendship.Query(). Where(friendship.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Friendship") + query, err := query.CollectFields(ctx, friendshipImplementors...) if err != nil { return nil, err } @@ -309,7 +306,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case group.Table: query := c.Group.Query(). Where(group.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Group") + query, err := query.CollectFields(ctx, groupImplementors...) if err != nil { return nil, err } @@ -325,7 +322,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case todo.Table: query := c.Todo.Query(). Where(todo.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Todo") + query, err := query.CollectFields(ctx, todoImplementors...) if err != nil { return nil, err } @@ -341,7 +338,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case user.Table: query := c.User.Query(). Where(user.IDIn(ids...)) - query, err := query.CollectFields(ctx, "User") + query, err := query.CollectFields(ctx, userImplementors...) if err != nil { return nil, err } diff --git a/entgql/internal/todouuid/ent/gql_pagination.go b/entgql/internal/todouuid/ent/gql_pagination.go index 07092faee..b3b59da84 100644 --- a/entgql/internal/todouuid/ent/gql_pagination.go +++ b/entgql/internal/todouuid/ent/gql_pagination.go @@ -337,12 +337,12 @@ func (bp *BillProductQuery) PaginateLimitOffset( bp.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bp.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := bp.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -375,7 +375,9 @@ func (bp *BillProductQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = bp.Clone().Count(ctx); err != nil { + c := bp.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -388,16 +390,17 @@ func (bp *BillProductQuery) Paginate( if bp, err = pager.applyCursors(bp, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { bp.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := bp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -571,11 +574,11 @@ func (p *categoryPager) applyFilter(query *CategoryQuery) (*CategoryQuery, error } func (p *categoryPager) toCursor(c *Category) Cursor { - cs := make([]any, 0, len(p.order)) - for _, o := range p.order { - cs = append(cs, o.Field.toCursor(c).Value) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(c).Value) } - return Cursor{ID: c.ID, Value: cs} + return Cursor{ID: c.ID, Value: cs_} } func (p *categoryPager) applyCursors(query *CategoryQuery, after, before *Cursor) (*CategoryQuery, error) { @@ -702,12 +705,12 @@ func (c *CategoryQuery) PaginateLimitOffset( c.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -740,7 +743,9 @@ func (c *CategoryQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = c.Clone().Count(ctx); err != nil { + c := c.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -753,16 +758,17 @@ func (c *CategoryQuery) Paginate( if c, err = pager.applyCursors(c, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { c.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -790,6 +796,20 @@ var ( } }, } + // CategoryOrderFieldStatus orders Category by status. + CategoryOrderFieldStatus = &CategoryOrderField{ + Value: func(c *Category) (ent.Value, error) { + return c.Status, nil + }, + column: category.FieldStatus, + toTerm: category.ByStatus, + toCursor: func(c *Category) Cursor { + return Cursor{ + ID: c.ID, + Value: c.Status, + } + }, + } // CategoryOrderFieldDuration orders Category by duration. CategoryOrderFieldDuration = &CategoryOrderField{ Value: func(c *Category) (ent.Value, error) { @@ -845,6 +865,8 @@ func (f CategoryOrderField) String() string { switch f.column { case CategoryOrderFieldText.column: str = "TEXT" + case CategoryOrderFieldStatus.column: + str = "STATUS" case CategoryOrderFieldDuration.column: str = "DURATION" case CategoryOrderFieldCount.column: @@ -869,6 +891,8 @@ func (f *CategoryOrderField) UnmarshalGQL(v interface{}) error { switch str { case "TEXT": *f = *CategoryOrderFieldText + case "STATUS": + *f = *CategoryOrderFieldStatus case "DURATION": *f = *CategoryOrderFieldDuration case "COUNT": @@ -1124,12 +1148,12 @@ func (f *FriendshipQuery) PaginateLimitOffset( f.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := f.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1162,7 +1186,9 @@ func (f *FriendshipQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = f.Clone().Count(ctx); err != nil { + c := f.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1175,16 +1201,17 @@ func (f *FriendshipQuery) Paginate( if f, err = pager.applyCursors(f, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { f.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := f.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1358,11 +1385,11 @@ func (p *groupPager) applyFilter(query *GroupQuery) (*GroupQuery, error) { } func (p *groupPager) toCursor(gr *Group) Cursor { - cs := make([]any, 0, len(p.order)) - for _, o := range p.order { - cs = append(cs, o.Field.toCursor(gr).Value) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(gr).Value) } - return Cursor{ID: gr.ID, Value: cs} + return Cursor{ID: gr.ID, Value: cs_} } func (p *groupPager) applyCursors(query *GroupQuery, after, before *Cursor) (*GroupQuery, error) { @@ -1476,12 +1503,12 @@ func (gr *GroupQuery) PaginateLimitOffset( gr.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := gr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := gr.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1514,7 +1541,9 @@ func (gr *GroupQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = gr.Clone().Count(ctx); err != nil { + c := gr.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1527,16 +1556,17 @@ func (gr *GroupQuery) Paginate( if gr, err = pager.applyCursors(gr, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { gr.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := gr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1658,19 +1688,14 @@ func (c *TodoList) build(nodes []*Todo, pager *todoPager, after *Cursor, first * type TodoPaginateOption func(*todoPager) error // WithTodoOrder configures pagination ordering. -func WithTodoOrder(order *TodoOrder) TodoPaginateOption { - if order == nil { - order = DefaultTodoOrder - } - o := *order +func WithTodoOrder(order []*TodoOrder) TodoPaginateOption { return func(pager *todoPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultTodoOrder.Field + for _, o := range order { + if err := o.Direction.Validate(); err != nil { + return err + } } - pager.order = &o + pager.order = append(pager.order, order...) return nil } } @@ -1688,7 +1713,7 @@ func WithTodoFilter(filter func(*TodoQuery) (*TodoQuery, error)) TodoPaginateOpt type todoPager struct { reverse bool - order *TodoOrder + order []*TodoOrder filter func(*TodoQuery) (*TodoQuery, error) } @@ -1699,8 +1724,10 @@ func newTodoPager(opts []TodoPaginateOption, reverse bool) (*todoPager, error) { return nil, err } } - if pager.order == nil { - pager.order = DefaultTodoOrder + for i, o := range pager.order { + if i > 0 && o.Field == pager.order[i-1].Field { + return nil, fmt.Errorf("duplicate order direction %q", o.Direction) + } } return pager, nil } @@ -1713,57 +1740,100 @@ func (p *todoPager) applyFilter(query *TodoQuery) (*TodoQuery, error) { } func (p *todoPager) toCursor(t *Todo) Cursor { - return p.order.Field.toCursor(t) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor(t).Value) + } + return Cursor{ID: t.ID, Value: cs_} } func (p *todoPager) applyCursors(query *TodoQuery, after, before *Cursor) (*TodoQuery, error) { - direction := p.order.Direction + idDirection := entgql.OrderDirectionAsc if p.reverse { - direction = direction.Reverse() + idDirection = entgql.OrderDirectionDesc + } + fields, directions := make([]string, 0, len(p.order)), make([]OrderDirection, 0, len(p.order)) + for _, o := range p.order { + fields = append(fields, o.Field.column) + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + directions = append(directions, direction) } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultTodoOrder.Field.column, p.order.Field.column, direction) { + predicates, err := entgql.MultiCursorsPredicate(after, before, &entgql.MultiCursorsOptions{ + FieldID: DefaultTodoOrder.Field.column, + DirectionID: idDirection, + Fields: fields, + Directions: directions, + }) + if err != nil { + return nil, err + } + for _, predicate := range predicates { query = query.Where(predicate) } return query, nil } func (p *todoPager) applyOrder(query *TodoQuery) *TodoQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultTodoOrder.Field { - query = query.Order(DefaultTodoOrder.Field.toTerm(direction.OrderTermOption())) + var defaultOrdered bool + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + if o.Field.column == DefaultTodoOrder.Field.column { + defaultOrdered = true + } + switch o.Field.column { + case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, TodoOrderFieldCategoryText.column: + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } + } } - switch p.order.Field.column { - case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, CategoryOrderFieldCategoryText.column: - default: - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) + if !defaultOrdered { + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() } + query = query.Order(DefaultTodoOrder.Field.toTerm(direction.OrderTermOption())) } return query } func (p *todoPager) orderExpr(query *TodoQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - switch p.order.Field.column { - case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, CategoryOrderFieldCategoryText.column: - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - default: - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) + for _, o := range p.order { + switch o.Field.column { + case TodoOrderFieldParentStatus.column, TodoOrderFieldChildrenCount.column, TodoOrderFieldCategoryText.column: + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } } } return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultTodoOrder.Field { - b.Comma().Ident(DefaultTodoOrder.Field.column).Pad().WriteString(string(direction)) + for _, o := range p.order { + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + b.Ident(o.Field.column).Pad().WriteString(string(direction)) + b.Comma() } + direction := entgql.OrderDirectionAsc + if p.reverse { + direction = direction.Reverse() + } + b.Ident(DefaultTodoOrder.Field.column).Pad().WriteString(string(direction)) }) } @@ -1801,12 +1871,12 @@ func (t *TodoQuery) PaginateLimitOffset( t.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1839,7 +1909,9 @@ func (t *TodoQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = t.Clone().Count(ctx); err != nil { + c := t.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1852,16 +1924,17 @@ func (t *TodoQuery) Paginate( if t, err = pager.applyCursors(t, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { t.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -1970,8 +2043,8 @@ var ( } }, } - // CategoryOrderFieldCategoryText orders by CATEGORY_TEXT. - CategoryOrderFieldCategoryText = &TodoOrderField{ + // TodoOrderFieldCategoryText orders by CATEGORY_TEXT. + TodoOrderFieldCategoryText = &TodoOrderField{ Value: func(t *Todo) (ent.Value, error) { return t.Value("category_text") }, @@ -2008,7 +2081,7 @@ func (f TodoOrderField) String() string { str = "PARENT_STATUS" case TodoOrderFieldChildrenCount.column: str = "CHILDREN_COUNT" - case CategoryOrderFieldCategoryText.column: + case TodoOrderFieldCategoryText.column: str = "CATEGORY_TEXT" } return str @@ -2039,7 +2112,7 @@ func (f *TodoOrderField) UnmarshalGQL(v interface{}) error { case "CHILDREN_COUNT": *f = *TodoOrderFieldChildrenCount case "CATEGORY_TEXT": - *f = *CategoryOrderFieldCategoryText + *f = *TodoOrderFieldCategoryText default: return fmt.Errorf("%s is not a valid TodoOrderField", str) } @@ -2298,12 +2371,12 @@ func (u *UserQuery) PaginateLimitOffset( u.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := u.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := u.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -2336,7 +2409,9 @@ func (u *UserQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = u.Clone().Count(ctx); err != nil { + c := u.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2349,16 +2424,17 @@ func (u *UserQuery) Paginate( if u, err = pager.applyCursors(u, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { u.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := u.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } diff --git a/entgql/internal/todouuid/ent/group/where.go b/entgql/internal/todouuid/ent/group/where.go index 1e5898a91..9d04941e6 100644 --- a/entgql/internal/todouuid/ent/group/where.go +++ b/entgql/internal/todouuid/ent/group/where.go @@ -163,32 +163,15 @@ func HasUsersWith(preds ...predicate.User) predicate.Group { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Group(sql.NotPredicates(p)) } diff --git a/entgql/internal/todouuid/ent/group_create.go b/entgql/internal/todouuid/ent/group_create.go index 3970e859a..749cb26d4 100644 --- a/entgql/internal/todouuid/ent/group_create.go +++ b/entgql/internal/todouuid/ent/group_create.go @@ -86,7 +86,7 @@ func (gc *GroupCreate) Mutation() *GroupMutation { // Save creates the Group in the database. func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) { gc.defaults() - return withHooks[*Group, GroupMutation](ctx, gc.sqlSave, gc.mutation, gc.hooks) + return withHooks(ctx, gc.sqlSave, gc.mutation, gc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -189,11 +189,15 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { // GroupCreateBulk is the builder for creating many Group entities in bulk. type GroupCreateBulk struct { config + err error builders []*GroupCreate } // Save creates the Group entities in the database. func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { + if gcb.err != nil { + return nil, gcb.err + } specs := make([]*sqlgraph.CreateSpec, len(gcb.builders)) nodes := make([]*Group, len(gcb.builders)) mutators := make([]Mutator, len(gcb.builders)) diff --git a/entgql/internal/todouuid/ent/group_delete.go b/entgql/internal/todouuid/ent/group_delete.go index ea920c60a..231bee1db 100644 --- a/entgql/internal/todouuid/ent/group_delete.go +++ b/entgql/internal/todouuid/ent/group_delete.go @@ -41,7 +41,7 @@ func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (gd *GroupDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gd.sqlExec, gd.mutation, gd.hooks) + return withHooks(ctx, gd.sqlExec, gd.mutation, gd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/group_update.go b/entgql/internal/todouuid/ent/group_update.go index 1387c9111..49f700d45 100644 --- a/entgql/internal/todouuid/ent/group_update.go +++ b/entgql/internal/todouuid/ent/group_update.go @@ -100,7 +100,7 @@ func (gu *GroupUpdate) RemoveUsers(u ...*User) *GroupUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (gu *GroupUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gu.sqlSave, gu.mutation, gu.hooks) + return withHooks(ctx, gu.sqlSave, gu.mutation, gu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -272,7 +272,7 @@ func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOn // Save executes the query and returns the updated Group entity. func (guo *GroupUpdateOne) Save(ctx context.Context) (*Group, error) { - return withHooks[*Group, GroupMutation](ctx, guo.sqlSave, guo.mutation, guo.hooks) + return withHooks(ctx, guo.sqlSave, guo.mutation, guo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/migrate/schema.go b/entgql/internal/todouuid/ent/migrate/schema.go index a160515e8..be619361c 100644 --- a/entgql/internal/todouuid/ent/migrate/schema.go +++ b/entgql/internal/todouuid/ent/migrate/schema.go @@ -41,6 +41,7 @@ var ( {Name: "text", Type: field.TypeString, Size: 2147483647}, {Name: "status", Type: field.TypeEnum, Enums: []string{"ENABLED", "DISABLED"}}, {Name: "config", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"sqlite3": "json"}}, + {Name: "types", Type: field.TypeJSON, Nullable: true}, {Name: "duration", Type: field.TypeInt64, Nullable: true}, {Name: "count", Type: field.TypeUint64, Nullable: true}, {Name: "strings", Type: field.TypeJSON, Nullable: true}, @@ -143,6 +144,7 @@ var ( {Name: "name", Type: field.TypeString, Default: "Anonymous"}, {Name: "username", Type: field.TypeUUID}, {Name: "password", Type: field.TypeString, Nullable: true}, + {Name: "required_metadata", Type: field.TypeJSON}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, } // UsersTable holds the schema information for the "users" table. diff --git a/entgql/internal/todouuid/ent/mutation.go b/entgql/internal/todouuid/ent/mutation.go index aacbf7b37..6ee345ecd 100644 --- a/entgql/internal/todouuid/ent/mutation.go +++ b/entgql/internal/todouuid/ent/mutation.go @@ -541,6 +541,7 @@ type CategoryMutation struct { text *string status *category.Status _config **schematype.CategoryConfig + types **schematype.CategoryTypes duration *time.Duration addduration *time.Duration count *uint64 @@ -784,6 +785,55 @@ func (m *CategoryMutation) ResetConfig() { delete(m.clearedFields, category.FieldConfig) } +// SetTypes sets the "types" field. +func (m *CategoryMutation) SetTypes(st *schematype.CategoryTypes) { + m.types = &st +} + +// Types returns the value of the "types" field in the mutation. +func (m *CategoryMutation) Types() (r *schematype.CategoryTypes, exists bool) { + v := m.types + if v == nil { + return + } + return *v, true +} + +// OldTypes returns the old "types" field's value of the Category entity. +// If the Category object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CategoryMutation) OldTypes(ctx context.Context) (v *schematype.CategoryTypes, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTypes is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTypes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTypes: %w", err) + } + return oldValue.Types, nil +} + +// ClearTypes clears the value of the "types" field. +func (m *CategoryMutation) ClearTypes() { + m.types = nil + m.clearedFields[category.FieldTypes] = struct{}{} +} + +// TypesCleared returns if the "types" field was cleared in this mutation. +func (m *CategoryMutation) TypesCleared() bool { + _, ok := m.clearedFields[category.FieldTypes] + return ok +} + +// ResetTypes resets all changes to the "types" field. +func (m *CategoryMutation) ResetTypes() { + m.types = nil + delete(m.clearedFields, category.FieldTypes) +} + // SetDuration sets the "duration" field. func (m *CategoryMutation) SetDuration(t time.Duration) { m.duration = &t @@ -1131,7 +1181,7 @@ func (m *CategoryMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *CategoryMutation) Fields() []string { - fields := make([]string, 0, 6) + fields := make([]string, 0, 7) if m.text != nil { fields = append(fields, category.FieldText) } @@ -1141,6 +1191,9 @@ func (m *CategoryMutation) Fields() []string { if m._config != nil { fields = append(fields, category.FieldConfig) } + if m.types != nil { + fields = append(fields, category.FieldTypes) + } if m.duration != nil { fields = append(fields, category.FieldDuration) } @@ -1164,6 +1217,8 @@ func (m *CategoryMutation) Field(name string) (ent.Value, bool) { return m.Status() case category.FieldConfig: return m.Config() + case category.FieldTypes: + return m.Types() case category.FieldDuration: return m.Duration() case category.FieldCount: @@ -1185,6 +1240,8 @@ func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldStatus(ctx) case category.FieldConfig: return m.OldConfig(ctx) + case category.FieldTypes: + return m.OldTypes(ctx) case category.FieldDuration: return m.OldDuration(ctx) case category.FieldCount: @@ -1221,6 +1278,13 @@ func (m *CategoryMutation) SetField(name string, value ent.Value) error { } m.SetConfig(v) return nil + case category.FieldTypes: + v, ok := value.(*schematype.CategoryTypes) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTypes(v) + return nil case category.FieldDuration: v, ok := value.(time.Duration) if !ok { @@ -1302,6 +1366,9 @@ func (m *CategoryMutation) ClearedFields() []string { if m.FieldCleared(category.FieldConfig) { fields = append(fields, category.FieldConfig) } + if m.FieldCleared(category.FieldTypes) { + fields = append(fields, category.FieldTypes) + } if m.FieldCleared(category.FieldDuration) { fields = append(fields, category.FieldDuration) } @@ -1328,6 +1395,9 @@ func (m *CategoryMutation) ClearField(name string) error { case category.FieldConfig: m.ClearConfig() return nil + case category.FieldTypes: + m.ClearTypes() + return nil case category.FieldDuration: m.ClearDuration() return nil @@ -1354,6 +1424,9 @@ func (m *CategoryMutation) ResetField(name string) error { case category.FieldConfig: m.ResetConfig() return nil + case category.FieldTypes: + m.ResetTypes() + return nil case category.FieldDuration: m.ResetDuration() return nil @@ -1709,6 +1782,7 @@ func (m *FriendshipMutation) ResetFriendID() { // ClearUser clears the "user" edge to the User entity. func (m *FriendshipMutation) ClearUser() { m.cleareduser = true + m.clearedFields[friendship.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. @@ -1735,6 +1809,7 @@ func (m *FriendshipMutation) ResetUser() { // ClearFriend clears the "friend" edge to the User entity. func (m *FriendshipMutation) ClearFriend() { m.clearedfriend = true + m.clearedFields[friendship.FieldFriendID] = struct{}{} } // FriendCleared reports if the "friend" edge to the User entity was cleared. @@ -3113,6 +3188,7 @@ func (m *TodoMutation) ResetChildren() { // ClearCategory clears the "category" edge to the Category entity. func (m *TodoMutation) ClearCategory() { m.clearedcategory = true + m.clearedFields[todo.FieldCategoryID] = struct{}{} } // CategoryCleared reports if the "category" edge to the Category entity was cleared. @@ -3637,6 +3713,7 @@ type UserMutation struct { name *string username *uuid.UUID password *string + required_metadata *map[string]interface{} metadata *map[string]interface{} clearedFields map[string]struct{} groups map[uuid.UUID]struct{} @@ -3878,6 +3955,42 @@ func (m *UserMutation) ResetPassword() { delete(m.clearedFields, user.FieldPassword) } +// SetRequiredMetadata sets the "required_metadata" field. +func (m *UserMutation) SetRequiredMetadata(value map[string]interface{}) { + m.required_metadata = &value +} + +// RequiredMetadata returns the value of the "required_metadata" field in the mutation. +func (m *UserMutation) RequiredMetadata() (r map[string]interface{}, exists bool) { + v := m.required_metadata + if v == nil { + return + } + return *v, true +} + +// OldRequiredMetadata returns the old "required_metadata" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldRequiredMetadata(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRequiredMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRequiredMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRequiredMetadata: %w", err) + } + return oldValue.RequiredMetadata, nil +} + +// ResetRequiredMetadata resets all changes to the "required_metadata" field. +func (m *UserMutation) ResetRequiredMetadata() { + m.required_metadata = nil +} + // SetMetadata sets the "metadata" field. func (m *UserMutation) SetMetadata(value map[string]interface{}) { m.metadata = &value @@ -4123,7 +4236,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 4) + fields := make([]string, 0, 5) if m.name != nil { fields = append(fields, user.FieldName) } @@ -4133,6 +4246,9 @@ func (m *UserMutation) Fields() []string { if m.password != nil { fields = append(fields, user.FieldPassword) } + if m.required_metadata != nil { + fields = append(fields, user.FieldRequiredMetadata) + } if m.metadata != nil { fields = append(fields, user.FieldMetadata) } @@ -4150,6 +4266,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.Username() case user.FieldPassword: return m.Password() + case user.FieldRequiredMetadata: + return m.RequiredMetadata() case user.FieldMetadata: return m.Metadata() } @@ -4167,6 +4285,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldUsername(ctx) case user.FieldPassword: return m.OldPassword(ctx) + case user.FieldRequiredMetadata: + return m.OldRequiredMetadata(ctx) case user.FieldMetadata: return m.OldMetadata(ctx) } @@ -4199,6 +4319,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetPassword(v) return nil + case user.FieldRequiredMetadata: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRequiredMetadata(v) + return nil case user.FieldMetadata: v, ok := value.(map[string]interface{}) if !ok { @@ -4279,6 +4406,9 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldPassword: m.ResetPassword() return nil + case user.FieldRequiredMetadata: + m.ResetRequiredMetadata() + return nil case user.FieldMetadata: m.ResetMetadata() return nil diff --git a/entgql/internal/todouuid/ent/runtime/runtime.go b/entgql/internal/todouuid/ent/runtime/runtime.go index 384887c2b..9b42a989a 100644 --- a/entgql/internal/todouuid/ent/runtime/runtime.go +++ b/entgql/internal/todouuid/ent/runtime/runtime.go @@ -19,6 +19,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entgql/internal/todouuid/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entgql/internal/todouuid/ent/todo/where.go b/entgql/internal/todouuid/ent/todo/where.go index 7ee947a4f..9449e7bbb 100644 --- a/entgql/internal/todouuid/ent/todo/where.go +++ b/entgql/internal/todouuid/ent/todo/where.go @@ -464,32 +464,15 @@ func HasSecretWith(preds ...predicate.VerySecret) predicate.Todo { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Todo(sql.NotPredicates(p)) } diff --git a/entgql/internal/todouuid/ent/todo_create.go b/entgql/internal/todouuid/ent/todo_create.go index c2aa168e1..20a4bda27 100644 --- a/entgql/internal/todouuid/ent/todo_create.go +++ b/entgql/internal/todouuid/ent/todo_create.go @@ -196,7 +196,7 @@ func (tc *TodoCreate) Mutation() *TodoMutation { // Save creates the Todo in the database. func (tc *TodoCreate) Save(ctx context.Context) (*Todo, error) { tc.defaults() - return withHooks[*Todo, TodoMutation](ctx, tc.sqlSave, tc.mutation, tc.hooks) + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -401,11 +401,15 @@ func (tc *TodoCreate) createSpec() (*Todo, *sqlgraph.CreateSpec) { // TodoCreateBulk is the builder for creating many Todo entities in bulk. type TodoCreateBulk struct { config + err error builders []*TodoCreate } // Save creates the Todo entities in the database. func (tcb *TodoCreateBulk) Save(ctx context.Context) ([]*Todo, error) { + if tcb.err != nil { + return nil, tcb.err + } specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) nodes := make([]*Todo, len(tcb.builders)) mutators := make([]Mutator, len(tcb.builders)) diff --git a/entgql/internal/todouuid/ent/todo_delete.go b/entgql/internal/todouuid/ent/todo_delete.go index dbd18536c..8593ec147 100644 --- a/entgql/internal/todouuid/ent/todo_delete.go +++ b/entgql/internal/todouuid/ent/todo_delete.go @@ -41,7 +41,7 @@ func (td *TodoDelete) Where(ps ...predicate.Todo) *TodoDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (td *TodoDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, td.sqlExec, td.mutation, td.hooks) + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/todo_update.go b/entgql/internal/todouuid/ent/todo_update.go index 9fae2af32..097db002f 100644 --- a/entgql/internal/todouuid/ent/todo_update.go +++ b/entgql/internal/todouuid/ent/todo_update.go @@ -51,6 +51,14 @@ func (tu *TodoUpdate) SetStatus(t todo.Status) *TodoUpdate { return tu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableStatus(t *todo.Status) *TodoUpdate { + if t != nil { + tu.SetStatus(*t) + } + return tu +} + // SetPriority sets the "priority" field. func (tu *TodoUpdate) SetPriority(i int) *TodoUpdate { tu.mutation.ResetPriority() @@ -78,6 +86,14 @@ func (tu *TodoUpdate) SetText(s string) *TodoUpdate { return tu } +// SetNillableText sets the "text" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableText(s *string) *TodoUpdate { + if s != nil { + tu.SetText(*s) + } + return tu +} + // SetBlob sets the "blob" field. func (tu *TodoUpdate) SetBlob(b []byte) *TodoUpdate { tu.mutation.SetBlob(b) @@ -231,7 +247,7 @@ func (tu *TodoUpdate) ClearSecret() *TodoUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TodoUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, tu.sqlSave, tu.mutation, tu.hooks) + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -458,6 +474,14 @@ func (tuo *TodoUpdateOne) SetStatus(t todo.Status) *TodoUpdateOne { return tuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableStatus(t *todo.Status) *TodoUpdateOne { + if t != nil { + tuo.SetStatus(*t) + } + return tuo +} + // SetPriority sets the "priority" field. func (tuo *TodoUpdateOne) SetPriority(i int) *TodoUpdateOne { tuo.mutation.ResetPriority() @@ -485,6 +509,14 @@ func (tuo *TodoUpdateOne) SetText(s string) *TodoUpdateOne { return tuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableText(s *string) *TodoUpdateOne { + if s != nil { + tuo.SetText(*s) + } + return tuo +} + // SetBlob sets the "blob" field. func (tuo *TodoUpdateOne) SetBlob(b []byte) *TodoUpdateOne { tuo.mutation.SetBlob(b) @@ -651,7 +683,7 @@ func (tuo *TodoUpdateOne) Select(field string, fields ...string) *TodoUpdateOne // Save executes the query and returns the updated Todo entity. func (tuo *TodoUpdateOne) Save(ctx context.Context) (*Todo, error) { - return withHooks[*Todo, TodoMutation](ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/user.go b/entgql/internal/todouuid/ent/user.go index 4e568090c..5766ed153 100644 --- a/entgql/internal/todouuid/ent/user.go +++ b/entgql/internal/todouuid/ent/user.go @@ -38,6 +38,8 @@ type User struct { Username uuid.UUID `json:"username,omitempty"` // Password holds the value of the "password" field. Password string `json:"-"` + // RequiredMetadata holds the value of the "required_metadata" field. + RequiredMetadata map[string]interface{} `json:"required_metadata,omitempty"` // Metadata holds the value of the "metadata" field. Metadata map[string]interface{} `json:"metadata,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -97,7 +99,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case user.FieldMetadata: + case user.FieldRequiredMetadata, user.FieldMetadata: values[i] = new([]byte) case user.FieldName, user.FieldPassword: values[i] = new(sql.NullString) @@ -142,6 +144,14 @@ func (u *User) assignValues(columns []string, values []any) error { } else if value.Valid { u.Password = value.String } + case user.FieldRequiredMetadata: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field required_metadata", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &u.RequiredMetadata); err != nil { + return fmt.Errorf("unmarshal field required_metadata: %w", err) + } + } case user.FieldMetadata: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field metadata", values[i]) @@ -209,6 +219,9 @@ func (u *User) String() string { builder.WriteString(", ") builder.WriteString("password=") builder.WriteString(", ") + builder.WriteString("required_metadata=") + builder.WriteString(fmt.Sprintf("%v", u.RequiredMetadata)) + builder.WriteString(", ") builder.WriteString("metadata=") builder.WriteString(fmt.Sprintf("%v", u.Metadata)) builder.WriteByte(')') diff --git a/entgql/internal/todouuid/ent/user/user.go b/entgql/internal/todouuid/ent/user/user.go index 46416fcb9..5734665c4 100644 --- a/entgql/internal/todouuid/ent/user/user.go +++ b/entgql/internal/todouuid/ent/user/user.go @@ -33,6 +33,8 @@ const ( FieldUsername = "username" // FieldPassword holds the string denoting the password field in the database. FieldPassword = "password" + // FieldRequiredMetadata holds the string denoting the required_metadata field in the database. + FieldRequiredMetadata = "required_metadata" // FieldMetadata holds the string denoting the metadata field in the database. FieldMetadata = "metadata" // EdgeGroups holds the string denoting the groups edge name in mutations. @@ -65,6 +67,7 @@ var Columns = []string{ FieldName, FieldUsername, FieldPassword, + FieldRequiredMetadata, FieldMetadata, } diff --git a/entgql/internal/todouuid/ent/user/where.go b/entgql/internal/todouuid/ent/user/where.go index a11fd55a4..cd68b540d 100644 --- a/entgql/internal/todouuid/ent/user/where.go +++ b/entgql/internal/todouuid/ent/user/where.go @@ -344,32 +344,15 @@ func HasFriendshipsWith(preds ...predicate.Friendship) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entgql/internal/todouuid/ent/user_create.go b/entgql/internal/todouuid/ent/user_create.go index d599c558c..52f91bc78 100644 --- a/entgql/internal/todouuid/ent/user_create.go +++ b/entgql/internal/todouuid/ent/user_create.go @@ -78,6 +78,12 @@ func (uc *UserCreate) SetNillablePassword(s *string) *UserCreate { return uc } +// SetRequiredMetadata sets the "required_metadata" field. +func (uc *UserCreate) SetRequiredMetadata(m map[string]interface{}) *UserCreate { + uc.mutation.SetRequiredMetadata(m) + return uc +} + // SetMetadata sets the "metadata" field. func (uc *UserCreate) SetMetadata(m map[string]interface{}) *UserCreate { uc.mutation.SetMetadata(m) @@ -151,7 +157,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { uc.defaults() - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -200,6 +206,9 @@ func (uc *UserCreate) check() error { if _, ok := uc.mutation.Username(); !ok { return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} } + if _, ok := uc.mutation.RequiredMetadata(); !ok { + return &ValidationError{Name: "required_metadata", err: errors.New(`ent: missing required field "User.required_metadata"`)} + } return nil } @@ -247,6 +256,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldPassword, field.TypeString, value) _node.Password = value } + if value, ok := uc.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + _node.RequiredMetadata = value + } if value, ok := uc.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) _node.Metadata = value @@ -312,11 +325,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entgql/internal/todouuid/ent/user_delete.go b/entgql/internal/todouuid/ent/user_delete.go index cf9dac2d7..63269a51f 100644 --- a/entgql/internal/todouuid/ent/user_delete.go +++ b/entgql/internal/todouuid/ent/user_delete.go @@ -41,7 +41,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/user_update.go b/entgql/internal/todouuid/ent/user_update.go index 298c5feb2..7424ef8ed 100644 --- a/entgql/internal/todouuid/ent/user_update.go +++ b/entgql/internal/todouuid/ent/user_update.go @@ -92,6 +92,12 @@ func (uu *UserUpdate) ClearPassword() *UserUpdate { return uu } +// SetRequiredMetadata sets the "required_metadata" field. +func (uu *UserUpdate) SetRequiredMetadata(m map[string]interface{}) *UserUpdate { + uu.mutation.SetRequiredMetadata(m) + return uu +} + // SetMetadata sets the "metadata" field. func (uu *UserUpdate) SetMetadata(m map[string]interface{}) *UserUpdate { uu.mutation.SetMetadata(m) @@ -219,7 +225,7 @@ func (uu *UserUpdate) RemoveFriendships(f ...*Friendship) *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -265,6 +271,9 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if uu.mutation.PasswordCleared() { _spec.ClearField(user.FieldPassword, field.TypeString) } + if value, ok := uu.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + } if value, ok := uu.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) } @@ -495,6 +504,12 @@ func (uuo *UserUpdateOne) ClearPassword() *UserUpdateOne { return uuo } +// SetRequiredMetadata sets the "required_metadata" field. +func (uuo *UserUpdateOne) SetRequiredMetadata(m map[string]interface{}) *UserUpdateOne { + uuo.mutation.SetRequiredMetadata(m) + return uuo +} + // SetMetadata sets the "metadata" field. func (uuo *UserUpdateOne) SetMetadata(m map[string]interface{}) *UserUpdateOne { uuo.mutation.SetMetadata(m) @@ -635,7 +650,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -698,6 +713,9 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if uuo.mutation.PasswordCleared() { _spec.ClearField(user.FieldPassword, field.TypeString) } + if value, ok := uuo.mutation.RequiredMetadata(); ok { + _spec.SetField(user.FieldRequiredMetadata, field.TypeJSON, value) + } if value, ok := uuo.mutation.Metadata(); ok { _spec.SetField(user.FieldMetadata, field.TypeJSON, value) } diff --git a/entgql/internal/todouuid/ent/verysecret/where.go b/entgql/internal/todouuid/ent/verysecret/where.go index 661db7d58..36ca58408 100644 --- a/entgql/internal/todouuid/ent/verysecret/where.go +++ b/entgql/internal/todouuid/ent/verysecret/where.go @@ -139,32 +139,15 @@ func PasswordContainsFold(v string) predicate.VerySecret { // And groups predicates with the AND operator between them. func And(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.VerySecret(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.VerySecret) predicate.VerySecret { - return predicate.VerySecret(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.VerySecret(sql.NotPredicates(p)) } diff --git a/entgql/internal/todouuid/ent/verysecret_create.go b/entgql/internal/todouuid/ent/verysecret_create.go index 400d17ab5..5131d094d 100644 --- a/entgql/internal/todouuid/ent/verysecret_create.go +++ b/entgql/internal/todouuid/ent/verysecret_create.go @@ -62,7 +62,7 @@ func (vsc *VerySecretCreate) Mutation() *VerySecretMutation { // Save creates the VerySecret in the database. func (vsc *VerySecretCreate) Save(ctx context.Context) (*VerySecret, error) { vsc.defaults() - return withHooks[*VerySecret, VerySecretMutation](ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) + return withHooks(ctx, vsc.sqlSave, vsc.mutation, vsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -145,11 +145,15 @@ func (vsc *VerySecretCreate) createSpec() (*VerySecret, *sqlgraph.CreateSpec) { // VerySecretCreateBulk is the builder for creating many VerySecret entities in bulk. type VerySecretCreateBulk struct { config + err error builders []*VerySecretCreate } // Save creates the VerySecret entities in the database. func (vscb *VerySecretCreateBulk) Save(ctx context.Context) ([]*VerySecret, error) { + if vscb.err != nil { + return nil, vscb.err + } specs := make([]*sqlgraph.CreateSpec, len(vscb.builders)) nodes := make([]*VerySecret, len(vscb.builders)) mutators := make([]Mutator, len(vscb.builders)) diff --git a/entgql/internal/todouuid/ent/verysecret_delete.go b/entgql/internal/todouuid/ent/verysecret_delete.go index 0f6ef08e7..155b7a6b0 100644 --- a/entgql/internal/todouuid/ent/verysecret_delete.go +++ b/entgql/internal/todouuid/ent/verysecret_delete.go @@ -41,7 +41,7 @@ func (vsd *VerySecretDelete) Where(ps ...predicate.VerySecret) *VerySecretDelete // Exec executes the deletion query and returns how many vertices were deleted. func (vsd *VerySecretDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) + return withHooks(ctx, vsd.sqlExec, vsd.mutation, vsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entgql/internal/todouuid/ent/verysecret_update.go b/entgql/internal/todouuid/ent/verysecret_update.go index dead078a9..27167b72c 100644 --- a/entgql/internal/todouuid/ent/verysecret_update.go +++ b/entgql/internal/todouuid/ent/verysecret_update.go @@ -47,6 +47,14 @@ func (vsu *VerySecretUpdate) SetPassword(s string) *VerySecretUpdate { return vsu } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsu *VerySecretUpdate) SetNillablePassword(s *string) *VerySecretUpdate { + if s != nil { + vsu.SetPassword(*s) + } + return vsu +} + // Mutation returns the VerySecretMutation object of the builder. func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { return vsu.mutation @@ -54,7 +62,7 @@ func (vsu *VerySecretUpdate) Mutation() *VerySecretMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (vsu *VerySecretUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, VerySecretMutation](ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) + return withHooks(ctx, vsu.sqlSave, vsu.mutation, vsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -117,6 +125,14 @@ func (vsuo *VerySecretUpdateOne) SetPassword(s string) *VerySecretUpdateOne { return vsuo } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (vsuo *VerySecretUpdateOne) SetNillablePassword(s *string) *VerySecretUpdateOne { + if s != nil { + vsuo.SetPassword(*s) + } + return vsuo +} + // Mutation returns the VerySecretMutation object of the builder. func (vsuo *VerySecretUpdateOne) Mutation() *VerySecretMutation { return vsuo.mutation @@ -137,7 +153,7 @@ func (vsuo *VerySecretUpdateOne) Select(field string, fields ...string) *VerySec // Save executes the query and returns the updated VerySecret entity. func (vsuo *VerySecretUpdateOne) Save(ctx context.Context) (*VerySecret, error) { - return withHooks[*VerySecret, VerySecretMutation](ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) + return withHooks(ctx, vsuo.sqlSave, vsuo.mutation, vsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entgql/internal/todouuid/generated.go b/entgql/internal/todouuid/generated.go index 9b730907b..111e5debe 100644 --- a/entgql/internal/todouuid/generated.go +++ b/entgql/internal/todouuid/generated.go @@ -13,6 +13,7 @@ import ( "time" "entgo.io/contrib/entgql" + ent1 "entgo.io/contrib/entgql/internal/todo/ent" "entgo.io/contrib/entgql/internal/todo/ent/schema/customstruct" "entgo.io/contrib/entgql/internal/todo/ent/schema/durationgql" "entgo.io/contrib/entgql/internal/todo/ent/schema/schematype" @@ -32,6 +33,7 @@ import ( // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ + schema: cfg.Schema, resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, @@ -39,6 +41,7 @@ func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { } type Config struct { + Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot @@ -47,6 +50,7 @@ type Config struct { type ResolverRoot interface { Category() CategoryResolver Mutation() MutationResolver + Organization() OrganizationResolver Query() QueryResolver Todo() TodoResolver User() UserResolver @@ -54,6 +58,7 @@ type ResolverRoot interface { CreateTodoInput() CreateTodoInputResolver CreateUserInput() CreateUserInputResolver TodoWhereInput() TodoWhereInputResolver + UpdateCategoryInput() UpdateCategoryInputResolver UpdateTodoInput() UpdateTodoInputResolver UpdateUserInput() UpdateUserInputResolver UserWhereInput() UserWhereInputResolver @@ -80,8 +85,9 @@ type ComplexityRoot struct { Strings func(childComplexity int) int SubCategories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int Text func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int TodosCount func(childComplexity int) int + Types func(childComplexity int) int } CategoryConfig struct { @@ -93,6 +99,10 @@ type ComplexityRoot struct { TotalCount func(childComplexity int) int } + CategoryTypes struct { + Public func(childComplexity int) int + } + Custom struct { Info func(childComplexity int) int } @@ -143,6 +153,11 @@ type ComplexityRoot struct { TotalCount func(childComplexity int) int } + Organization struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int @@ -152,25 +167,26 @@ type ComplexityRoot struct { Project struct { ID func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int } Query struct { - BillProducts func(childComplexity int) int - Categories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int - Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int - Node func(childComplexity int, id uuid.UUID) int - Nodes func(childComplexity int, ids []uuid.UUID) int - OneToMany func(childComplexity int, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) int - Ping func(childComplexity int) int - Todos func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int - Users func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int + BillProducts func(childComplexity int) int + Categories func(childComplexity int, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) int + Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int + Node func(childComplexity int, id uuid.UUID) int + Nodes func(childComplexity int, ids []uuid.UUID) int + OneToMany func(childComplexity int, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) int + Ping func(childComplexity int) int + Todos func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int + TodosWithJoins func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int + Users func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int } Todo struct { Category func(childComplexity int) int CategoryID func(childComplexity int) int - Children func(childComplexity int, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) int + Children func(childComplexity int, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) int CreatedAt func(childComplexity int) int Custom func(childComplexity int) int Customp func(childComplexity int) int @@ -189,13 +205,14 @@ type ComplexityRoot struct { } User struct { - Friends func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int - Friendships func(childComplexity int, limit *int, offset *int, where *ent.FriendshipWhereInput) int - Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int - ID func(childComplexity int) int - Metadata func(childComplexity int) int - Name func(childComplexity int) int - Username func(childComplexity int) int + Friends func(childComplexity int, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) int + Friendships func(childComplexity int, limit *int, offset *int, where *ent.FriendshipWhereInput) int + Groups func(childComplexity int, limit *int, offset *int, where *ent.GroupWhereInput) int + ID func(childComplexity int) int + Metadata func(childComplexity int) int + Name func(childComplexity int) int + RequiredMetadata func(childComplexity int) int + Username func(childComplexity int) int } UserList struct { @@ -205,6 +222,8 @@ type ComplexityRoot struct { } type CategoryResolver interface { + Types(ctx context.Context, obj *ent.Category) (*CategoryTypes, error) + TodosCount(ctx context.Context, obj *ent.Category) (*int, error) } type MutationResolver interface { @@ -214,6 +233,9 @@ type MutationResolver interface { ClearTodos(ctx context.Context) (int, error) UpdateFriendship(ctx context.Context, id uuid.UUID, input UpdateFriendshipInput) (*ent.Friendship, error) } +type OrganizationResolver interface { + ID(ctx context.Context, obj *ent1.Workspace) (uuid.UUID, error) +} type QueryResolver interface { Node(ctx context.Context, id uuid.UUID) (ent.Noder, error) Nodes(ctx context.Context, ids []uuid.UUID) ([]ent.Noder, error) @@ -221,9 +243,10 @@ type QueryResolver interface { Categories(ctx context.Context, limit *int, offset *int, orderBy []*ent.CategoryOrder, where *ent.CategoryWhereInput) (*ent.CategoryList, error) Groups(ctx context.Context, limit *int, offset *int, where *ent.GroupWhereInput) (*ent.GroupList, error) OneToMany(ctx context.Context, limit *int, offset *int, orderBy *OneToManyOrder, where *OneToManyWhereInput) (*OneToManyList, error) - Todos(ctx context.Context, limit *int, offset *int, orderBy *ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) + Todos(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) Users(ctx context.Context, limit *int, offset *int, orderBy *ent.UserOrder, where *ent.UserWhereInput) (*ent.UserList, error) Ping(ctx context.Context) (string, error) + TodosWithJoins(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) } type TodoResolver interface { Status(ctx context.Context, obj *ent.Todo) (todo.Status, error) @@ -238,6 +261,8 @@ type UserResolver interface { } type CreateCategoryInputResolver interface { + Types(ctx context.Context, obj *ent.CreateCategoryInput, data *CategoryTypesInput) error + CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error } type CreateTodoInputResolver interface { @@ -254,6 +279,9 @@ type TodoWhereInputResolver interface { CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error } +type UpdateCategoryInputResolver interface { + Types(ctx context.Context, obj *ent.UpdateCategoryInput, data *CategoryTypesInput) error +} type UpdateTodoInputResolver interface { Status(ctx context.Context, obj *ent.UpdateTodoInput, data *todo.Status) error } @@ -272,17 +300,21 @@ type UserWhereInputResolver interface { } type executableSchema struct { + schema *ast.Schema resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} + ec := executionContext{nil, e, 0, 0, nil} _ = ec switch typeName + "." + field { @@ -385,7 +417,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Category.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Category.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Category.todosCount": if e.complexity.Category.TodosCount == nil { @@ -394,6 +426,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Category.TodosCount(childComplexity), true + case "Category.types": + if e.complexity.Category.Types == nil { + break + } + + return e.complexity.Category.Types(childComplexity), true + case "CategoryConfig.maxMembers": if e.complexity.CategoryConfig.MaxMembers == nil { break @@ -415,6 +454,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CategoryList.TotalCount(childComplexity), true + case "CategoryTypes.public": + if e.complexity.CategoryTypes.Public == nil { + break + } + + return e.complexity.CategoryTypes.Public(childComplexity), true + case "Custom.info": if e.complexity.Custom.Info == nil { break @@ -622,6 +668,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OneToManyList.TotalCount(childComplexity), true + case "Organization.id": + if e.complexity.Organization.ID == nil { + break + } + + return e.complexity.Organization.ID(childComplexity), true + + case "Organization.name": + if e.complexity.Organization.Name == nil { + break + } + + return e.complexity.Organization.Name(childComplexity), true + case "PageInfo.endCursor": if e.complexity.PageInfo.EndCursor == nil { break @@ -667,7 +727,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Project.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Project.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Query.billProducts": if e.complexity.Query.BillProducts == nil { @@ -753,7 +813,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Query.Todos(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + + case "Query.todosWithJoins": + if e.complexity.Query.TodosWithJoins == nil { + break + } + + args, err := ec.field_Query_todosWithJoins_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.TodosWithJoins(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Query.users": if e.complexity.Query.Users == nil { @@ -791,7 +863,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Todo.Children(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].(*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true + return e.complexity.Todo.Children(childComplexity, args["limit"].(*int), args["offset"].(*int), args["orderBy"].([]*ent.TodoOrder), args["where"].(*ent.TodoWhereInput)), true case "Todo.createdAt": if e.complexity.Todo.CreatedAt == nil { @@ -934,6 +1006,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Name(childComplexity), true + case "User.requiredMetadata": + if e.complexity.User.RequiredMetadata == nil { + break + } + + return e.complexity.User.RequiredMetadata(childComplexity), true + case "User.username": if e.complexity.User.Username == nil { break @@ -961,11 +1040,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputBillProductWhereInput, ec.unmarshalInputCategoryConfigInput, ec.unmarshalInputCategoryOrder, + ec.unmarshalInputCategoryTypesInput, ec.unmarshalInputCategoryWhereInput, ec.unmarshalInputCreateCategoryInput, ec.unmarshalInputCreateTodoInput, @@ -974,6 +1054,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputGroupWhereInput, ec.unmarshalInputOneToManyOrder, ec.unmarshalInputOneToManyWhereInput, + ec.unmarshalInputOrganizationWhereInput, ec.unmarshalInputProjectWhereInput, ec.unmarshalInputTodoOrder, ec.unmarshalInputTodoWhereInput, @@ -989,18 +1070,33 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { - if !first { - return nil + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } } - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext } + + return &response } case ast.Mutation: return func(ctx context.Context) *graphql.Response { @@ -1026,20 +1122,42 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { type executionContext struct { *graphql.OperationContext *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } var sources = []*ast.Source{ @@ -1053,6 +1171,14 @@ input CategoryConfigInput { maxMembers: Int } +type CategoryTypes { + public: Boolean +} + +input CategoryTypesInput { + public: Boolean +} + scalar Duration scalar UUID @@ -1076,6 +1202,21 @@ extend type Query { This field is an example of extending the built-in Query type from Ent. """ ping: String! + + """This is the todo item""" + todosWithJoins( + """Pagination limit.""" + limit: Int = 100 + + """Pagination offset.""" + offset: Int = 0 + + """Ordering options for Todos returned from the connection.""" + orderBy: [TodoOrder!] + + """Filtering options for Todos returned from the connection.""" + where: TodoWhereInput +): TodoList } type Mutation { @@ -1093,22 +1234,31 @@ type Custom { extend input CreateCategoryInput { createTodos: [CreateTodoInput!] } -`, BuiltIn: false}, - {Name: "../todo/ent.graphql", Input: `directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -"""Represents BillProduct object""" + +interface NamedNode { + name: String! +}`, BuiltIn: false}, + {Name: "../todo/ent.graphql", Input: `directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @goModel(model: String, models: [String!], forceGenerate: Boolean) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +""" +Represents BillProduct object +""" type BillProduct implements Node { id: ID! name: String! sku: String! quantity: Uint64! } -"""BillProductWhereInput is used for filtering BillProduct objects.""" +""" +BillProductWhereInput is used for filtering BillProduct objects. +""" input BillProductWhereInput { not: BillProductWhereInput and: [BillProductWhereInput!] or: [BillProductWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1117,7 +1267,9 @@ input BillProductWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1131,7 +1283,9 @@ input BillProductWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """sku field predicates""" + """ + sku field predicates + """ sku: String skuNEQ: String skuIn: [String!] @@ -1145,7 +1299,9 @@ input BillProductWhereInput { skuHasSuffix: String skuEqualFold: String skuContainsFold: String - """quantity field predicates""" + """ + quantity field predicates + """ quantity: Uint64 quantityNEQ: Uint64 quantityIn: [Uint64!] @@ -1155,75 +1311,115 @@ input BillProductWhereInput { quantityLT: Uint64 quantityLTE: Uint64 } -"""Represents Category object""" +""" +Represents Category object +""" type Category implements Node { id: ID! text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList subCategories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type CategoryList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Category]! } -"""Ordering options for Category connections""" +""" +Ordering options for Category connections +""" input CategoryOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Categories.""" + """ + The field by which to order Categories. + """ field: CategoryOrderField! } -"""Properties by which Category connections can be ordered.""" +""" +Properties by which Category connections can be ordered. +""" enum CategoryOrderField { ID TEXT + STATUS DURATION COUNT TODOS_COUNT } -"""CategoryStatus is enum for the field status""" +""" +CategoryStatus is enum for the field status +""" enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { ENABLED DISABLED } -"""CategoryWhereInput is used for filtering Category objects.""" +""" +CategoryWhereInput is used for filtering Category objects. +""" input CategoryWhereInput { not: CategoryWhereInput and: [CategoryWhereInput!] or: [CategoryWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1232,7 +1428,9 @@ input CategoryWhereInput { idGTE: ID idLT: ID idLTE: ID - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -1246,12 +1444,16 @@ input CategoryWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """status field predicates""" + """ + status field predicates + """ status: CategoryStatus statusNEQ: CategoryStatus statusIn: [CategoryStatus!] statusNotIn: [CategoryStatus!] - """config field predicates""" + """ + config field predicates + """ config: CategoryConfigInput configNEQ: CategoryConfigInput configIn: [CategoryConfigInput!] @@ -1262,7 +1464,9 @@ input CategoryWhereInput { configLTE: CategoryConfigInput configIsNil: Boolean configNotNil: Boolean - """duration field predicates""" + """ + duration field predicates + """ duration: Duration durationNEQ: Duration durationIn: [Duration!] @@ -1273,7 +1477,9 @@ input CategoryWhereInput { durationLTE: Duration durationIsNil: Boolean durationNotNil: Boolean - """count field predicates""" + """ + count field predicates + """ count: Uint64 countNEQ: Uint64 countIn: [Uint64!] @@ -1284,25 +1490,34 @@ input CategoryWhereInput { countLTE: Uint64 countIsNil: Boolean countNotNil: Boolean - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] - """sub_categories edge predicates""" + """ + sub_categories edge predicates + """ hasSubCategories: Boolean hasSubCategoriesWith: [CategoryWhereInput!] } -"""CreateCategoryInput is used for create Category object.""" +""" +CreateCategoryInput is used for create Category object. +""" input CreateCategoryInput { text: String! status: CategoryStatus! config: CategoryConfigInput + types: CategoryTypesInput duration: Duration count: Uint64 strings: [String!] todoIDs: [ID!] subCategoryIDs: [ID!] } -"""CreateTodoInput is used for create Todo object.""" +""" +CreateTodoInput is used for create Todo object. +""" input CreateTodoInput { status: TodoStatus! priority: Int @@ -1313,11 +1528,14 @@ input CreateTodoInput { categoryID: ID secretID: ID } -"""CreateUserInput is used for create User object.""" +""" +CreateUserInput is used for create User object. +""" input CreateUserInput { name: String username: UUID password: String + requiredMetadata: Map! metadata: Map groupIDs: [ID!] friendIDs: [ID!] @@ -1335,19 +1553,29 @@ type Friendship implements Node { user: User! friend: User! } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type FriendshipList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Friendship]! } -"""FriendshipWhereInput is used for filtering Friendship objects.""" +""" +FriendshipWhereInput is used for filtering Friendship objects. +""" input FriendshipWhereInput { not: FriendshipWhereInput and: [FriendshipWhereInput!] or: [FriendshipWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1356,7 +1584,9 @@ input FriendshipWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -1366,36 +1596,54 @@ input FriendshipWhereInput { createdAtLT: Time createdAtLTE: Time } -type Group implements Node @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { +type Group implements Node & NamedNode @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { id: ID! name: String! users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type GroupList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Group]! } -"""GroupWhereInput is used for filtering Group objects.""" +""" +GroupWhereInput is used for filtering Group objects. +""" input GroupWhereInput { not: GroupWhereInput and: [GroupWhereInput!] or: [GroupWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1404,7 +1652,9 @@ input GroupWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1418,18 +1668,24 @@ input GroupWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """users edge predicates""" + """ + users edge predicates + """ hasUsers: Boolean hasUsersWith: [UserWhereInput!] } -"""The builtin Map type""" +""" +The builtin Map type +""" scalar Map """ An object with an ID. Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) """ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder") { - """The id of the object.""" + """ + The id of the object. + """ id: ID! } type OneToMany implements Node { @@ -1439,30 +1695,48 @@ type OneToMany implements Node { parent: OneToMany children: [OneToMany!] } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type OneToManyList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [OneToMany]! } -"""Ordering options for OneToMany connections""" +""" +Ordering options for OneToMany connections +""" input OneToManyOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" + """ + The field by which to order OneToManies. + """ field: OneToManyOrderField! } -"""Properties by which OneToMany connections can be ordered.""" +""" +Properties by which OneToMany connections can be ordered. +""" enum OneToManyOrderField { NAME } -"""OneToManyWhereInput is used for filtering OneToMany objects.""" +""" +OneToManyWhereInput is used for filtering OneToMany objects. +""" input OneToManyWhereInput { not: OneToManyWhereInput and: [OneToManyWhereInput!] or: [OneToManyWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1471,7 +1745,9 @@ input OneToManyWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1485,7 +1761,9 @@ input OneToManyWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """field2 field predicates""" + """ + field2 field predicates + """ field2: String field2NEQ: String field2In: [String!] @@ -1501,56 +1779,125 @@ input OneToManyWhereInput { field2NotNil: Boolean field2EqualFold: String field2ContainsFold: String - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [OneToManyWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [OneToManyWhereInput!] } -"""Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument.""" +""" +Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument. +""" enum OrderDirection { - """Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument.""" + """ + Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument. + """ ASC - """Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument.""" + """ + Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument. + """ DESC } +type Organization implements Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Workspace") { + id: ID! + name: String! +} +""" +OrganizationWhereInput is used for filtering Workspace objects. +""" +input OrganizationWhereInput { + not: OrganizationWhereInput + and: [OrganizationWhereInput!] + or: [OrganizationWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String +} """ Information about pagination in a connection. https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo """ type PageInfo { - """When paginating forwards, are there more items?""" + """ + When paginating forwards, are there more items? + """ hasNextPage: Boolean! - """When paginating backwards, are there more items?""" + """ + When paginating backwards, are there more items? + """ hasPreviousPage: Boolean! - """When paginating backwards, the cursor to continue.""" + """ + When paginating backwards, the cursor to continue. + """ startCursor: Cursor - """When paginating forwards, the cursor to continue.""" + """ + When paginating forwards, the cursor to continue. + """ endCursor: Cursor } type Project implements Node { id: ID! todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList } -"""ProjectWhereInput is used for filtering Project objects.""" +""" +ProjectWhereInput is used for filtering Project objects. +""" input ProjectWhereInput { not: ProjectWhereInput and: [ProjectWhereInput!] or: [ProjectWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1559,87 +1906,139 @@ input ProjectWhereInput { idGTE: ID idLT: ID idLTE: ID - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] } type Query { - """Fetches an object given its ID.""" + """ + Fetches an object given its ID. + """ node( - """ID of the object.""" + """ + ID of the object. + """ id: ID! ): Node - """Lookup nodes by a list of IDs.""" + """ + Lookup nodes by a list of IDs. + """ nodes( - """The list of node IDs.""" + """ + The list of node IDs. + """ ids: [ID!]! ): [Node]! billProducts: [BillProduct!]! categories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList oneToMany( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for OneToManies returned from the connection.""" + """ + Ordering options for OneToManies returned from the connection. + """ orderBy: OneToManyOrder - """Filtering options for OneToManies returned from the connection.""" + """ + Filtering options for OneToManies returned from the connection. + """ where: OneToManyWhereInput ): OneToManyList - """This is the todo item""" + """ + This is the todo item + """ todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""The builtin Time type""" +""" +The builtin Time type +""" scalar Time type Todo implements Node { id: ID! @@ -1653,39 +2052,65 @@ type Todo implements Node { init: Map custom: [Custom!] customp: [Custom] - """Todo parent""" + """ + Todo parent + """ parent: Todo - """Todo children""" + """ + Todo children + """ children( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList category: Category } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type TodoList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Todo]! } -"""Ordering options for Todo connections""" +""" +Ordering options for Todo connections +""" input TodoOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Todos.""" + """ + The field by which to order Todos. + """ field: TodoOrderField! } -"""Properties by which Todo connections can be ordered.""" +""" +Properties by which Todo connections can be ordered. +""" enum TodoOrderField { CREATED_AT STATUS @@ -1695,18 +2120,24 @@ enum TodoOrderField { CHILDREN_COUNT CATEGORY_TEXT } -"""TodoStatus is enum for the field status""" +""" +TodoStatus is enum for the field status +""" enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { IN_PROGRESS COMPLETED PENDING } -"""TodoWhereInput is used for filtering Todo objects.""" +""" +TodoWhereInput is used for filtering Todo objects. +""" input TodoWhereInput { not: TodoWhereInput and: [TodoWhereInput!] or: [TodoWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1715,7 +2146,9 @@ input TodoWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -1724,12 +2157,16 @@ input TodoWhereInput { createdAtGTE: Time createdAtLT: Time createdAtLTE: Time - """status field predicates""" + """ + status field predicates + """ status: TodoStatus statusNEQ: TodoStatus statusIn: [TodoStatus!] statusNotIn: [TodoStatus!] - """priority field predicates""" + """ + priority field predicates + """ priority: Int priorityNEQ: Int priorityIn: [Int!] @@ -1738,7 +2175,9 @@ input TodoWhereInput { priorityGTE: Int priorityLT: Int priorityLTE: Int - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -1752,31 +2191,45 @@ input TodoWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """category_id field predicates""" + """ + category_id field predicates + """ categoryID: ID categoryIDNEQ: ID categoryIDIn: [ID!] categoryIDNotIn: [ID!] categoryIDIsNil: Boolean categoryIDNotNil: Boolean - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [TodoWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [TodoWhereInput!] - """category edge predicates""" + """ + category edge predicates + """ hasCategory: Boolean hasCategoryWith: [CategoryWhereInput!] } -"""The builtin Uint64 type""" +""" +The builtin Uint64 type +""" scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" +""" +UpdateCategoryInput is used for update Category object. +""" input UpdateCategoryInput { text: String status: CategoryStatus config: CategoryConfigInput clearConfig: Boolean + types: CategoryTypesInput + clearTypes: Boolean duration: Duration clearDuration: Boolean count: Uint64 @@ -1791,13 +2244,17 @@ input UpdateCategoryInput { removeSubCategoryIDs: [ID!] clearSubCategories: Boolean } -"""UpdateFriendshipInput is used for update Friendship object.""" +""" +UpdateFriendshipInput is used for update Friendship object. +""" input UpdateFriendshipInput { createdAt: Time userID: ID friendID: ID } -"""UpdateTodoInput is used for update Todo object.""" +""" +UpdateTodoInput is used for update Todo object. +""" input UpdateTodoInput { status: TodoStatus priority: Int @@ -1812,12 +2269,15 @@ input UpdateTodoInput { secretID: ID clearSecret: Boolean } -"""UpdateUserInput is used for update User object.""" +""" +UpdateUserInput is used for update User object. +""" input UpdateUserInput { name: String username: UUID password: String clearPassword: Boolean + requiredMetadata: Map metadata: Map clearMetadata: Boolean addGroupIDs: [ID!] @@ -1831,66 +2291,107 @@ type User implements Node { id: ID! name: String! username: UUID! + requiredMetadata: Map! metadata: Map - """The groups of the user""" + """ + The groups of the user + """ groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList friends( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList friendships( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Friendships returned from the connection.""" + """ + Filtering options for Friendships returned from the connection. + """ where: FriendshipWhereInput ): FriendshipList } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type UserList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [User]! } -"""Ordering options for User connections""" +""" +Ordering options for User connections +""" input UserOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Users.""" + """ + The field by which to order Users. + """ field: UserOrderField! } -"""Properties by which User connections can be ordered.""" +""" +Properties by which User connections can be ordered. +""" enum UserOrderField { GROUPS_COUNT } -"""UserWhereInput is used for filtering User objects.""" +""" +UserWhereInput is used for filtering User objects. +""" input UserWhereInput { not: UserWhereInput and: [UserWhereInput!] or: [UserWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -1899,7 +2400,9 @@ input UserWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -1913,7 +2416,9 @@ input UserWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """username field predicates""" + """ + username field predicates + """ username: UUID usernameNEQ: UUID usernameIn: [UUID!] @@ -1922,13 +2427,19 @@ input UserWhereInput { usernameGTE: UUID usernameLT: UUID usernameLTE: UUID - """groups edge predicates""" + """ + groups edge predicates + """ hasGroups: Boolean hasGroupsWith: [GroupWhereInput!] - """friends edge predicates""" + """ + friends edge predicates + """ hasFriends: Boolean hasFriendsWith: [UserWhereInput!] - """friendships edge predicates""" + """ + friendships edge predicates + """ hasFriendships: Boolean hasFriendshipsWith: [FriendshipWhereInput!] } @@ -2018,10 +2529,10 @@ func (ec *executionContext) field_Category_todos_args(ctx context.Context, rawAr } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2180,10 +2691,10 @@ func (ec *executionContext) field_Project_todos_args(ctx context.Context, rawArg } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2363,6 +2874,48 @@ func (ec *executionContext) field_Query_oneToMany_args(ctx context.Context, rawA return args, nil } +func (ec *executionContext) field_Query_todosWithJoins_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["offset"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset")) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["offset"] = arg1 + var arg2 []*ent.TodoOrder + if tmp, ok := rawArgs["orderBy"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["orderBy"] = arg2 + var arg3 *ent.TodoWhereInput + if tmp, ok := rawArgs["where"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) + arg3, err = ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["where"] = arg3 + return args, nil +} + func (ec *executionContext) field_Query_todos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2384,10 +2937,10 @@ func (ec *executionContext) field_Query_todos_args(ctx context.Context, rawArgs } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2468,10 +3021,10 @@ func (ec *executionContext) field_Todo_children_args(ctx context.Context, rawArg } } args["offset"] = arg1 - var arg2 *ent.TodoOrder + var arg2 []*ent.TodoOrder if tmp, ok := rawArgs["orderBy"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg2, err = ec.unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrder(ctx, tmp) + arg2, err = ec.unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderᚄ(ctx, tmp) if err != nil { return nil, err } @@ -2988,6 +3541,51 @@ func (ec *executionContext) fieldContext_Category_config(ctx context.Context, fi return fc, nil } +func (ec *executionContext) _Category_types(ctx context.Context, field graphql.CollectedField, obj *ent.Category) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Category_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Category().Types(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*CategoryTypes) + fc.Result = res + return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypes(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Category_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Category", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "public": + return ec.fieldContext_CategoryTypes_public(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CategoryTypes", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Category_duration(ctx context.Context, field graphql.CollectedField, obj *ent.Category) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Category_duration(ctx, field) if err != nil { @@ -3125,7 +3723,7 @@ func (ec *executionContext) _Category_todos(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Todos(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -3164,7 +3762,7 @@ func (ec *executionContext) fieldContext_Category_todos(ctx context.Context, fie ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Category_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3222,7 +3820,7 @@ func (ec *executionContext) fieldContext_Category_subCategories(ctx context.Cont ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Category_subCategories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -3400,6 +3998,8 @@ func (ec *executionContext) fieldContext_CategoryList_items(ctx context.Context, return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -3419,6 +4019,47 @@ func (ec *executionContext) fieldContext_CategoryList_items(ctx context.Context, return fc, nil } +func (ec *executionContext) _CategoryTypes_public(ctx context.Context, field graphql.CollectedField, obj *CategoryTypes) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CategoryTypes_public(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Public, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CategoryTypes_public(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CategoryTypes", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Custom_info(ctx context.Context, field graphql.CollectedField, obj *customstruct.Custom) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Custom_info(ctx, field) if err != nil { @@ -3684,6 +4325,8 @@ func (ec *executionContext) fieldContext_Friendship_user(ctx context.Context, fi return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -3744,6 +4387,8 @@ func (ec *executionContext) fieldContext_Friendship_friend(ctx context.Context, return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -4002,7 +4647,7 @@ func (ec *executionContext) fieldContext_Group_users(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Group_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4174,6 +4819,8 @@ func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Con return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -4199,7 +4846,7 @@ func (ec *executionContext) fieldContext_Mutation_createCategory(ctx context.Con ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createCategory_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4286,7 +4933,7 @@ func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4373,7 +5020,7 @@ func (ec *executionContext) fieldContext_Mutation_updateTodo(ctx context.Context ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4486,7 +5133,7 @@ func (ec *executionContext) fieldContext_Mutation_updateFriendship(ctx context.C ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateFriendship_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -4826,6 +5473,94 @@ func (ec *executionContext) fieldContext_OneToManyList_items(ctx context.Context return fc, nil } +func (ec *executionContext) _Organization_id(ctx context.Context, field graphql.CollectedField, obj *ent1.Workspace) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Organization().ID(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(uuid.UUID) + fc.Result = res + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Organization_name(ctx context.Context, field graphql.CollectedField, obj *ent1.Workspace) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Organization_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Organization_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Organization", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[uuid.UUID]) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { @@ -5093,7 +5828,7 @@ func (ec *executionContext) fieldContext_Project_todos(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Project_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5145,7 +5880,7 @@ func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5200,7 +5935,7 @@ func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5312,7 +6047,7 @@ func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_categories_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5370,7 +6105,7 @@ func (ec *executionContext) fieldContext_Query_groups(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_groups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5428,7 +6163,7 @@ func (ec *executionContext) fieldContext_Query_oneToMany(ctx context.Context, fi ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_oneToMany_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5447,7 +6182,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Todos(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return ec.resolvers.Query().Todos(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5486,7 +6221,7 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_todos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5544,7 +6279,7 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -5593,8 +6328,8 @@ func (ec *executionContext) fieldContext_Query_ping(ctx context.Context, field g return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _Query_todosWithJoins(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_todosWithJoins(ctx, field) if err != nil { return graphql.Null } @@ -5607,7 +6342,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return ec.resolvers.Query().TodosWithJoins(rctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -5616,21 +6351,79 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*ent.TodoList) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOTodoList2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoList(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_todosWithJoins(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) + case "totalCount": + return ec.fieldContext_TodoList_totalCount(ctx, field) + case "items": + return ec.fieldContext_TodoList_items(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TodoList", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_todosWithJoins_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) case "name": return ec.fieldContext___Type_name(ctx, field) case "description": @@ -5662,7 +6455,7 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6283,7 +7076,7 @@ func (ec *executionContext) _Todo_children(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Children(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].(*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) + return obj.Children(ctx, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["orderBy"].([]*ent.TodoOrder), fc.Args["where"].(*ent.TodoWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -6322,7 +7115,7 @@ func (ec *executionContext) fieldContext_Todo_children(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Todo_children_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6371,6 +7164,8 @@ func (ec *executionContext) fieldContext_Todo_category(ctx context.Context, fiel return ec.fieldContext_Category_status(ctx, field) case "config": return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) case "duration": return ec.fieldContext_Category_duration(ctx, field) case "count": @@ -6683,6 +7478,50 @@ func (ec *executionContext) fieldContext_User_username(ctx context.Context, fiel return fc, nil } +func (ec *executionContext) _User_requiredMetadata(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_requiredMetadata(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RequiredMetadata, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(map[string]interface{}) + fc.Result = res + return ec.marshalNMap2map(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_requiredMetadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Map does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_metadata(ctx, field) if err != nil { @@ -6777,7 +7616,7 @@ func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_groups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6835,7 +7674,7 @@ func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_friends_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6893,7 +7732,7 @@ func (ec *executionContext) fieldContext_User_friendships(ctx context.Context, f ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_friendships_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -6987,6 +7826,8 @@ func (ec *executionContext) fieldContext_UserList_items(ctx context.Context, fie return ec.fieldContext_User_name(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) case "metadata": return ec.fieldContext_User_metadata(ctx, field) case "groups": @@ -8423,7 +9264,7 @@ func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, fiel ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -8611,7 +9452,7 @@ func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return + return fc, err } return fc, nil } @@ -8782,368 +9623,328 @@ func (ec *executionContext) unmarshalInputBillProductWhereInput(ctx context.Cont asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "sku", "skuNEQ", "skuIn", "skuNotIn", "skuGT", "skuGTE", "skuLT", "skuLTE", "skuContains", "skuHasPrefix", "skuHasSuffix", "skuEqualFold", "skuContainsFold", "quantity", "quantityNEQ", "quantityIn", "quantityNotIn", "quantityGT", "quantityGTE", "quantityLT", "quantityLTE"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOBillProductWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐBillProductWhereInput(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐBillProductWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐBillProductWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐBillProductWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐBillProductWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBillProductWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐBillProductWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "sku": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sku")) - it.Sku, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Sku = data case "skuNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuNEQ")) - it.SkuNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuNEQ = data case "skuIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuIn")) - it.SkuIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.SkuIn = data case "skuNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuNotIn")) - it.SkuNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.SkuNotIn = data case "skuGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuGT")) - it.SkuGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuGT = data case "skuGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuGTE")) - it.SkuGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuGTE = data case "skuLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuLT")) - it.SkuLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuLT = data case "skuLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuLTE")) - it.SkuLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuLTE = data case "skuContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuContains")) - it.SkuContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuContains = data case "skuHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuHasPrefix")) - it.SkuHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuHasPrefix = data case "skuHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuHasSuffix")) - it.SkuHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuHasSuffix = data case "skuEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuEqualFold")) - it.SkuEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuEqualFold = data case "skuContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("skuContainsFold")) - it.SkuContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.SkuContainsFold = data case "quantity": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantity")) - it.Quantity, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Quantity = data case "quantityNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityNEQ")) - it.QuantityNEQ, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityNEQ = data case "quantityIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityIn")) - it.QuantityIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.QuantityIn = data case "quantityNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityNotIn")) - it.QuantityNotIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.QuantityNotIn = data case "quantityGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityGT")) - it.QuantityGT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityGT = data case "quantityGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityGTE")) - it.QuantityGTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityGTE = data case "quantityLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityLT")) - it.QuantityLT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityLT = data case "quantityLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("quantityLTE")) - it.QuantityLTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.QuantityLTE = data } } @@ -9157,16 +9958,20 @@ func (ec *executionContext) unmarshalInputCategoryConfigInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"maxMembers"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "maxMembers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("maxMembers")) - it.MaxMembers, err = ec.unmarshalOInt2int(ctx, v) + data, err := ec.unmarshalOInt2int(ctx, v) if err != nil { return it, err } + it.MaxMembers = data } } @@ -9184,24 +9989,54 @@ func (ec *executionContext) unmarshalInputCategoryOrder(ctx context.Context, obj asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNCategoryOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryOrderField(ctx, v) + data, err := ec.unmarshalNCategoryOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCategoryTypesInput(ctx context.Context, obj interface{}) (CategoryTypesInput, error) { + var it CategoryTypesInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"public"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Public = data } } @@ -9215,504 +10050,447 @@ func (ec *executionContext) unmarshalInputCategoryWhereInput(ctx context.Context asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "text", "textNEQ", "textIn", "textNotIn", "textGT", "textGTE", "textLT", "textLTE", "textContains", "textHasPrefix", "textHasSuffix", "textEqualFold", "textContainsFold", "status", "statusNEQ", "statusIn", "statusNotIn", "config", "configNEQ", "configIn", "configNotIn", "configGT", "configGTE", "configLT", "configLTE", "configIsNil", "configNotNil", "duration", "durationNEQ", "durationIn", "durationNotIn", "durationGT", "durationGTE", "durationLT", "durationLTE", "durationIsNil", "durationNotNil", "count", "countNEQ", "countIn", "countNotIn", "countGT", "countGTE", "countLT", "countLTE", "countIsNil", "countNotNil", "hasTodos", "hasTodosWith", "hasSubCategories", "hasSubCategoriesWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInput(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "textNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNEQ")) - it.TextNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextNEQ = data case "textIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textIn")) - it.TextIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextIn = data case "textNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNotIn")) - it.TextNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextNotIn = data case "textGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGT")) - it.TextGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGT = data case "textGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGTE")) - it.TextGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGTE = data case "textLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLT")) - it.TextLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLT = data case "textLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLTE")) - it.TextLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLTE = data case "textContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContains")) - it.TextContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContains = data case "textHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasPrefix")) - it.TextHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasPrefix = data case "textHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasSuffix")) - it.TextHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasSuffix = data case "textEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textEqualFold")) - it.TextEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextEqualFold = data case "textContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContainsFold")) - it.TextContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContainsFold = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "statusNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) - it.StatusNEQ, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.StatusNEQ = data case "statusIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) - it.StatusIn, err = ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusIn = data case "statusNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) - it.StatusNotIn, err = ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatusᚄ(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatusᚄ(ctx, v) if err != nil { return it, err } + it.StatusNotIn = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.Config = data case "configNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNEQ")) - it.ConfigNEQ, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigNEQ = data case "configIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configIn")) - it.ConfigIn, err = ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) if err != nil { return it, err } + it.ConfigIn = data case "configNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNotIn")) - it.ConfigNotIn, err = ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx, v) if err != nil { return it, err } + it.ConfigNotIn = data case "configGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configGT")) - it.ConfigGT, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigGT = data case "configGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configGTE")) - it.ConfigGTE, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigGTE = data case "configLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configLT")) - it.ConfigLT, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigLT = data case "configLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configLTE")) - it.ConfigLTE, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.ConfigLTE = data case "configIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configIsNil")) - it.ConfigIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ConfigIsNil = data case "configNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("configNotNil")) - it.ConfigNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ConfigNotNil = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "durationNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNEQ")) - it.DurationNEQ, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationNEQ = data case "durationIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationIn")) - it.DurationIn, err = ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) + data, err := ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) if err != nil { return it, err } + it.DurationIn = data case "durationNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNotIn")) - it.DurationNotIn, err = ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) + data, err := ec.unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx, v) if err != nil { return it, err } + it.DurationNotIn = data case "durationGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationGT")) - it.DurationGT, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationGT = data case "durationGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationGTE")) - it.DurationGTE, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationGTE = data case "durationLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationLT")) - it.DurationLT, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationLT = data case "durationLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationLTE")) - it.DurationLTE, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.DurationLTE = data case "durationIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationIsNil")) - it.DurationIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.DurationIsNil = data case "durationNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("durationNotNil")) - it.DurationNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.DurationNotNil = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "countNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNEQ")) - it.CountNEQ, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountNEQ = data case "countIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countIn")) - it.CountIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.CountIn = data case "countNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNotIn")) - it.CountNotIn, err = ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } + it.CountNotIn = data case "countGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countGT")) - it.CountGT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountGT = data case "countGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countGTE")) - it.CountGTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountGTE = data case "countLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countLT")) - it.CountLT, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountLT = data case "countLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countLTE")) - it.CountLTE, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.CountLTE = data case "countIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countIsNil")) - it.CountIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CountIsNil = data case "countNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("countNotNil")) - it.CountNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CountNotNil = data case "hasTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) - it.HasTodos, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasTodos = data case "hasTodosWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) - it.HasTodosWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasTodosWith = data case "hasSubCategories": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSubCategories")) - it.HasSubCategories, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasSubCategories = data case "hasSubCategoriesWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSubCategoriesWith")) - it.HasSubCategoriesWith, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasSubCategoriesWith = data } } @@ -9726,75 +10504,79 @@ func (ec *executionContext) unmarshalInputCreateCategoryInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"text", "status", "config", "types", "duration", "count", "strings", "todoIDs", "subCategoryIDs", "createTodos"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalNCategoryStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalNCategoryStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + if err != nil { + return it, err + } + it.Config = data + case "types": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("types")) + data, err := ec.unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypesInput(ctx, v) if err != nil { return it, err } + if err = ec.resolvers.CreateCategoryInput().Types(ctx, &it, data); err != nil { + return it, err + } case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "strings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strings")) - it.Strings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Strings = data case "todoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("todoIDs")) - it.TodoIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.TodoIDs = data case "subCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subCategoryIDs")) - it.SubCategoryIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.SubCategoryIDs = data case "createTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTodos")) data, err := ec.unmarshalOCreateTodoInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCreateTodoInputᚄ(ctx, v) if err != nil { @@ -9816,11 +10598,14 @@ func (ec *executionContext) unmarshalInputCreateTodoInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "init", "parentID", "childIDs", "categoryID", "secretID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalNTodoStatus2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -9830,61 +10615,54 @@ func (ec *executionContext) unmarshalInputCreateTodoInput(ctx context.Context, o return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } + it.Text = data case "init": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("init")) - it.Init, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Init = data case "parentID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) - it.ParentID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ParentID = data case "childIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("childIDs")) - it.ChildIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.ChildIDs = data case "categoryID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryID")) - it.CategoryID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.CategoryID = data case "secretID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretID")) - it.SecretID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.SecretID = data } } @@ -9898,19 +10676,21 @@ func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "username", "password", "requiredMetadata", "metadata", "groupIDs", "friendIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -9920,37 +10700,40 @@ func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, o return it, err } case "password": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Password = data + case "requiredMetadata": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requiredMetadata")) + data, err := ec.unmarshalNMap2map(ctx, v) + if err != nil { + return it, err + } + it.RequiredMetadata = data case "metadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadata")) - it.Metadata, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Metadata = data case "groupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIDs")) - it.GroupIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.GroupIDs = data case "friendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("friendIDs")) - it.FriendIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.FriendIDs = data } } @@ -9964,160 +10747,146 @@ func (ec *executionContext) unmarshalInputFriendshipWhereInput(ctx context.Conte asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendshipWhereInput(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendshipWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "createdAt": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAt = data case "createdAtNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtNEQ = data case "createdAtIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtIn = data case "createdAtNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtNotIn = data case "createdAtGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGT = data case "createdAtGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGTE = data case "createdAtLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLT = data case "createdAtLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLTE = data } } @@ -10131,216 +10900,195 @@ func (ec *executionContext) unmarshalInputGroupWhereInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasUsers", "hasUsersWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroupWhereInput(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroupWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "hasUsers": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUsers")) - it.HasUsers, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasUsers = data case "hasUsersWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUsersWith")) - it.HasUsersWith, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasUsersWith = data } } @@ -10358,24 +11106,27 @@ func (ec *executionContext) unmarshalInputOneToManyOrder(ctx context.Context, ob asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNOneToManyOrderField2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyOrderField(ctx, v) + data, err := ec.unmarshalNOneToManyOrderField2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -10389,676 +11140,805 @@ func (ec *executionContext) unmarshalInputOneToManyWhereInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "field2", "field2NEQ", "field2In", "field2NotIn", "field2GT", "field2GTE", "field2LT", "field2LTE", "field2Contains", "field2HasPrefix", "field2HasSuffix", "field2IsNil", "field2NotNil", "field2EqualFold", "field2ContainsFold", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInput(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNeq, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGt, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGte, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLt, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLte, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLte = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNeq, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNeq = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGt = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGte = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLt = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLte = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "field2": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2")) - it.Field2, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2 = data case "field2NEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NEQ")) - it.Field2neq, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2neq = data case "field2In": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2In")) - it.Field2In, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Field2In = data case "field2NotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NotIn")) - it.Field2NotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Field2NotIn = data case "field2GT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2GT")) - it.Field2gt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2gt = data case "field2GTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2GTE")) - it.Field2gte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2gte = data case "field2LT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2LT")) - it.Field2lt, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2lt = data case "field2LTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2LTE")) - it.Field2lte, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2lte = data case "field2Contains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2Contains")) - it.Field2Contains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2Contains = data case "field2HasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2HasPrefix")) - it.Field2HasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2HasPrefix = data case "field2HasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2HasSuffix")) - it.Field2HasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2HasSuffix = data case "field2IsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2IsNil")) - it.Field2IsNil, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Field2IsNil = data case "field2NotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2NotNil")) - it.Field2NotNil, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.Field2NotNil = data case "field2EqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2EqualFold")) - it.Field2EqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2EqualFold = data case "field2ContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field2ContainsFold")) - it.Field2ContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Field2ContainsFold = data case "hasParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParent")) - it.HasParent, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasParent = data case "hasParentWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParentWith")) - it.HasParentWith, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasParentWith = data case "hasChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildren")) - it.HasChildren, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasChildren = data case "hasChildrenWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildrenWith")) - it.HasChildrenWith, err = ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOneToManyWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasChildrenWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputProjectWhereInput(ctx context.Context, obj interface{}) (ProjectWhereInput, error) { - var it ProjectWhereInput +func (ec *executionContext) unmarshalInputOrganizationWhereInput(ctx context.Context, obj interface{}) (OrganizationWhereInput, error) { + var it OrganizationWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐProjectWhereInput(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOrganizationWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐProjectWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOrganizationWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐProjectWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOrganizationWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNeq, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGt, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGte, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLt, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLte, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } - case "hasTodos": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) - it.HasTodos, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.IDLte = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "hasTodosWith": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) - it.HasTodosWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj interface{}) (ent.TodoOrder, error) { - var it ent.TodoOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - for k, v := range asMap { - switch k { - case "direction": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + it.NameNeq = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - case "field": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderField(ctx, v) + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGt = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGte = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLt = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLte = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data } } return it, nil } -func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, obj interface{}) (ent.TodoWhereInput, error) { - var it ent.TodoWhereInput +func (ec *executionContext) unmarshalInputProjectWhereInput(ctx context.Context, obj interface{}) (ProjectWhereInput, error) { + var it ProjectWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "hasTodos", "hasTodosWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInput(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐProjectWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐProjectWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐProjectWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDNeq = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGt = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGte = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLt = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } - case "createdAt": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.IDLte = data + case "hasTodos": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodos")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - case "createdAtNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - it.CreatedAtNEQ, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + it.HasTodos = data + case "hasTodosWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTodosWith")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } - case "createdAtIn": - var err error + it.HasTodosWith = data + } + } - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - it.CreatedAtIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + return it, nil +} + +func (ec *executionContext) unmarshalInputTodoOrder(ctx context.Context, obj interface{}) (ent.TodoOrder, error) { + var it ent.TodoOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - case "createdAtNotIn": - var err error + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, obj interface{}) (ent.TodoWhereInput, error) { + var it ent.TodoWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "status", "statusNEQ", "statusIn", "statusNotIn", "priority", "priorityNEQ", "priorityIn", "priorityNotIn", "priorityGT", "priorityGTE", "priorityLT", "priorityLTE", "text", "textNEQ", "textIn", "textNotIn", "textGT", "textGTE", "textLT", "textLTE", "textContains", "textHasPrefix", "textHasSuffix", "textEqualFold", "textContainsFold", "categoryID", "categoryIDNEQ", "categoryIDIn", "categoryIDNotIn", "categoryIDIsNil", "categoryIDNotNil", "hasParent", "hasParentWith", "hasChildren", "hasChildrenWith", "hasCategory", "hasCategoryWith", "createdToday"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOTodoWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - it.CreatedAtNotIn, err = ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } + it.CreatedAtNotIn = data case "createdAtGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - it.CreatedAtGT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGT = data case "createdAtGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - it.CreatedAtGTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtGTE = data case "createdAtLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - it.CreatedAtLT, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLT = data case "createdAtLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - it.CreatedAtLTE, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAtLTE = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11068,8 +11948,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11079,8 +11957,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) data, err := ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) if err != nil { @@ -11090,8 +11966,6 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "statusNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) data, err := ec.unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx, v) if err != nil { @@ -11101,272 +11975,237 @@ func (ec *executionContext) unmarshalInputTodoWhereInput(ctx context.Context, ob return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "priorityNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityNEQ")) - it.PriorityNEQ, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityNEQ = data case "priorityIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityIn")) - it.PriorityIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.PriorityIn = data case "priorityNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityNotIn")) - it.PriorityNotIn, err = ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } + it.PriorityNotIn = data case "priorityGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityGT")) - it.PriorityGT, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityGT = data case "priorityGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityGTE")) - it.PriorityGTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityGTE = data case "priorityLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityLT")) - it.PriorityLT, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityLT = data case "priorityLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priorityLTE")) - it.PriorityLTE, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.PriorityLTE = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "textNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNEQ")) - it.TextNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextNEQ = data case "textIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textIn")) - it.TextIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextIn = data case "textNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textNotIn")) - it.TextNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.TextNotIn = data case "textGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGT")) - it.TextGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGT = data case "textGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textGTE")) - it.TextGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextGTE = data case "textLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLT")) - it.TextLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLT = data case "textLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textLTE")) - it.TextLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextLTE = data case "textContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContains")) - it.TextContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContains = data case "textHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasPrefix")) - it.TextHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasPrefix = data case "textHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textHasSuffix")) - it.TextHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextHasSuffix = data case "textEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textEqualFold")) - it.TextEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextEqualFold = data case "textContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("textContainsFold")) - it.TextContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.TextContainsFold = data case "categoryID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryID")) - it.CategoryID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.CategoryID = data case "categoryIDNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNEQ")) - it.CategoryIDNEQ, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.CategoryIDNEQ = data case "categoryIDIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDIn")) - it.CategoryIDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.CategoryIDIn = data case "categoryIDNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNotIn")) - it.CategoryIDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.CategoryIDNotIn = data case "categoryIDIsNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDIsNil")) - it.CategoryIDIsNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CategoryIDIsNil = data case "categoryIDNotNil": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("categoryIDNotNil")) - it.CategoryIDNotNil, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.CategoryIDNotNil = data case "hasParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParent")) - it.HasParent, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasParent = data case "hasParentWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasParentWith")) - it.HasParentWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasParentWith = data case "hasChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildren")) - it.HasChildren, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasChildren = data case "hasChildrenWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasChildrenWith")) - it.HasChildrenWith, err = ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOTodoWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasChildrenWith = data case "hasCategory": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCategory")) - it.HasCategory, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasCategory = data case "hasCategoryWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCategoryWith")) - it.HasCategoryWith, err = ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasCategoryWith = data case "createdToday": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdToday")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { @@ -11388,144 +12227,148 @@ func (ec *executionContext) unmarshalInputUpdateCategoryInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"text", "status", "config", "clearConfig", "types", "clearTypes", "duration", "clearDuration", "count", "clearCount", "strings", "appendStrings", "clearStrings", "addTodoIDs", "removeTodoIDs", "clearTodos", "addSubCategoryIDs", "removeSubCategoryIDs", "clearSubCategories"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - it.Status, err = ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatus(ctx, v) + data, err := ec.unmarshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚋcategoryᚐStatus(ctx, v) if err != nil { return it, err } + it.Status = data case "config": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("config")) - it.Config, err = ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) + data, err := ec.unmarshalOCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, v) if err != nil { return it, err } + it.Config = data case "clearConfig": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearConfig")) - it.ClearConfig, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearConfig = data + case "types": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("types")) + data, err := ec.unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypesInput(ctx, v) if err != nil { return it, err } + if err = ec.resolvers.UpdateCategoryInput().Types(ctx, &it, data); err != nil { + return it, err + } + case "clearTypes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTypes")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearTypes = data case "duration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("duration")) - it.Duration, err = ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) + data, err := ec.unmarshalODuration2ᚖtimeᚐDuration(ctx, v) if err != nil { return it, err } + it.Duration = data case "clearDuration": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearDuration")) - it.ClearDuration, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearDuration = data case "count": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("count")) - it.Count, err = ec.unmarshalOUint642ᚖuint64(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } + it.Count = data case "clearCount": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearCount")) - it.ClearCount, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearCount = data case "strings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strings")) - it.Strings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.Strings = data case "appendStrings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("appendStrings")) - it.AppendStrings, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.AppendStrings = data case "clearStrings": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearStrings")) - it.ClearStrings, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearStrings = data case "addTodoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addTodoIDs")) - it.AddTodoIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.AddTodoIDs = data case "removeTodoIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeTodoIDs")) - it.RemoveTodoIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveTodoIDs = data case "clearTodos": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearTodos")) - it.ClearTodos, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearTodos = data case "addSubCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addSubCategoryIDs")) - it.AddSubCategoryIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.AddSubCategoryIDs = data case "removeSubCategoryIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeSubCategoryIDs")) - it.RemoveSubCategoryIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveSubCategoryIDs = data case "clearSubCategories": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSubCategories")) - it.ClearSubCategories, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearSubCategories = data } } @@ -11539,32 +12382,34 @@ func (ec *executionContext) unmarshalInputUpdateFriendshipInput(ctx context.Cont asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"createdAt", "userID", "friendID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "createdAt": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - it.CreatedAt, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } + it.CreatedAt = data case "userID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - it.UserID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.UserID = data case "friendID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("friendID")) - it.FriendID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.FriendID = data } } @@ -11578,11 +12423,14 @@ func (ec *executionContext) unmarshalInputUpdateTodoInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"status", "priority", "text", "init", "clearInit", "parentID", "clearParent", "addChildIDs", "removeChildIDs", "clearChildren", "secretID", "clearSecret"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "status": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalOTodoStatus2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatus(ctx, v) if err != nil { @@ -11592,93 +12440,82 @@ func (ec *executionContext) unmarshalInputUpdateTodoInput(ctx context.Context, o return it, err } case "priority": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priority")) - it.Priority, err = ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } + it.Priority = data case "text": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) - it.Text, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Text = data case "init": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("init")) - it.Init, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Init = data case "clearInit": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearInit")) - it.ClearInit, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearInit = data case "parentID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) - it.ParentID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ParentID = data case "clearParent": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearParent")) - it.ClearParent, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearParent = data case "addChildIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addChildIDs")) - it.AddChildIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.AddChildIDs = data case "removeChildIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeChildIDs")) - it.RemoveChildIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveChildIDs = data case "clearChildren": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearChildren")) - it.ClearChildren, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearChildren = data case "secretID": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secretID")) - it.SecretID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.SecretID = data case "clearSecret": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearSecret")) - it.ClearSecret, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearSecret = data } } @@ -11692,19 +12529,21 @@ func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, o asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "username", "password", "clearPassword", "requiredMetadata", "metadata", "clearMetadata", "addGroupIDs", "removeGroupIDs", "clearGroups", "addFriendIDs", "removeFriendIDs", "clearFriends"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -11714,85 +12553,82 @@ func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, o return it, err } case "password": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Password = data case "clearPassword": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearPassword")) - it.ClearPassword, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearPassword = data + case "requiredMetadata": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requiredMetadata")) + data, err := ec.unmarshalOMap2map(ctx, v) + if err != nil { + return it, err + } + it.RequiredMetadata = data case "metadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metadata")) - it.Metadata, err = ec.unmarshalOMap2map(ctx, v) + data, err := ec.unmarshalOMap2map(ctx, v) if err != nil { return it, err } + it.Metadata = data case "clearMetadata": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearMetadata")) - it.ClearMetadata, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearMetadata = data case "addGroupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addGroupIDs")) - it.AddGroupIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.AddGroupIDs = data case "removeGroupIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeGroupIDs")) - it.RemoveGroupIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveGroupIDs = data case "clearGroups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearGroups")) - it.ClearGroups, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearGroups = data case "addFriendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addFriendIDs")) - it.AddFriendIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.AddFriendIDs = data case "removeFriendIDs": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeFriendIDs")) - it.RemoveFriendIDs, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.RemoveFriendIDs = data case "clearFriends": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearFriends")) - it.ClearFriends, err = ec.unmarshalOBoolean2bool(ctx, v) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } + it.ClearFriends = data } } @@ -11810,24 +12646,27 @@ func (ec *executionContext) unmarshalInputUserOrder(ctx context.Context, obj int asMap["direction"] = "ASC" } - for k, v := range asMap { + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "direction": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - it.Direction, err = ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } + it.Direction = data case "field": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - it.Field, err = ec.unmarshalNUserOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserOrderField(ctx, v) + data, err := ec.unmarshalNUserOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserOrderField(ctx, v) if err != nil { return it, err } + it.Field = data } } @@ -11841,203 +12680,182 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "username", "usernameNEQ", "usernameIn", "usernameNotIn", "usernameGT", "usernameGTE", "usernameLT", "usernameLTE", "hasGroups", "hasGroupsWith", "hasFriends", "hasFriendsWith", "hasFriendships", "hasFriendshipsWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "not": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - it.Not, err = ec.unmarshalOUserWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInput(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInput(ctx, v) if err != nil { return it, err } + it.Not = data case "and": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - it.And, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.And = data case "or": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - it.Or, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.Or = data case "id": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.ID = data case "idNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - it.IDNEQ, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDNEQ = data case "idIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - it.IDIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDIn = data case "idNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - it.IDNotIn, err = ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } + it.IDNotIn = data case "idGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - it.IDGT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGT = data case "idGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - it.IDGTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDGTE = data case "idLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - it.IDLT, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLT = data case "idLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - it.IDLTE, err = ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } + it.IDLTE = data case "name": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - it.Name, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.Name = data case "nameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - it.NameNEQ, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameNEQ = data case "nameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - it.NameIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameIn = data case "nameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - it.NameNotIn, err = ec.unmarshalOString2ᚕstringᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } + it.NameNotIn = data case "nameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - it.NameGT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGT = data case "nameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - it.NameGTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameGTE = data case "nameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - it.NameLT, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLT = data case "nameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - it.NameLTE, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameLTE = data case "nameContains": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - it.NameContains, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContains = data case "nameHasPrefix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - it.NameHasPrefix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasPrefix = data case "nameHasSuffix": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - it.NameHasSuffix, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameHasSuffix = data case "nameEqualFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - it.NameEqualFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameEqualFold = data case "nameContainsFold": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - it.NameContainsFold, err = ec.unmarshalOString2ᚖstring(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } + it.NameContainsFold = data case "username": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12047,8 +12865,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameNEQ": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameNEQ")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12058,8 +12874,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameIn")) data, err := ec.unmarshalOUUID2ᚕstringᚄ(ctx, v) if err != nil { @@ -12069,8 +12883,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameNotIn": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameNotIn")) data, err := ec.unmarshalOUUID2ᚕstringᚄ(ctx, v) if err != nil { @@ -12080,8 +12892,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameGT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameGT")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12091,8 +12901,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameGTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameGTE")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12102,8 +12910,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameLT": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameLT")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12113,8 +12919,6 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "usernameLTE": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usernameLTE")) data, err := ec.unmarshalOUUID2ᚖstring(ctx, v) if err != nil { @@ -12124,53 +12928,47 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob return it, err } case "hasGroups": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasGroups")) - it.HasGroups, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasGroups = data case "hasGroupsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasGroupsWith")) - it.HasGroupsWith, err = ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroupWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOGroupWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroupWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasGroupsWith = data case "hasFriends": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriends")) - it.HasFriends, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasFriends = data case "hasFriendsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendsWith")) - it.HasFriendsWith, err = ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOUserWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUserWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasFriendsWith = data case "hasFriendships": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendships")) - it.HasFriendships, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } + it.HasFriendships = data case "hasFriendshipsWith": - var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFriendshipsWith")) - it.HasFriendshipsWith, err = ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendshipWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOFriendshipWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendshipWhereInputᚄ(ctx, v) if err != nil { return it, err } + it.HasFriendshipsWith = data } } @@ -12181,30 +12979,44 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob // region ************************** interface.gotpl *************************** -func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { +func (ec *executionContext) _NamedNode(ctx context.Context, sel ast.SelectionSet, obj NamedNode) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null - case *ent.BillProduct: + case *ent.Group: if obj == nil { return graphql.Null } - return ec._BillProduct(ctx, sel, obj) - case *ent.Category: + return ec._Group(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case *ent.Group: if obj == nil { return graphql.Null } - return ec._Category(ctx, sel, obj) - case *ent.Friendship: + return ec._Group(ctx, sel, obj) + case *ent.BillProduct: if obj == nil { return graphql.Null } - return ec._Friendship(ctx, sel, obj) - case *ent.Group: + return ec._BillProduct(ctx, sel, obj) + case *ent.Category: if obj == nil { return graphql.Null } - return ec._Group(ctx, sel, obj) + return ec._Category(ctx, sel, obj) + case *ent.Friendship: + if obj == nil { + return graphql.Null + } + return ec._Friendship(ctx, sel, obj) case OneToMany: return ec._OneToMany(ctx, sel, &obj) case *OneToMany: @@ -12212,6 +13024,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._OneToMany(ctx, sel, obj) + case *ent1.Workspace: + if obj == nil { + return graphql.Null + } + return ec._Organization(ctx, sel, obj) case Project: return ec._Project(ctx, sel, &obj) case *Project: @@ -12242,48 +13059,53 @@ var billProductImplementors = []string{"BillProduct", "Node"} func (ec *executionContext) _BillProduct(ctx context.Context, sel ast.SelectionSet, obj *ent.BillProduct) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, billProductImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("BillProduct") case "id": - out.Values[i] = ec._BillProduct_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec._BillProduct_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "sku": - out.Values[i] = ec._BillProduct_sku(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "quantity": - out.Values[i] = ec._BillProduct_quantity(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12291,53 +13113,73 @@ var categoryImplementors = []string{"Category", "Node"} func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, obj *ent.Category) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Category") case "id": - out.Values[i] = ec._Category_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Category_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "status": - out.Values[i] = ec._Category_status(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "config": - out.Values[i] = ec._Category_config(ctx, field, obj) + case "types": + field := field - case "duration": + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Category_types(ctx, field, obj) + return res + } - out.Values[i] = ec._Category_duration(ctx, field, obj) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - case "count": + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "duration": + out.Values[i] = ec._Category_duration(ctx, field, obj) + case "count": out.Values[i] = ec._Category_count(ctx, field, obj) - case "strings": - out.Values[i] = ec._Category_strings(ctx, field, obj) - case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12347,14 +13189,30 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "subCategories": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12364,14 +13222,30 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "todosCount": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12381,18 +13255,46 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12400,24 +13302,35 @@ var categoryConfigImplementors = []string{"CategoryConfig"} func (ec *executionContext) _CategoryConfig(ctx context.Context, sel ast.SelectionSet, obj *schematype.CategoryConfig) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryConfigImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryConfig") case "maxMembers": - out.Values[i] = ec._CategoryConfig_maxMembers(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12425,34 +13338,79 @@ var categoryListImplementors = []string{"CategoryList"} func (ec *executionContext) _CategoryList(ctx context.Context, sel ast.SelectionSet, obj *ent.CategoryList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, categoryListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CategoryList") case "totalCount": - out.Values[i] = ec._CategoryList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._CategoryList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var categoryTypesImplementors = []string{"CategoryTypes"} + +func (ec *executionContext) _CategoryTypes(ctx context.Context, sel ast.SelectionSet, obj *CategoryTypes) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, categoryTypesImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CategoryTypes") + case "public": + out.Values[i] = ec._CategoryTypes_public(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12460,27 +13418,38 @@ var customImplementors = []string{"Custom"} func (ec *executionContext) _Custom(ctx context.Context, sel ast.SelectionSet, obj *customstruct.Custom) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, customImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Custom") case "info": - out.Values[i] = ec._Custom_info(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12488,44 +13457,37 @@ var friendshipImplementors = []string{"Friendship", "Node"} func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSet, obj *ent.Friendship) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendshipImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Friendship") case "id": - out.Values[i] = ec._Friendship_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Friendship_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "userID": - out.Values[i] = ec._Friendship_userID(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "friendID": - out.Values[i] = ec._Friendship_friendID(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "user": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12533,19 +13495,35 @@ func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSe }() res = ec._Friendship_user(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friend": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12553,23 +13531,51 @@ func (ec *executionContext) _Friendship(ctx context.Context, sel ast.SelectionSe }() res = ec._Friendship_friend(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12577,65 +13583,71 @@ var friendshipListImplementors = []string{"FriendshipList"} func (ec *executionContext) _FriendshipList(ctx context.Context, sel ast.SelectionSet, obj *ent.FriendshipList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendshipListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FriendshipList") case "totalCount": - out.Values[i] = ec._FriendshipList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._FriendshipList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } -var groupImplementors = []string{"Group", "Node"} +var groupImplementors = []string{"Group", "Node", "NamedNode"} func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, obj *ent.Group) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, groupImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Group") case "id": - out.Values[i] = ec._Group_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._Group_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "users": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12645,18 +13657,46 @@ func (ec *executionContext) _Group(ctx context.Context, sel ast.SelectionSet, ob return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12664,34 +13704,43 @@ var groupListImplementors = []string{"GroupList"} func (ec *executionContext) _GroupList(ctx context.Context, sel ast.SelectionSet, obj *ent.GroupList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, groupListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("GroupList") case "totalCount": - out.Values[i] = ec._GroupList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._GroupList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12704,7 +13753,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -12715,58 +13764,60 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createCategory": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createCategory(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "createTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "updateTodo": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateTodo(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "clearTodos": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_clearTodos(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "updateFriendship": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateFriendship(ctx, field) }) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12774,46 +13825,49 @@ var oneToManyImplementors = []string{"OneToMany", "Node"} func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet, obj *OneToMany) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, oneToManyImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OneToMany") case "id": - out.Values[i] = ec._OneToMany_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec._OneToMany_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "field2": - out.Values[i] = ec._OneToMany_field2(ctx, field, obj) - case "parent": - out.Values[i] = ec._OneToMany_parent(ctx, field, obj) - case "children": - out.Values[i] = ec._OneToMany_children(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12821,34 +13875,118 @@ var oneToManyListImplementors = []string{"OneToManyList"} func (ec *executionContext) _OneToManyList(ctx context.Context, sel ast.SelectionSet, obj *OneToManyList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, oneToManyListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OneToManyList") case "totalCount": - out.Values[i] = ec._OneToManyList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._OneToManyList_items(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var organizationImplementors = []string{"Organization", "Node"} + +func (ec *executionContext) _Organization(ctx context.Context, sel ast.SelectionSet, obj *ent1.Workspace) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, organizationImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Organization") + case "id": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Organization_id(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "name": + out.Values[i] = ec._Organization_name(ctx, field, obj) if out.Values[i] == graphql.Null { - invalids++ + atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12856,42 +13994,47 @@ var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[uuid.UUID]) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12899,31 +14042,40 @@ var projectImplementors = []string{"Project", "Node"} func (ec *executionContext) _Project(ctx context.Context, sel ast.SelectionSet, obj *Project) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, projectImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Project") case "id": - out.Values[i] = ec._Project_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "todos": - out.Values[i] = ec._Project_todos(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -12936,7 +14088,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }) out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -12949,7 +14101,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "node": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12960,16 +14112,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nodes": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12977,22 +14128,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_nodes(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "billProducts": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13000,22 +14150,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_billProducts(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "categories": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13026,16 +14175,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "groups": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13046,16 +14194,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "oneToMany": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13066,16 +14213,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "todos": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13086,16 +14232,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "users": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13106,16 +14251,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "ping": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13123,38 +14267,64 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr }() res = ec._Query_ping(ctx, field) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "__type": + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "todosWithJoins": + field := field + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_todosWithJoins(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) - case "__schema": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13162,30 +14332,27 @@ var todoImplementors = []string{"Todo", "Node"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *ent.Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Todo_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "status": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13193,57 +14360,57 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj }() res = ec._Todo_status(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) - case "priorityOrder": + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "priorityOrder": out.Values[i] = ec._Todo_priorityOrder(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "categoryID": - out.Values[i] = ec._Todo_categoryID(ctx, field, obj) - case "category_id": - out.Values[i] = ec._Todo_category_id(ctx, field, obj) - case "categoryX": - out.Values[i] = ec._Todo_categoryX(ctx, field, obj) - case "init": - out.Values[i] = ec._Todo_init(ctx, field, obj) - case "custom": - out.Values[i] = ec._Todo_custom(ctx, field, obj) - case "customp": - out.Values[i] = ec._Todo_customp(ctx, field, obj) - case "parent": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13253,14 +14420,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "children": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13270,14 +14453,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "category": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13287,14 +14486,30 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "extendedField": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13304,18 +14519,46 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13323,34 +14566,43 @@ var todoListImplementors = []string{"TodoList"} func (ec *executionContext) _TodoList(ctx context.Context, sel ast.SelectionSet, obj *ent.TodoList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("TodoList") case "totalCount": - out.Values[i] = ec._TodoList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._TodoList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13358,30 +14610,27 @@ var userImplementors = []string{"User", "Node"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *ent.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&out.Invalids, 1) } case "username": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13389,23 +14638,42 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj }() res = ec._User_username(ctx, field, obj) if res == graphql.Null { - atomic.AddUint32(&invalids, 1) + atomic.AddUint32(&fs.Invalids, 1) } return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) - case "metadata": + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "requiredMetadata": + out.Values[i] = ec._User_requiredMetadata(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "metadata": out.Values[i] = ec._User_metadata(ctx, field, obj) - case "groups": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13415,14 +14683,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friends": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13432,14 +14716,30 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friendships": field := field - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -13449,18 +14749,46 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return res } - out.Concurrently(i, func() graphql.Marshaler { - return innerFunc(ctx) + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) - }) + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13468,34 +14796,43 @@ var userListImplementors = []string{"UserList"} func (ec *executionContext) _UserList(ctx context.Context, sel ast.SelectionSet, obj *ent.UserList) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userListImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("UserList") case "totalCount": - out.Values[i] = ec._UserList_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "items": - out.Values[i] = ec._UserList_items(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13503,52 +14840,55 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isRepeatable": - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13556,42 +14896,47 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13599,56 +14944,57 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13656,42 +15002,47 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13699,53 +15050,54 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "description": - out.Values[i] = ec.___Schema_description(ctx, field, obj) - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -13753,63 +15105,56 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) - var invalids uint32 + deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ + out.Invalids++ } case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - case "specifiedByURL": - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - default: panic("unknown field " + strconv.Quote(field.Name)) } } - out.Dispatch() - if invalids > 0 { + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + return out } @@ -14180,6 +15525,27 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } +func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + func (ec *executionContext) marshalNNode2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v []ent.Noder) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -14291,6 +15657,11 @@ func (ec *executionContext) marshalNOrderDirection2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) unmarshalNOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOrganizationWhereInput(ctx context.Context, v interface{}) (*OrganizationWhereInput, error) { + res, err := ec.unmarshalInputOrganizationWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNProjectWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐProjectWhereInput(ctx context.Context, v interface{}) (*ProjectWhereInput, error) { res, err := ec.unmarshalInputProjectWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -14410,6 +15781,11 @@ func (ec *executionContext) marshalNTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinte return ec._Todo(ctx, sel, v) } +func (ec *executionContext) unmarshalNTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrder(ctx context.Context, v interface{}) (*ent.TodoOrder, error) { + res, err := ec.unmarshalInputTodoOrder(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNTodoOrderField2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderField(ctx context.Context, v interface{}) (*ent.TodoOrderField, error) { var res = new(ent.TodoOrderField) err := res.UnmarshalGQL(v) @@ -15009,6 +16385,21 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } +func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypesInput(ctx context.Context, v interface{}) (*CategoryTypesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputCategoryTypesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOCategoryWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.CategoryWhereInput, error) { if v == nil { return nil, nil @@ -15564,6 +16955,34 @@ func (ec *executionContext) unmarshalOOneToManyWhereInput2ᚖentgoᚗioᚋcontri return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOOrganizationWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOrganizationWhereInputᚄ(ctx context.Context, v interface{}) ([]*OrganizationWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*OrganizationWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOrganizationWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOrganizationWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOrganizationWhereInput(ctx context.Context, v interface{}) (*OrganizationWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputOrganizationWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOProjectWhereInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐProjectWhereInputᚄ(ctx context.Context, v interface{}) ([]*ProjectWhereInput, error) { if v == nil { return nil, nil @@ -15714,12 +17133,24 @@ func (ec *executionContext) marshalOTodoList2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._TodoList(ctx, sel, v) } -func (ec *executionContext) unmarshalOTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrder(ctx context.Context, v interface{}) (*ent.TodoOrder, error) { +func (ec *executionContext) unmarshalOTodoOrder2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrderᚄ(ctx context.Context, v interface{}) ([]*ent.TodoOrder, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalInputTodoOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.TodoOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNTodoOrder2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodoOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil } func (ec *executionContext) unmarshalOTodoStatus2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋtodoᚐStatusᚄ(ctx context.Context, v interface{}) ([]todo.Status, error) { diff --git a/entgql/internal/todouuid/gqlgen.yml b/entgql/internal/todouuid/gqlgen.yml index 2eedd734d..eb37d943f 100644 --- a/entgql/internal/todouuid/gqlgen.yml +++ b/entgql/internal/todouuid/gqlgen.yml @@ -17,6 +17,8 @@ autobind: - entgo.io/contrib/entgql/internal/todouuid/ent/todo - entgo.io/contrib/entgql/internal/todo/ent/schema/customstruct +# Disable the generated getters for all models and interfaces. +omit_getters: true models: ID: model: diff --git a/entgql/internal/todouuid/models_gen.go b/entgql/internal/todouuid/models_gen.go index 5a953c241..bde9ce7d5 100644 --- a/entgql/internal/todouuid/models_gen.go +++ b/entgql/internal/todouuid/models_gen.go @@ -13,12 +13,24 @@ import ( "github.com/google/uuid" ) +type NamedNode interface { + IsNamedNode() +} + +type CategoryTypes struct { + Public *bool `json:"public,omitempty"` +} + +type CategoryTypesInput struct { + Public *bool `json:"public,omitempty"` +} + type OneToMany struct { ID uuid.UUID `json:"id"` Name string `json:"name"` - Field2 *string `json:"field2"` - Parent *OneToMany `json:"parent"` - Children []*OneToMany `json:"children"` + Field2 *string `json:"field2,omitempty"` + Parent *OneToMany `json:"parent,omitempty"` + Children []*OneToMany `json:"children,omitempty"` } func (OneToMany) IsNode() {} @@ -41,87 +53,117 @@ type OneToManyOrder struct { // OneToManyWhereInput is used for filtering OneToMany objects. type OneToManyWhereInput struct { - Not *OneToManyWhereInput `json:"not"` - And []*OneToManyWhereInput `json:"and"` - Or []*OneToManyWhereInput `json:"or"` + Not *OneToManyWhereInput `json:"not,omitempty"` + And []*OneToManyWhereInput `json:"and,omitempty"` + Or []*OneToManyWhereInput `json:"or,omitempty"` // id field predicates - ID *uuid.UUID `json:"id"` - IDNeq *uuid.UUID `json:"idNEQ"` - IDIn []uuid.UUID `json:"idIn"` - IDNotIn []uuid.UUID `json:"idNotIn"` - IDGt *uuid.UUID `json:"idGT"` - IDGte *uuid.UUID `json:"idGTE"` - IDLt *uuid.UUID `json:"idLT"` - IDLte *uuid.UUID `json:"idLTE"` + ID *uuid.UUID `json:"id,omitempty"` + IDNeq *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGt *uuid.UUID `json:"idGT,omitempty"` + IDGte *uuid.UUID `json:"idGTE,omitempty"` + IDLt *uuid.UUID `json:"idLT,omitempty"` + IDLte *uuid.UUID `json:"idLTE,omitempty"` // name field predicates - Name *string `json:"name"` - NameNeq *string `json:"nameNEQ"` - NameIn []string `json:"nameIn"` - NameNotIn []string `json:"nameNotIn"` - NameGt *string `json:"nameGT"` - NameGte *string `json:"nameGTE"` - NameLt *string `json:"nameLT"` - NameLte *string `json:"nameLTE"` - NameContains *string `json:"nameContains"` - NameHasPrefix *string `json:"nameHasPrefix"` - NameHasSuffix *string `json:"nameHasSuffix"` - NameEqualFold *string `json:"nameEqualFold"` - NameContainsFold *string `json:"nameContainsFold"` + Name *string `json:"name,omitempty"` + NameNeq *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGt *string `json:"nameGT,omitempty"` + NameGte *string `json:"nameGTE,omitempty"` + NameLt *string `json:"nameLT,omitempty"` + NameLte *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` // field2 field predicates - Field2 *string `json:"field2"` - Field2neq *string `json:"field2NEQ"` - Field2In []string `json:"field2In"` - Field2NotIn []string `json:"field2NotIn"` - Field2gt *string `json:"field2GT"` - Field2gte *string `json:"field2GTE"` - Field2lt *string `json:"field2LT"` - Field2lte *string `json:"field2LTE"` - Field2Contains *string `json:"field2Contains"` - Field2HasPrefix *string `json:"field2HasPrefix"` - Field2HasSuffix *string `json:"field2HasSuffix"` - Field2IsNil *bool `json:"field2IsNil"` - Field2NotNil *bool `json:"field2NotNil"` - Field2EqualFold *string `json:"field2EqualFold"` - Field2ContainsFold *string `json:"field2ContainsFold"` + Field2 *string `json:"field2,omitempty"` + Field2neq *string `json:"field2NEQ,omitempty"` + Field2In []string `json:"field2In,omitempty"` + Field2NotIn []string `json:"field2NotIn,omitempty"` + Field2gt *string `json:"field2GT,omitempty"` + Field2gte *string `json:"field2GTE,omitempty"` + Field2lt *string `json:"field2LT,omitempty"` + Field2lte *string `json:"field2LTE,omitempty"` + Field2Contains *string `json:"field2Contains,omitempty"` + Field2HasPrefix *string `json:"field2HasPrefix,omitempty"` + Field2HasSuffix *string `json:"field2HasSuffix,omitempty"` + Field2IsNil *bool `json:"field2IsNil,omitempty"` + Field2NotNil *bool `json:"field2NotNil,omitempty"` + Field2EqualFold *string `json:"field2EqualFold,omitempty"` + Field2ContainsFold *string `json:"field2ContainsFold,omitempty"` // parent edge predicates - HasParent *bool `json:"hasParent"` - HasParentWith []*OneToManyWhereInput `json:"hasParentWith"` + HasParent *bool `json:"hasParent,omitempty"` + HasParentWith []*OneToManyWhereInput `json:"hasParentWith,omitempty"` // children edge predicates - HasChildren *bool `json:"hasChildren"` - HasChildrenWith []*OneToManyWhereInput `json:"hasChildrenWith"` + HasChildren *bool `json:"hasChildren,omitempty"` + HasChildrenWith []*OneToManyWhereInput `json:"hasChildrenWith,omitempty"` +} + +// OrganizationWhereInput is used for filtering Workspace objects. +type OrganizationWhereInput struct { + Not *OrganizationWhereInput `json:"not,omitempty"` + And []*OrganizationWhereInput `json:"and,omitempty"` + Or []*OrganizationWhereInput `json:"or,omitempty"` + // id field predicates + ID *uuid.UUID `json:"id,omitempty"` + IDNeq *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGt *uuid.UUID `json:"idGT,omitempty"` + IDGte *uuid.UUID `json:"idGTE,omitempty"` + IDLt *uuid.UUID `json:"idLT,omitempty"` + IDLte *uuid.UUID `json:"idLTE,omitempty"` + // name field predicates + Name *string `json:"name,omitempty"` + NameNeq *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGt *string `json:"nameGT,omitempty"` + NameGte *string `json:"nameGTE,omitempty"` + NameLt *string `json:"nameLT,omitempty"` + NameLte *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` } type Project struct { ID uuid.UUID `json:"id"` - Todos *ent.TodoList `json:"todos"` + Todos *ent.TodoList `json:"todos,omitempty"` } func (Project) IsNode() {} // ProjectWhereInput is used for filtering Project objects. type ProjectWhereInput struct { - Not *ProjectWhereInput `json:"not"` - And []*ProjectWhereInput `json:"and"` - Or []*ProjectWhereInput `json:"or"` + Not *ProjectWhereInput `json:"not,omitempty"` + And []*ProjectWhereInput `json:"and,omitempty"` + Or []*ProjectWhereInput `json:"or,omitempty"` // id field predicates - ID *uuid.UUID `json:"id"` - IDNeq *uuid.UUID `json:"idNEQ"` - IDIn []uuid.UUID `json:"idIn"` - IDNotIn []uuid.UUID `json:"idNotIn"` - IDGt *uuid.UUID `json:"idGT"` - IDGte *uuid.UUID `json:"idGTE"` - IDLt *uuid.UUID `json:"idLT"` - IDLte *uuid.UUID `json:"idLTE"` + ID *uuid.UUID `json:"id,omitempty"` + IDNeq *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGt *uuid.UUID `json:"idGT,omitempty"` + IDGte *uuid.UUID `json:"idGTE,omitempty"` + IDLt *uuid.UUID `json:"idLT,omitempty"` + IDLte *uuid.UUID `json:"idLTE,omitempty"` // todos edge predicates - HasTodos *bool `json:"hasTodos"` - HasTodosWith []*ent.TodoWhereInput `json:"hasTodosWith"` + HasTodos *bool `json:"hasTodos,omitempty"` + HasTodosWith []*ent.TodoWhereInput `json:"hasTodosWith,omitempty"` } // UpdateFriendshipInput is used for update Friendship object. type UpdateFriendshipInput struct { - CreatedAt *time.Time `json:"createdAt"` - UserID *uuid.UUID `json:"userID"` - FriendID *uuid.UUID `json:"friendID"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + UserID *uuid.UUID `json:"userID,omitempty"` + FriendID *uuid.UUID `json:"friendID,omitempty"` } // Properties by which OneToMany connections can be ordered. diff --git a/entgql/internal/todouuid/server/server.go b/entgql/internal/todouuid/server/server.go index 159b8ec33..12d0add36 100644 --- a/entgql/internal/todouuid/server/server.go +++ b/entgql/internal/todouuid/server/server.go @@ -11,11 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package main import ( "context" "net/http" + "time" "entgo.io/contrib/entgql" todo "entgo.io/contrib/entgql/internal/todouuid" @@ -61,7 +63,11 @@ func main() { http.Handle("/query", srv) log.Info("listening on", zap.String("address", cli.Addr)) - if err := http.ListenAndServe(cli.Addr, nil); err != nil { + server := &http.Server{ + Addr: cli.Addr, + ReadHeaderTimeout: 30 * time.Second, + } + if err := server.ListenAndServe(); err != nil { log.Error("http server terminated", zap.Error(err)) } } diff --git a/entgql/internal/todouuid/todo.resolvers.go b/entgql/internal/todouuid/todo.resolvers.go index 9564fab74..604084cf4 100644 --- a/entgql/internal/todouuid/todo.resolvers.go +++ b/entgql/internal/todouuid/todo.resolvers.go @@ -16,6 +16,7 @@ package todo // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.43 import ( "context" @@ -27,14 +28,17 @@ import ( "github.com/google/uuid" ) +// TodosCount is the resolver for the todosCount field. func (r *categoryResolver) TodosCount(ctx context.Context, obj *ent.Category) (*int, error) { panic(fmt.Errorf("not implemented")) } +// CreateCategory is the resolver for the createCategory field. func (r *mutationResolver) CreateCategory(ctx context.Context, input ent.CreateCategoryInput) (*ent.Category, error) { panic(fmt.Errorf("not implemented")) } +// CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo(ctx context.Context, input ent.CreateTodoInput) (*ent.Todo, error) { return ent.FromContext(ctx).Todo. Create(). @@ -42,10 +46,12 @@ func (r *mutationResolver) CreateTodo(ctx context.Context, input ent.CreateTodoI Save(ctx) } +// UpdateTodo is the resolver for the updateTodo field. func (r *mutationResolver) UpdateTodo(ctx context.Context, id uuid.UUID, input ent.UpdateTodoInput) (*ent.Todo, error) { panic(fmt.Errorf("not implemented")) } +// ClearTodos is the resolver for the clearTodos field. func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { client := ent.FromContext(ctx) return client.Todo. @@ -53,22 +59,32 @@ func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) { Exec(ctx) } +// UpdateFriendship is the resolver for the updateFriendship field. func (r *mutationResolver) UpdateFriendship(ctx context.Context, id uuid.UUID, input UpdateFriendshipInput) (*ent.Friendship, error) { panic(fmt.Errorf("not implemented")) } +// Ping is the resolver for the ping field. func (r *queryResolver) Ping(ctx context.Context) (string, error) { panic(fmt.Errorf("not implemented")) } +// TodosWithJoins is the resolver for the todosWithJoins field. +func (r *queryResolver) TodosWithJoins(ctx context.Context, limit *int, offset *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoList, error) { + panic(fmt.Errorf("not implemented")) +} + +// ExtendedField is the resolver for the extendedField field. func (r *todoResolver) ExtendedField(ctx context.Context, obj *ent.Todo) (*string, error) { panic(fmt.Errorf("not implemented")) } +// CreateTodos is the resolver for the createTodos field. func (r *createCategoryInputResolver) CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error { panic(fmt.Errorf("not implemented")) } +// CreatedToday is the resolver for the createdToday field. func (r *todoWhereInputResolver) CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error { if data == nil { return nil diff --git a/entgql/pagination.go b/entgql/pagination.go index 97aed2439..6e536f42a 100644 --- a/entgql/pagination.go +++ b/entgql/pagination.go @@ -215,20 +215,48 @@ func multiPredicate[T any](cursor *Cursor[T], opts *MultiCursorsOptions) (func(* opts.Fields = append(opts.Fields, opts.FieldID) opts.Directions = append(opts.Directions, opts.DirectionID) } - // Given the following terms: x DESC, y ASC, etc. The following predicate will be - // generated: (x < x1 OR (x = x1 AND y > y1) OR (x = x1 AND y = y1 AND id > last)). - var or []*sql.Predicate - for i := range opts.Fields { - var ands []*sql.Predicate - for j := 0; j < i; j++ { - ands = append(ands, sql.EQ(opts.Fields[j], values[j])) - } - if opts.Directions[i] == OrderDirectionAsc { - ands = append(ands, sql.GT(opts.Fields[i], values[i])) - } else { - ands = append(ands, sql.LT(opts.Fields[i], values[i])) + return func(s *sql.Selector) { + // Given the following terms: x DESC, y ASC, etc. The following predicate will be + // generated: (x < x1 OR (x = x1 AND y > y1) OR (x = x1 AND y = y1 AND id > last)). + var or []*sql.Predicate + for i := range opts.Fields { + var ands []*sql.Predicate + for j := 0; j < i; j++ { + ands = append(ands, sql.EQ(s.C(opts.Fields[j]), values[j])) + } + if opts.Directions[i] == OrderDirectionAsc { + ands = append(ands, sql.GT(s.C(opts.Fields[i]), values[i])) + } else { + ands = append(ands, sql.LT(s.C(opts.Fields[i]), values[i])) + } + or = append(or, sql.And(ands...)) } - or = append(or, sql.And(ands...)) + s.Where(sql.Or(or...)) + }, nil +} + +// LimitPerRow returns a query modifier that limits the number of (edges) rows returned +// by the given partition. This helper function is used mainly by the paginated API to +// override the default Limit behavior for limit returned per node and not limit for all query. +func LimitPerRow(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { + return func(s *sql.Selector) { + d := sql.Dialect(s.Dialect()) + s.SetDistinct(false) + with := d.With("src_query"). + As(s.Clone()). + With("limited_query"). + As( + d.Select("*"). + AppendSelectExprAs( + sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), + "row_number", + ). + From(d.Table("src_query")), + ) + t := d.Table("limited_query").As(s.TableName()) + *s = *d.Select(s.UnqualifiedColumns()...). + From(t). + Where(sql.LTE(t.C("row_number"), limit)). + Prefix(with) } - return func(s *sql.Selector) { s.Where(sql.Or(or...)) }, nil } diff --git a/entgql/schema.go b/entgql/schema.go index 596ec706e..19d53c18c 100644 --- a/entgql/schema.go +++ b/entgql/schema.go @@ -60,6 +60,10 @@ var ( Name: "models", Type: ast.ListType(ast.NonNullNamedType("String", nil), nil), }, + { + Name: "forceGenerate", + Type: ast.NamedType("Boolean", nil), + }, }, Locations: []ast.DirectiveLocation{ ast.LocationObject, @@ -82,6 +86,10 @@ var ( Name: "name", Type: ast.NamedType("String", nil), }, + { + Name: "omittable", + Type: ast.NamedType("Boolean", nil), + }, }, Locations: []ast.DirectiveLocation{ ast.LocationFieldDefinition, @@ -89,7 +97,6 @@ var ( }, }, } - inputObjectFilter = func(t string) bool { return strings.HasSuffix(t, "Input") } nonInputObjectFilter = func(t string) bool { return !inputObjectFilter(t) } ) @@ -776,9 +783,6 @@ func (e *schemaGenerator) mapScalar(gqlType string, f *gen.Field, ant *Annotatio case reflect.Map: if f.Type.RType.Ident == "map[string]interface {}" { scalar = "Map" - if !f.Optional { - scalar += "!" - } } } } diff --git a/entgql/schema_test.go b/entgql/schema_test.go index 3ec2d98ef..0b093bdcc 100644 --- a/entgql/schema_test.go +++ b/entgql/schema_test.go @@ -61,7 +61,7 @@ func TestEntGQL_buildTypes_todoplugin_relay(t *testing.T) { schema := &ast.Schema{ Types: make(map[string]*ast.Definition), } - err = plugin.buildTypes(graph, schema, true) + err = plugin.buildTypes(graph, schema, false) require.NoError(t, err) schemaExpect, err := os.ReadFile("./testdata/schema_relay.graphql") require.NoError(t, err) @@ -89,18 +89,30 @@ func TestSchema_relayConnectionTypes(t *testing.T) { Name: "Todo", }, }, - want: `"""An edge in a connection.""" + want: `""" +An edge in a connection. +""" type TodoEdge { - """The item at the end of the edge.""" + """ + The item at the end of the edge. + """ node: Todo } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type TodoList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Todo]! - """The list of edges where each edge holds a data node and possibly metadata.""" + """ + The list of edges where each edge holds a data node and possibly metadata. + """ edges: [TodoEdge] } `, @@ -117,18 +129,30 @@ type TodoList { }, }, }, - want: `"""An edge in a connection.""" + want: `""" +An edge in a connection. +""" type SuperTodoEdge { - """The item at the end of the edge.""" + """ + The item at the end of the edge. + """ node: SuperTodo } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type SuperTodoList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [SuperTodo]! - """The list of edges where each edge holds a data node and possibly metadata.""" + """ + The list of edges where each edge holds a data node and possibly metadata. + """ edges: [SuperTodoEdge] } `, @@ -170,7 +194,9 @@ An object with an ID. Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) """ interface Node @goModel(model: "todo/ent.Noder") { - """The id of the object.""" + """ + The id of the object. + """ id: ID! } """ @@ -178,13 +204,21 @@ Information about pagination in a connection. https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo """ type PageInfo { - """When paginating forwards, are there more items?""" + """ + When paginating forwards, are there more items? + """ hasNextPage: Boolean! - """When paginating backwards, are there more items?""" + """ + When paginating backwards, are there more items? + """ hasPreviousPage: Boolean! - """When paginating backwards, the cursor to continue.""" + """ + When paginating backwards, the cursor to continue. + """ startCursor: Cursor - """When paginating forwards, the cursor to continue.""" + """ + When paginating forwards, the cursor to continue. + """ endCursor: Cursor } `, diff --git a/entgql/template.go b/entgql/template.go index d3a58c199..a4854abec 100644 --- a/entgql/template.go +++ b/entgql/template.go @@ -89,6 +89,8 @@ var ( "isRelayConn": isRelayConn, "isSkipMode": isSkipMode, "mutationInputs": mutationInputs, + "nodeImplementors": nodeImplementors, + "nodeImplementorsVar": nodeImplementorsVar, "nodePaginationNames": nodePaginationNames, "orderFields": orderFields, "skipMode": skipModeFromString, @@ -369,11 +371,19 @@ func filterFields(fields []*gen.Field, skip SkipMode) ([]*gen.Field, error) { // OrderTerm is a struct that represents a single GraphQL order term. type OrderTerm struct { - GQL string // The GraphQL name of the field. - Type *gen.Type // The type that owns the field. - Field *gen.Field // Not nil if it is a type/edge field. - Edge *gen.Edge // Not nil if it is an edge field or count. - Count bool // True if it is a count field. + // The type that owns the order field. + Owner *gen.Type + // The GraphQL name of the field. + GQL string + // The type that owns the field. For type fields, it equals to Owner. + // For edge fields, it equals to the underlying edge's type. + Type *gen.Type + // Not nil if it is a type/edge field. + Field *gen.Field + // Not nil if it is an edge field or count. + Edge *gen.Edge + // True if it is a count field. + Count bool } // IsFieldTerm returns true if the order term is a type field term. @@ -393,7 +403,7 @@ func (o *OrderTerm) IsEdgeCountTerm() bool { // VarName returns the name of the variable holding the order term. func (o *OrderTerm) VarName() (string, error) { - switch prefix := paginationNames(o.Type.Name, false).OrderField; { + switch prefix := paginationNames(o.Owner.Name, false).OrderField; { case o.IsFieldTerm(): return prefix + o.Field.StructField(), nil case o.IsEdgeFieldTerm(): @@ -435,6 +445,7 @@ func orderFields(n *gen.Type) ([]*OrderTerm, error) { return nil, fmt.Errorf("entgql: ordered field %s.%s must be comparable", n.Name, f.Name) default: terms = append(terms, &OrderTerm{ + Owner: n, GQL: ant.OrderField, Type: n, Field: f, @@ -453,6 +464,7 @@ func orderFields(n *gen.Type) ([]*OrderTerm, error) { return nil, fmt.Errorf("entgql: invalid order field %s defined on edge %s.%s: %w", ant.OrderField, n.Name, e.Name, err) } terms = append(terms, &OrderTerm{ + Owner: n, GQL: ant.OrderField, Type: n, Edge: e, @@ -472,6 +484,7 @@ func orderFields(n *gen.Type) ([]*OrderTerm, error) { return nil, fmt.Errorf("entgql: order field %s defined on edge %s.%s was not found on its reference", ant.OrderField, n.Name, e.Name) } terms = append(terms, &OrderTerm{ + Owner: n, GQL: ant.OrderField, Edge: e, Type: e.Type, @@ -776,3 +789,18 @@ func skipMutationTemplate(g *gen.Graph) bool { } return true } + +func nodeImplementors(n *gen.Type) (ifaces []string, err error) { + ant, err := annotation(n.Annotations) + if err != nil { + return nil, err + } + if !ant.Skip.Is(SkipType) && !slices.Contains(ant.Implements, "Node") { + ifaces = append(ifaces, "Node") + } + return append(ifaces, ant.Implements...), nil +} + +func nodeImplementorsVar(n *gen.Type) string { + return strings.ToLower(n.Name) + "Implementors" +} diff --git a/entgql/template/collection.tmpl b/entgql/template/collection.tmpl index ccb68541e..0b4bba886 100644 --- a/entgql/template/collection.tmpl +++ b/entgql/template/collection.tmpl @@ -32,13 +32,13 @@ func ({{ $receiver }} *{{ $query }}) CollectFields(ctx context.Context, satisfie if fc == nil { return {{ $receiver }}, nil } - if err := {{ $receiver }}.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := {{ $receiver }}.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return {{ $receiver }}, nil } -func ({{ $receiver }} *{{ $query }}) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func ({{ $receiver }} *{{ $query }}) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) {{- $fields := filterFields $node.Fields (skipMode "type") }} {{- $collects := fieldCollections (filterEdges $node.Edges (skipMode "type")) }} @@ -59,6 +59,8 @@ func ({{ $receiver }} *{{ $query }}) collectField(ctx context.Context, opCtx *gr switch field.Name { {{- range $i, $fc := $collects }} {{- $e := $fc.Edge }} + {{- /* If the edge is unique, we inherit the cardinality of the parent. */}} + {{ $oneNode := "false" }}{{- if $e.Unique }}{{ $oneNode = "oneNode" }}{{ end }} case {{ range $i, $value := $fc.Mapping }}{{ if $i }}, {{ end }}"{{ $value }}"{{ end }}: var ( alias = field.Alias @@ -109,29 +111,34 @@ func ({{ $receiver }} *{{ $query }}) collectField(ctx context.Context, opCtx *gr } pathNodes := append(path, edgesField, nodeField) if field := collectedField(ctx, pathNodes...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathNodes, mayAddCondition(satisfies, "{{ $e.Type.Name }}")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathNodes, mayAddCondition(satisfies, []string{"{{ $e.Type.Name }}"})...); err != nil { return err } } pathItems := append(path, itemsField) if field := collectedField(ctx, pathItems...); field != nil { - if err := query.collectField(ctx, opCtx, *field, pathItems, mayAddCondition(satisfies, "{{ $e.Type.Name }}")...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, *field, pathItems, mayAddCondition(satisfies, []string{"{{ $e.Type.Name }}"})...); err != nil { return err } } if args.limit != nil && *args.limit > 0 { - {{- $fk := print $node.Package "." $fc.Edge.ColumnConstant }} - {{- if $e.M2M }} - {{- $i := 0 }}{{ if $e.IsInverse }}{{ $i = 1 }}{{ end }} - {{- $fk = print $node.Package "." $e.PKConstant "[" $i "]" }} - {{- end }} - modify := limitRows({{ $fk }}, *args.limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + {{- /* Limit per row is not required, as there is only node returned by the top query. */}} + if oneNode { + pager.applyOrder(query.Limit(*args.limit)) + } else { + {{- $fk := print $node.Package "." $fc.Edge.ColumnConstant }} + {{- if $e.M2M }} + {{- $i := 0 }}{{ if $e.IsInverse }}{{ $i = 1 }}{{ end }} + {{- $fk = print $node.Package "." $e.PKConstant "[" $i "]" }} + {{- end }} + modify := entgql.LimitPerRow({{ $fk }}, *args.limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } {{- else }} - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, {{ $oneNode }}, opCtx, field, path, mayAddCondition(satisfies, {{ nodeImplementorsVar $e.Type }})...); err != nil { return err } {{- end }} @@ -192,7 +199,7 @@ type {{ $paginateArg }} struct { opts []{{ print $name "PaginateOption" }} } -func {{ $newPaginateArg }}(rv map[string]interface{}) *{{ $paginateArg }} { +func {{ $newPaginateArg }}(rv map[string]any) *{{ $paginateArg }} { args := &{{ $paginateArg }}{} if rv == nil { return args @@ -209,10 +216,10 @@ func {{ $newPaginateArg }}(rv map[string]interface{}) *{{ $paginateArg }} { {{- if $multiOrder }} case []*{{ $order }}: args.opts = append(args.opts, {{ print "With" $order }}(v)) - case []interface{}: + case []any: var orders []*{{ $order }} for i := range v { - mv, ok := v[i].(map[string]interface{}) + mv, ok := v[i].(map[string]any) if !ok { continue } @@ -232,7 +239,7 @@ func {{ $newPaginateArg }}(rv map[string]interface{}) *{{ $paginateArg }} { } args.opts = append(args.opts, {{ print "With" $order }}(orders)) {{- else }} - case map[string]interface{}: + case map[string]any: var ( err1, err2 error order = &{{ $order }}{Field: &{{ $orderField }}{}, Direction: entgql.OrderDirectionAsc} @@ -273,35 +280,18 @@ const ( {{- end }} ) -func fieldArgs(ctx context.Context, whereInput interface{}, path ...string) map[string]interface{} { - fc := graphql.GetFieldContext(ctx) - if fc == nil { +func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { + field := collectedField(ctx, path...) + if field == nil || field.Arguments == nil { return nil } oc := graphql.GetOperationContext(ctx) - for _, name := range path { - var field *graphql.CollectedField - for _, f := range graphql.CollectFields(oc, fc.Field.Selections, nil) { - if f.Alias == name { - field = &f - break - } - } - if field == nil { - return nil - } - cf, err := fc.Child(ctx, *field) - if err != nil { - args := field.ArgumentMap(oc.Variables) - return unmarshalArgs(ctx, whereInput, args) - } - fc = cf - } - return fc.Args + args := field.ArgumentMap(oc.Variables) + return unmarshalArgs(ctx, whereInput, args) } // unmarshalArgs allows extracting the field arguments from their raw representation. -func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string]interface{}) map[string]interface{} { +func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{limitField, offsetField} { v, ok := args[k] if !ok { @@ -321,41 +311,19 @@ func unmarshalArgs(ctx context.Context, whereInput interface{}, args map[string] return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } {{ end }} diff --git a/entgql/template/node.tmpl b/entgql/template/node.tmpl index 2553798b9..e7cbbc532 100644 --- a/entgql/template/node.tmpl +++ b/entgql/template/node.tmpl @@ -48,8 +48,13 @@ type Noder interface { {{/* loop over all types and add implement the Node interface. */}} {{ range $n := $gqlNodes }} - // IsNode implements the Node interface check for GQLGen. - func (n *{{ $n.Name }}) IsNode() {} + {{ $names := nodePaginationNames $n false -}} + var {{ nodeImplementorsVar $n }} = []string{"{{ $names.Node }}" {{ range $iface := nodeImplementors $n }},"{{ $iface }}"{{ end }} } + {{- range $iface := nodeImplementors $n }} + {{- $method := print "Is" $iface }} + // {{ $method }} implements the {{ $iface }} interface check for GQLGen. + func (*{{ $n.Name }}) {{ $method }}() {} + {{- end }} {{- if and $idType.Mixed (gqlMarshaler $n.ID) }} {{ $receiver := $n.Receiver }} @@ -136,16 +141,13 @@ func (c *Client) noder(ctx context.Context, table string, id {{ $idType }}) (Nod query := c.{{ $n.Name }}.Query(). Where({{ $n.Package }}.ID({{ if $unmarshalID }}u{{ end }}id)) {{- if hasTemplate "gql_collection" }} - query, err := query.CollectFields(ctx, "{{ $n.Name }}") - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, {{ nodeImplementorsVar $n }}...); err != nil { + return nil, err + } } {{- end }} - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil + return query.Only(ctx) {{- end }} default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) @@ -235,7 +237,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []{{ $idType }}) query := c.{{ $n.Name }}.Query(). Where({{ $n.Package }}.IDIn({{ if $unmarshalID }}u{{ end }}ids...)) {{- if hasTemplate "gql_collection" }} - query, err := query.CollectFields(ctx, "{{ $n.Name }}") + query, err := query.CollectFields(ctx, {{ nodeImplementorsVar $n }}...) if err != nil { return nil, err } diff --git a/entgql/template/pagination.tmpl b/entgql/template/pagination.tmpl index 7e8c38e0b..e5c59e79e 100644 --- a/entgql/template/pagination.tmpl +++ b/entgql/template/pagination.tmpl @@ -297,12 +297,12 @@ func (p *{{ $pager }}) applyFilter(query *{{ $query }}) (*{{ $query }}, error) { {{ $r := $node.Receiver }} func (p *{{ $pager }}) toCursor({{ $r }} *{{ $name }}) Cursor { {{- if $multiOrder }} - cs := make([]any, 0, len(p.order)) - for _, o := range p.order { - cs = append(cs, o.Field.toCursor({{ $r }}).Value) + cs_ := make([]any, 0, len(p.order)) + for _, o_ := range p.order { + cs_ = append(cs_, o_.Field.toCursor({{ $r }}).Value) } {{- $marshalID := and $idType.Mixed (gqlMarshaler $node.ID) }} - return Cursor{ID: {{ $r }}.{{ if $marshalID }}marshalID(){{ else }}ID{{ end }}, Value: cs} + return Cursor{ID: {{ $r }}.{{ if $marshalID }}marshalID(){{ else }}ID{{ end }}, Value: cs_} {{- else }} return p.order.Field.toCursor({{ $r }}) {{- end }} @@ -666,7 +666,10 @@ func ({{ $r }} *{{ $name }}) ToEdge(order *{{ $order }}) *{{ $edge }} { if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = {{ $r }}.Clone().Count(ctx); err != nil { + c := {{ $r }}.Clone() + {{- /* Clear the selection fields before counting to avoid generating invalid queries. */}} + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -680,16 +683,17 @@ func ({{ $r }} *{{ $name }}) ToEdge(order *{{ $order }}) *{{ $edge }} { if {{ $r }}, err = pager.applyCursors({{ $r }}, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { {{ $r }}.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := {{ $r }}.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := {{ $r }}.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := {{ $r }}.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := {{ $r }}.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } @@ -744,12 +748,12 @@ func ({{ $r }} *{{ $name }}) ToEdge(order *{{ $order }}) *{{ $edge }} { {{ $r }}.Offset(*offset) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := {{ $r }}.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := {{ $r }}.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } if field := collectedField(ctx, itemsField); field != nil { - if err := {{ $r }}.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { + if err := {{ $r }}.collectField(ctx, (limit != nil && *limit == 1), graphql.GetOperationContext(ctx), *field, []string{itemsField}); err != nil { return nil, err } } diff --git a/entgql/testdata/schema.graphql b/entgql/testdata/schema.graphql index 4a68de0fb..2ae302b82 100644 --- a/entgql/testdata/schema.graphql +++ b/entgql/testdata/schema.graphql @@ -1,54 +1,75 @@ -"""Represents BillProduct object""" +""" +Represents BillProduct object +""" type BillProduct { id: ID! name: String! sku: String! quantity: Uint64! } -"""Represents Category object""" +""" +Represents Category object +""" type Category { id: ID! text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todos: [Todo!] subCategories: [Category!] } -"""Ordering options for Category connections""" +""" +Ordering options for Category connections +""" input CategoryOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Categories.""" + """ + The field by which to order Categories. + """ field: CategoryOrderField! } -"""Properties by which Category connections can be ordered.""" +""" +Properties by which Category connections can be ordered. +""" enum CategoryOrderField { ID TEXT + STATUS DURATION COUNT TODOS_COUNT } -"""CategoryStatus is enum for the field status""" +""" +CategoryStatus is enum for the field status +""" enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { ENABLED DISABLED } -"""CreateCategoryInput is used for create Category object.""" +""" +CreateCategoryInput is used for create Category object. +""" input CreateCategoryInput { text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todoIDs: [ID!] subCategoryIDs: [ID!] } -"""CreateTodoInput is used for create Todo object.""" +""" +CreateTodoInput is used for create Todo object. +""" input CreateTodoInput { status: TodoStatus! priority: Int @@ -59,11 +80,14 @@ input CreateTodoInput { categoryID: ID secretID: ID } -"""CreateUserInput is used for create User object.""" +""" +CreateUserInput is used for create User object. +""" input CreateUserInput { name: String username: UUID password: String + requiredMetadata: Map! metadata: Map groupIDs: [ID!] friendIDs: [ID!] @@ -76,12 +100,14 @@ type Friendship { user: User! friend: User! } -type Group @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { +type Group implements NamedNode @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { id: ID! name: String! users: [User!] } -"""The builtin Map type""" +""" +The builtin Map type +""" scalar Map type OneToMany { id: ID! @@ -90,17 +116,29 @@ type OneToMany { parent: OneToMany children: [OneToMany!] } -"""Ordering options for OneToMany connections""" +""" +Ordering options for OneToMany connections +""" input OneToManyOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" + """ + The field by which to order OneToManies. + """ field: OneToManyOrderField! } -"""Properties by which OneToMany connections can be ordered.""" +""" +Properties by which OneToMany connections can be ordered. +""" enum OneToManyOrderField { NAME } +type Organization @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Workspace") { + id: ID! + name: String! +} type Project { id: ID! todos: [Todo!] @@ -110,11 +148,15 @@ type Query { categories: [Category!]! groups: [Group!]! oneToMany: [OneToMany!]! - """This is the todo item""" + """ + This is the todo item + """ todos: [Todo!]! users: [User!]! } -"""The builtin Time type""" +""" +The builtin Time type +""" scalar Time type Todo { id: ID! @@ -128,20 +170,32 @@ type Todo { init: Map custom: [Custom!] customp: [Custom] - """Todo parent""" + """ + Todo parent + """ parent: Todo - """Todo children""" + """ + Todo children + """ children: [Todo!] category: Category } -"""Ordering options for Todo connections""" +""" +Ordering options for Todo connections +""" input TodoOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Todos.""" + """ + The field by which to order Todos. + """ field: TodoOrderField! } -"""Properties by which Todo connections can be ordered.""" +""" +Properties by which Todo connections can be ordered. +""" enum TodoOrderField { CREATED_AT STATUS @@ -151,20 +205,28 @@ enum TodoOrderField { CHILDREN_COUNT CATEGORY_TEXT } -"""TodoStatus is enum for the field status""" +""" +TodoStatus is enum for the field status +""" enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { IN_PROGRESS COMPLETED PENDING } -"""The builtin Uint64 type""" +""" +The builtin Uint64 type +""" scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" +""" +UpdateCategoryInput is used for update Category object. +""" input UpdateCategoryInput { text: String status: CategoryStatus config: CategoryConfig clearConfig: Boolean + types: CategoryTypes + clearTypes: Boolean duration: Duration clearDuration: Boolean count: Uint64 @@ -179,13 +241,17 @@ input UpdateCategoryInput { removeSubCategoryIDs: [ID!] clearSubCategories: Boolean } -"""UpdateFriendshipInput is used for update Friendship object.""" +""" +UpdateFriendshipInput is used for update Friendship object. +""" input UpdateFriendshipInput { createdAt: Time userID: ID friendID: ID } -"""UpdateTodoInput is used for update Todo object.""" +""" +UpdateTodoInput is used for update Todo object. +""" input UpdateTodoInput { status: TodoStatus priority: Int @@ -200,12 +266,15 @@ input UpdateTodoInput { secretID: ID clearSecret: Boolean } -"""UpdateUserInput is used for update User object.""" +""" +UpdateUserInput is used for update User object. +""" input UpdateUserInput { name: String username: UUID password: String clearPassword: Boolean + requiredMetadata: Map metadata: Map clearMetadata: Boolean addGroupIDs: [ID!] @@ -219,20 +288,31 @@ type User { id: ID! name: String! username: UUID! + requiredMetadata: Map! metadata: Map - """The groups of the user""" + """ + The groups of the user + """ groups: [Group!] friends: [User!] friendships: [Friendship!] } -"""Ordering options for User connections""" +""" +Ordering options for User connections +""" input UserOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Users.""" + """ + The field by which to order Users. + """ field: UserOrderField! } -"""Properties by which User connections can be ordered.""" +""" +Properties by which User connections can be ordered. +""" enum UserOrderField { GROUPS_COUNT } diff --git a/entgql/testdata/schema_output.graphql b/entgql/testdata/schema_output.graphql index 4a68de0fb..2ae302b82 100644 --- a/entgql/testdata/schema_output.graphql +++ b/entgql/testdata/schema_output.graphql @@ -1,54 +1,75 @@ -"""Represents BillProduct object""" +""" +Represents BillProduct object +""" type BillProduct { id: ID! name: String! sku: String! quantity: Uint64! } -"""Represents Category object""" +""" +Represents Category object +""" type Category { id: ID! text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todos: [Todo!] subCategories: [Category!] } -"""Ordering options for Category connections""" +""" +Ordering options for Category connections +""" input CategoryOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Categories.""" + """ + The field by which to order Categories. + """ field: CategoryOrderField! } -"""Properties by which Category connections can be ordered.""" +""" +Properties by which Category connections can be ordered. +""" enum CategoryOrderField { ID TEXT + STATUS DURATION COUNT TODOS_COUNT } -"""CategoryStatus is enum for the field status""" +""" +CategoryStatus is enum for the field status +""" enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { ENABLED DISABLED } -"""CreateCategoryInput is used for create Category object.""" +""" +CreateCategoryInput is used for create Category object. +""" input CreateCategoryInput { text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todoIDs: [ID!] subCategoryIDs: [ID!] } -"""CreateTodoInput is used for create Todo object.""" +""" +CreateTodoInput is used for create Todo object. +""" input CreateTodoInput { status: TodoStatus! priority: Int @@ -59,11 +80,14 @@ input CreateTodoInput { categoryID: ID secretID: ID } -"""CreateUserInput is used for create User object.""" +""" +CreateUserInput is used for create User object. +""" input CreateUserInput { name: String username: UUID password: String + requiredMetadata: Map! metadata: Map groupIDs: [ID!] friendIDs: [ID!] @@ -76,12 +100,14 @@ type Friendship { user: User! friend: User! } -type Group @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { +type Group implements NamedNode @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { id: ID! name: String! users: [User!] } -"""The builtin Map type""" +""" +The builtin Map type +""" scalar Map type OneToMany { id: ID! @@ -90,17 +116,29 @@ type OneToMany { parent: OneToMany children: [OneToMany!] } -"""Ordering options for OneToMany connections""" +""" +Ordering options for OneToMany connections +""" input OneToManyOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" + """ + The field by which to order OneToManies. + """ field: OneToManyOrderField! } -"""Properties by which OneToMany connections can be ordered.""" +""" +Properties by which OneToMany connections can be ordered. +""" enum OneToManyOrderField { NAME } +type Organization @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Workspace") { + id: ID! + name: String! +} type Project { id: ID! todos: [Todo!] @@ -110,11 +148,15 @@ type Query { categories: [Category!]! groups: [Group!]! oneToMany: [OneToMany!]! - """This is the todo item""" + """ + This is the todo item + """ todos: [Todo!]! users: [User!]! } -"""The builtin Time type""" +""" +The builtin Time type +""" scalar Time type Todo { id: ID! @@ -128,20 +170,32 @@ type Todo { init: Map custom: [Custom!] customp: [Custom] - """Todo parent""" + """ + Todo parent + """ parent: Todo - """Todo children""" + """ + Todo children + """ children: [Todo!] category: Category } -"""Ordering options for Todo connections""" +""" +Ordering options for Todo connections +""" input TodoOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Todos.""" + """ + The field by which to order Todos. + """ field: TodoOrderField! } -"""Properties by which Todo connections can be ordered.""" +""" +Properties by which Todo connections can be ordered. +""" enum TodoOrderField { CREATED_AT STATUS @@ -151,20 +205,28 @@ enum TodoOrderField { CHILDREN_COUNT CATEGORY_TEXT } -"""TodoStatus is enum for the field status""" +""" +TodoStatus is enum for the field status +""" enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { IN_PROGRESS COMPLETED PENDING } -"""The builtin Uint64 type""" +""" +The builtin Uint64 type +""" scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" +""" +UpdateCategoryInput is used for update Category object. +""" input UpdateCategoryInput { text: String status: CategoryStatus config: CategoryConfig clearConfig: Boolean + types: CategoryTypes + clearTypes: Boolean duration: Duration clearDuration: Boolean count: Uint64 @@ -179,13 +241,17 @@ input UpdateCategoryInput { removeSubCategoryIDs: [ID!] clearSubCategories: Boolean } -"""UpdateFriendshipInput is used for update Friendship object.""" +""" +UpdateFriendshipInput is used for update Friendship object. +""" input UpdateFriendshipInput { createdAt: Time userID: ID friendID: ID } -"""UpdateTodoInput is used for update Todo object.""" +""" +UpdateTodoInput is used for update Todo object. +""" input UpdateTodoInput { status: TodoStatus priority: Int @@ -200,12 +266,15 @@ input UpdateTodoInput { secretID: ID clearSecret: Boolean } -"""UpdateUserInput is used for update User object.""" +""" +UpdateUserInput is used for update User object. +""" input UpdateUserInput { name: String username: UUID password: String clearPassword: Boolean + requiredMetadata: Map metadata: Map clearMetadata: Boolean addGroupIDs: [ID!] @@ -219,20 +288,31 @@ type User { id: ID! name: String! username: UUID! + requiredMetadata: Map! metadata: Map - """The groups of the user""" + """ + The groups of the user + """ groups: [Group!] friends: [User!] friendships: [Friendship!] } -"""Ordering options for User connections""" +""" +Ordering options for User connections +""" input UserOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Users.""" + """ + The field by which to order Users. + """ field: UserOrderField! } -"""Properties by which User connections can be ordered.""" +""" +Properties by which User connections can be ordered. +""" enum UserOrderField { GROUPS_COUNT } diff --git a/entgql/testdata/schema_relay.graphql b/entgql/testdata/schema_relay.graphql index 0dffdab2f..172fdde6e 100644 --- a/entgql/testdata/schema_relay.graphql +++ b/entgql/testdata/schema_relay.graphql @@ -1,16 +1,22 @@ -"""Represents BillProduct object""" +""" +Represents BillProduct object +""" type BillProduct implements Node { id: ID! name: String! sku: String! quantity: Uint64! } -"""BillProductWhereInput is used for filtering BillProduct objects.""" +""" +BillProductWhereInput is used for filtering BillProduct objects. +""" input BillProductWhereInput { not: BillProductWhereInput and: [BillProductWhereInput!] or: [BillProductWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -19,7 +25,9 @@ input BillProductWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -33,7 +41,9 @@ input BillProductWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """sku field predicates""" + """ + sku field predicates + """ sku: String skuNEQ: String skuIn: [String!] @@ -47,7 +57,9 @@ input BillProductWhereInput { skuHasSuffix: String skuEqualFold: String skuContainsFold: String - """quantity field predicates""" + """ + quantity field predicates + """ quantity: Uint64 quantityNEQ: Uint64 quantityIn: [Uint64!] @@ -57,82 +69,115 @@ input BillProductWhereInput { quantityLT: Uint64 quantityLTE: Uint64 } -"""Represents Category object""" +""" +Represents Category object +""" type Category implements Node { id: ID! text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList subCategories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList } -"""An edge in a connection.""" -type CategoryEdge { - """The item at the end of the edge.""" - node: Category -} -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type CategoryList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Category]! - """The list of edges where each edge holds a data node and possibly metadata.""" - edges: [CategoryEdge] } -"""Ordering options for Category connections""" +""" +Ordering options for Category connections +""" input CategoryOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Categories.""" + """ + The field by which to order Categories. + """ field: CategoryOrderField! } -"""Properties by which Category connections can be ordered.""" +""" +Properties by which Category connections can be ordered. +""" enum CategoryOrderField { ID TEXT + STATUS DURATION COUNT TODOS_COUNT } -"""CategoryStatus is enum for the field status""" +""" +CategoryStatus is enum for the field status +""" enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { ENABLED DISABLED } -"""CategoryWhereInput is used for filtering Category objects.""" +""" +CategoryWhereInput is used for filtering Category objects. +""" input CategoryWhereInput { not: CategoryWhereInput and: [CategoryWhereInput!] or: [CategoryWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -141,7 +186,9 @@ input CategoryWhereInput { idGTE: ID idLT: ID idLTE: ID - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -155,12 +202,16 @@ input CategoryWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """status field predicates""" + """ + status field predicates + """ status: CategoryStatus statusNEQ: CategoryStatus statusIn: [CategoryStatus!] statusNotIn: [CategoryStatus!] - """config field predicates""" + """ + config field predicates + """ config: CategoryConfig configNEQ: CategoryConfig configIn: [CategoryConfig!] @@ -171,7 +222,9 @@ input CategoryWhereInput { configLTE: CategoryConfig configIsNil: Boolean configNotNil: Boolean - """duration field predicates""" + """ + duration field predicates + """ duration: Duration durationNEQ: Duration durationIn: [Duration!] @@ -182,7 +235,9 @@ input CategoryWhereInput { durationLTE: Duration durationIsNil: Boolean durationNotNil: Boolean - """count field predicates""" + """ + count field predicates + """ count: Uint64 countNEQ: Uint64 countIn: [Uint64!] @@ -193,25 +248,34 @@ input CategoryWhereInput { countLTE: Uint64 countIsNil: Boolean countNotNil: Boolean - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] - """sub_categories edge predicates""" + """ + sub_categories edge predicates + """ hasSubCategories: Boolean hasSubCategoriesWith: [CategoryWhereInput!] } -"""CreateCategoryInput is used for create Category object.""" +""" +CreateCategoryInput is used for create Category object. +""" input CreateCategoryInput { text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todoIDs: [ID!] subCategoryIDs: [ID!] } -"""CreateTodoInput is used for create Todo object.""" +""" +CreateTodoInput is used for create Todo object. +""" input CreateTodoInput { status: TodoStatus! priority: Int @@ -222,11 +286,14 @@ input CreateTodoInput { categoryID: ID secretID: ID } -"""CreateUserInput is used for create User object.""" +""" +CreateUserInput is used for create User object. +""" input CreateUserInput { name: String username: UUID password: String + requiredMetadata: Map! metadata: Map groupIDs: [ID!] friendIDs: [ID!] @@ -239,26 +306,29 @@ type Friendship implements Node { user: User! friend: User! } -"""An edge in a connection.""" -type FriendshipEdge { - """The item at the end of the edge.""" - node: Friendship -} -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type FriendshipList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Friendship]! - """The list of edges where each edge holds a data node and possibly metadata.""" - edges: [FriendshipEdge] } -"""FriendshipWhereInput is used for filtering Friendship objects.""" +""" +FriendshipWhereInput is used for filtering Friendship objects. +""" input FriendshipWhereInput { not: FriendshipWhereInput and: [FriendshipWhereInput!] or: [FriendshipWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -267,7 +337,9 @@ input FriendshipWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -277,43 +349,54 @@ input FriendshipWhereInput { createdAtLT: Time createdAtLTE: Time } -type Group implements Node @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { +type Group implements Node & NamedNode @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { id: ID! name: String! users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""An edge in a connection.""" -type GroupEdge { - """The item at the end of the edge.""" - node: Group -} -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type GroupList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Group]! - """The list of edges where each edge holds a data node and possibly metadata.""" - edges: [GroupEdge] } -"""GroupWhereInput is used for filtering Group objects.""" +""" +GroupWhereInput is used for filtering Group objects. +""" input GroupWhereInput { not: GroupWhereInput and: [GroupWhereInput!] or: [GroupWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -322,7 +405,9 @@ input GroupWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -336,11 +421,15 @@ input GroupWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """users edge predicates""" + """ + users edge predicates + """ hasUsers: Boolean hasUsersWith: [UserWhereInput!] } -"""The builtin Map type""" +""" +The builtin Map type +""" scalar Map type OneToMany implements Node { id: ID! @@ -349,37 +438,48 @@ type OneToMany implements Node { parent: OneToMany children: [OneToMany!] } -"""An edge in a connection.""" -type OneToManyEdge { - """The item at the end of the edge.""" - node: OneToMany -} -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type OneToManyList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [OneToMany]! - """The list of edges where each edge holds a data node and possibly metadata.""" - edges: [OneToManyEdge] } -"""Ordering options for OneToMany connections""" +""" +Ordering options for OneToMany connections +""" input OneToManyOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" + """ + The field by which to order OneToManies. + """ field: OneToManyOrderField! } -"""Properties by which OneToMany connections can be ordered.""" +""" +Properties by which OneToMany connections can be ordered. +""" enum OneToManyOrderField { NAME } -"""OneToManyWhereInput is used for filtering OneToMany objects.""" +""" +OneToManyWhereInput is used for filtering OneToMany objects. +""" input OneToManyWhereInput { not: OneToManyWhereInput and: [OneToManyWhereInput!] or: [OneToManyWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -388,7 +488,9 @@ input OneToManyWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -402,7 +504,9 @@ input OneToManyWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """field2 field predicates""" + """ + field2 field predicates + """ field2: String field2NEQ: String field2In: [String!] @@ -418,35 +522,90 @@ input OneToManyWhereInput { field2NotNil: Boolean field2EqualFold: String field2ContainsFold: String - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [OneToManyWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [OneToManyWhereInput!] } +type Organization implements Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Workspace") { + id: ID! + name: String! +} +""" +OrganizationWhereInput is used for filtering Workspace objects. +""" +input OrganizationWhereInput { + not: OrganizationWhereInput + and: [OrganizationWhereInput!] + or: [OrganizationWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String +} type Project implements Node { id: ID! todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList } -"""ProjectWhereInput is used for filtering Project objects.""" +""" +ProjectWhereInput is used for filtering Project objects. +""" input ProjectWhereInput { not: ProjectWhereInput and: [ProjectWhereInput!] or: [ProjectWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -455,87 +614,139 @@ input ProjectWhereInput { idGTE: ID idLT: ID idLTE: ID - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] } type Query { - """Fetches an object given its ID.""" + """ + Fetches an object given its ID. + """ node( - """ID of the object.""" + """ + ID of the object. + """ id: ID! ): Node - """Lookup nodes by a list of IDs.""" + """ + Lookup nodes by a list of IDs. + """ nodes( - """The list of node IDs.""" + """ + The list of node IDs. + """ ids: [ID!]! ): [Node]! billProducts: [BillProduct!]! categories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList oneToMany( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for OneToManies returned from the connection.""" + """ + Ordering options for OneToManies returned from the connection. + """ orderBy: OneToManyOrder - """Filtering options for OneToManies returned from the connection.""" + """ + Filtering options for OneToManies returned from the connection. + """ where: OneToManyWhereInput ): OneToManyList - """This is the todo item""" + """ + This is the todo item + """ todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""The builtin Time type""" +""" +The builtin Time type +""" scalar Time type Todo implements Node { id: ID! @@ -549,46 +760,65 @@ type Todo implements Node { init: Map custom: [Custom!] customp: [Custom] - """Todo parent""" + """ + Todo parent + """ parent: Todo - """Todo children""" + """ + Todo children + """ children( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList category: Category } -"""An edge in a connection.""" -type TodoEdge { - """The item at the end of the edge.""" - node: Todo -} -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type TodoList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Todo]! - """The list of edges where each edge holds a data node and possibly metadata.""" - edges: [TodoEdge] } -"""Ordering options for Todo connections""" +""" +Ordering options for Todo connections +""" input TodoOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Todos.""" + """ + The field by which to order Todos. + """ field: TodoOrderField! } -"""Properties by which Todo connections can be ordered.""" +""" +Properties by which Todo connections can be ordered. +""" enum TodoOrderField { CREATED_AT STATUS @@ -598,18 +828,24 @@ enum TodoOrderField { CHILDREN_COUNT CATEGORY_TEXT } -"""TodoStatus is enum for the field status""" +""" +TodoStatus is enum for the field status +""" enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { IN_PROGRESS COMPLETED PENDING } -"""TodoWhereInput is used for filtering Todo objects.""" +""" +TodoWhereInput is used for filtering Todo objects. +""" input TodoWhereInput { not: TodoWhereInput and: [TodoWhereInput!] or: [TodoWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -618,7 +854,9 @@ input TodoWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -627,12 +865,16 @@ input TodoWhereInput { createdAtGTE: Time createdAtLT: Time createdAtLTE: Time - """status field predicates""" + """ + status field predicates + """ status: TodoStatus statusNEQ: TodoStatus statusIn: [TodoStatus!] statusNotIn: [TodoStatus!] - """priority field predicates""" + """ + priority field predicates + """ priority: Int priorityNEQ: Int priorityIn: [Int!] @@ -641,7 +883,9 @@ input TodoWhereInput { priorityGTE: Int priorityLT: Int priorityLTE: Int - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -655,31 +899,45 @@ input TodoWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """category_id field predicates""" + """ + category_id field predicates + """ categoryID: ID categoryIDNEQ: ID categoryIDIn: [ID!] categoryIDNotIn: [ID!] categoryIDIsNil: Boolean categoryIDNotNil: Boolean - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [TodoWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [TodoWhereInput!] - """category edge predicates""" + """ + category edge predicates + """ hasCategory: Boolean hasCategoryWith: [CategoryWhereInput!] } -"""The builtin Uint64 type""" +""" +The builtin Uint64 type +""" scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" +""" +UpdateCategoryInput is used for update Category object. +""" input UpdateCategoryInput { text: String status: CategoryStatus config: CategoryConfig clearConfig: Boolean + types: CategoryTypes + clearTypes: Boolean duration: Duration clearDuration: Boolean count: Uint64 @@ -694,13 +952,17 @@ input UpdateCategoryInput { removeSubCategoryIDs: [ID!] clearSubCategories: Boolean } -"""UpdateFriendshipInput is used for update Friendship object.""" +""" +UpdateFriendshipInput is used for update Friendship object. +""" input UpdateFriendshipInput { createdAt: Time userID: ID friendID: ID } -"""UpdateTodoInput is used for update Todo object.""" +""" +UpdateTodoInput is used for update Todo object. +""" input UpdateTodoInput { status: TodoStatus priority: Int @@ -715,12 +977,15 @@ input UpdateTodoInput { secretID: ID clearSecret: Boolean } -"""UpdateUserInput is used for update User object.""" +""" +UpdateUserInput is used for update User object. +""" input UpdateUserInput { name: String username: UUID password: String clearPassword: Boolean + requiredMetadata: Map metadata: Map clearMetadata: Boolean addGroupIDs: [ID!] @@ -734,73 +999,107 @@ type User implements Node { id: ID! name: String! username: UUID! + requiredMetadata: Map! metadata: Map - """The groups of the user""" + """ + The groups of the user + """ groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList friends( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList friendships( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Friendships returned from the connection.""" + """ + Filtering options for Friendships returned from the connection. + """ where: FriendshipWhereInput ): FriendshipList } -"""An edge in a connection.""" -type UserEdge { - """The item at the end of the edge.""" - node: User -} -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type UserList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [User]! - """The list of edges where each edge holds a data node and possibly metadata.""" - edges: [UserEdge] } -"""Ordering options for User connections""" +""" +Ordering options for User connections +""" input UserOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Users.""" + """ + The field by which to order Users. + """ field: UserOrderField! } -"""Properties by which User connections can be ordered.""" +""" +Properties by which User connections can be ordered. +""" enum UserOrderField { GROUPS_COUNT } -"""UserWhereInput is used for filtering User objects.""" +""" +UserWhereInput is used for filtering User objects. +""" input UserWhereInput { not: UserWhereInput and: [UserWhereInput!] or: [UserWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -809,7 +1108,9 @@ input UserWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -823,7 +1124,9 @@ input UserWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """username field predicates""" + """ + username field predicates + """ username: UUID usernameNEQ: UUID usernameIn: [UUID!] @@ -832,13 +1135,19 @@ input UserWhereInput { usernameGTE: UUID usernameLT: UUID usernameLTE: UUID - """groups edge predicates""" + """ + groups edge predicates + """ hasGroups: Boolean hasGroupsWith: [GroupWhereInput!] - """friends edge predicates""" + """ + friends edge predicates + """ hasFriends: Boolean hasFriendsWith: [UserWhereInput!] - """friendships edge predicates""" + """ + friendships edge predicates + """ hasFriendships: Boolean hasFriendshipsWith: [FriendshipWhereInput!] } diff --git a/entgql/testdata/schema_relay_output.graphql b/entgql/testdata/schema_relay_output.graphql index 0dffdab2f..f94020b0c 100644 --- a/entgql/testdata/schema_relay_output.graphql +++ b/entgql/testdata/schema_relay_output.graphql @@ -1,16 +1,22 @@ -"""Represents BillProduct object""" +""" +Represents BillProduct object +""" type BillProduct implements Node { id: ID! name: String! sku: String! quantity: Uint64! } -"""BillProductWhereInput is used for filtering BillProduct objects.""" +""" +BillProductWhereInput is used for filtering BillProduct objects. +""" input BillProductWhereInput { not: BillProductWhereInput and: [BillProductWhereInput!] or: [BillProductWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -19,7 +25,9 @@ input BillProductWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -33,7 +41,9 @@ input BillProductWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """sku field predicates""" + """ + sku field predicates + """ sku: String skuNEQ: String skuIn: [String!] @@ -47,7 +57,9 @@ input BillProductWhereInput { skuHasSuffix: String skuEqualFold: String skuContainsFold: String - """quantity field predicates""" + """ + quantity field predicates + """ quantity: Uint64 quantityNEQ: Uint64 quantityIn: [Uint64!] @@ -57,82 +69,128 @@ input BillProductWhereInput { quantityLT: Uint64 quantityLTE: Uint64 } -"""Represents Category object""" +""" +Represents Category object +""" type Category implements Node { id: ID! text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList subCategories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList } -"""An edge in a connection.""" +""" +An edge in a connection. +""" type CategoryEdge { - """The item at the end of the edge.""" + """ + The item at the end of the edge. + """ node: Category } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type CategoryList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Category]! - """The list of edges where each edge holds a data node and possibly metadata.""" + """ + The list of edges where each edge holds a data node and possibly metadata. + """ edges: [CategoryEdge] } -"""Ordering options for Category connections""" +""" +Ordering options for Category connections +""" input CategoryOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Categories.""" + """ + The field by which to order Categories. + """ field: CategoryOrderField! } -"""Properties by which Category connections can be ordered.""" +""" +Properties by which Category connections can be ordered. +""" enum CategoryOrderField { ID TEXT + STATUS DURATION COUNT TODOS_COUNT } -"""CategoryStatus is enum for the field status""" +""" +CategoryStatus is enum for the field status +""" enum CategoryStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/category.Status") { ENABLED DISABLED } -"""CategoryWhereInput is used for filtering Category objects.""" +""" +CategoryWhereInput is used for filtering Category objects. +""" input CategoryWhereInput { not: CategoryWhereInput and: [CategoryWhereInput!] or: [CategoryWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -141,7 +199,9 @@ input CategoryWhereInput { idGTE: ID idLT: ID idLTE: ID - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -155,12 +215,16 @@ input CategoryWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """status field predicates""" + """ + status field predicates + """ status: CategoryStatus statusNEQ: CategoryStatus statusIn: [CategoryStatus!] statusNotIn: [CategoryStatus!] - """config field predicates""" + """ + config field predicates + """ config: CategoryConfig configNEQ: CategoryConfig configIn: [CategoryConfig!] @@ -171,7 +235,9 @@ input CategoryWhereInput { configLTE: CategoryConfig configIsNil: Boolean configNotNil: Boolean - """duration field predicates""" + """ + duration field predicates + """ duration: Duration durationNEQ: Duration durationIn: [Duration!] @@ -182,7 +248,9 @@ input CategoryWhereInput { durationLTE: Duration durationIsNil: Boolean durationNotNil: Boolean - """count field predicates""" + """ + count field predicates + """ count: Uint64 countNEQ: Uint64 countIn: [Uint64!] @@ -193,25 +261,34 @@ input CategoryWhereInput { countLTE: Uint64 countIsNil: Boolean countNotNil: Boolean - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] - """sub_categories edge predicates""" + """ + sub_categories edge predicates + """ hasSubCategories: Boolean hasSubCategoriesWith: [CategoryWhereInput!] } -"""CreateCategoryInput is used for create Category object.""" +""" +CreateCategoryInput is used for create Category object. +""" input CreateCategoryInput { text: String! status: CategoryStatus! config: CategoryConfig + types: CategoryTypes duration: Duration count: Uint64 strings: [String!] todoIDs: [ID!] subCategoryIDs: [ID!] } -"""CreateTodoInput is used for create Todo object.""" +""" +CreateTodoInput is used for create Todo object. +""" input CreateTodoInput { status: TodoStatus! priority: Int @@ -222,11 +299,14 @@ input CreateTodoInput { categoryID: ID secretID: ID } -"""CreateUserInput is used for create User object.""" +""" +CreateUserInput is used for create User object. +""" input CreateUserInput { name: String username: UUID password: String + requiredMetadata: Map! metadata: Map groupIDs: [ID!] friendIDs: [ID!] @@ -239,26 +319,42 @@ type Friendship implements Node { user: User! friend: User! } -"""An edge in a connection.""" +""" +An edge in a connection. +""" type FriendshipEdge { - """The item at the end of the edge.""" + """ + The item at the end of the edge. + """ node: Friendship } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type FriendshipList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Friendship]! - """The list of edges where each edge holds a data node and possibly metadata.""" + """ + The list of edges where each edge holds a data node and possibly metadata. + """ edges: [FriendshipEdge] } -"""FriendshipWhereInput is used for filtering Friendship objects.""" +""" +FriendshipWhereInput is used for filtering Friendship objects. +""" input FriendshipWhereInput { not: FriendshipWhereInput and: [FriendshipWhereInput!] or: [FriendshipWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -267,7 +363,9 @@ input FriendshipWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -277,43 +375,67 @@ input FriendshipWhereInput { createdAtLT: Time createdAtLTE: Time } -type Group implements Node @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { +type Group implements Node & NamedNode @hasPermissions(permissions: ["ADMIN","MODERATOR"]) { id: ID! name: String! users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""An edge in a connection.""" +""" +An edge in a connection. +""" type GroupEdge { - """The item at the end of the edge.""" + """ + The item at the end of the edge. + """ node: Group } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type GroupList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Group]! - """The list of edges where each edge holds a data node and possibly metadata.""" + """ + The list of edges where each edge holds a data node and possibly metadata. + """ edges: [GroupEdge] } -"""GroupWhereInput is used for filtering Group objects.""" +""" +GroupWhereInput is used for filtering Group objects. +""" input GroupWhereInput { not: GroupWhereInput and: [GroupWhereInput!] or: [GroupWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -322,7 +444,9 @@ input GroupWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -336,11 +460,15 @@ input GroupWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """users edge predicates""" + """ + users edge predicates + """ hasUsers: Boolean hasUsersWith: [UserWhereInput!] } -"""The builtin Map type""" +""" +The builtin Map type +""" scalar Map type OneToMany implements Node { id: ID! @@ -349,37 +477,61 @@ type OneToMany implements Node { parent: OneToMany children: [OneToMany!] } -"""An edge in a connection.""" +""" +An edge in a connection. +""" type OneToManyEdge { - """The item at the end of the edge.""" + """ + The item at the end of the edge. + """ node: OneToMany } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type OneToManyList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [OneToMany]! - """The list of edges where each edge holds a data node and possibly metadata.""" + """ + The list of edges where each edge holds a data node and possibly metadata. + """ edges: [OneToManyEdge] } -"""Ordering options for OneToMany connections""" +""" +Ordering options for OneToMany connections +""" input OneToManyOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order OneToManies.""" + """ + The field by which to order OneToManies. + """ field: OneToManyOrderField! } -"""Properties by which OneToMany connections can be ordered.""" +""" +Properties by which OneToMany connections can be ordered. +""" enum OneToManyOrderField { NAME } -"""OneToManyWhereInput is used for filtering OneToMany objects.""" +""" +OneToManyWhereInput is used for filtering OneToMany objects. +""" input OneToManyWhereInput { not: OneToManyWhereInput and: [OneToManyWhereInput!] or: [OneToManyWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -388,7 +540,9 @@ input OneToManyWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -402,7 +556,9 @@ input OneToManyWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """field2 field predicates""" + """ + field2 field predicates + """ field2: String field2NEQ: String field2In: [String!] @@ -418,35 +574,90 @@ input OneToManyWhereInput { field2NotNil: Boolean field2EqualFold: String field2ContainsFold: String - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [OneToManyWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [OneToManyWhereInput!] } +type Organization implements Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Workspace") { + id: ID! + name: String! +} +""" +OrganizationWhereInput is used for filtering Workspace objects. +""" +input OrganizationWhereInput { + not: OrganizationWhereInput + and: [OrganizationWhereInput!] + or: [OrganizationWhereInput!] + """ + id field predicates + """ + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """ + name field predicates + """ + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String +} type Project implements Node { id: ID! todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList } -"""ProjectWhereInput is used for filtering Project objects.""" +""" +ProjectWhereInput is used for filtering Project objects. +""" input ProjectWhereInput { not: ProjectWhereInput and: [ProjectWhereInput!] or: [ProjectWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -455,87 +666,139 @@ input ProjectWhereInput { idGTE: ID idLT: ID idLTE: ID - """todos edge predicates""" + """ + todos edge predicates + """ hasTodos: Boolean hasTodosWith: [TodoWhereInput!] } type Query { - """Fetches an object given its ID.""" + """ + Fetches an object given its ID. + """ node( - """ID of the object.""" + """ + ID of the object. + """ id: ID! ): Node - """Lookup nodes by a list of IDs.""" + """ + Lookup nodes by a list of IDs. + """ nodes( - """The list of node IDs.""" + """ + The list of node IDs. + """ ids: [ID!]! ): [Node]! billProducts: [BillProduct!]! categories( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Categories returned from the connection.""" + """ + Ordering options for Categories returned from the connection. + """ orderBy: [CategoryOrder!] - """Filtering options for Categories returned from the connection.""" + """ + Filtering options for Categories returned from the connection. + """ where: CategoryWhereInput ): CategoryList groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList oneToMany( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for OneToManies returned from the connection.""" + """ + Ordering options for OneToManies returned from the connection. + """ orderBy: OneToManyOrder - """Filtering options for OneToManies returned from the connection.""" + """ + Filtering options for OneToManies returned from the connection. + """ where: OneToManyWhereInput ): OneToManyList - """This is the todo item""" + """ + This is the todo item + """ todos( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList users( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList } -"""The builtin Time type""" +""" +The builtin Time type +""" scalar Time type Todo implements Node { id: ID! @@ -549,46 +812,78 @@ type Todo implements Node { init: Map custom: [Custom!] customp: [Custom] - """Todo parent""" + """ + Todo parent + """ parent: Todo - """Todo children""" + """ + Todo children + """ children( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Todos returned from the connection.""" - orderBy: TodoOrder + """ + Ordering options for Todos returned from the connection. + """ + orderBy: [TodoOrder!] - """Filtering options for Todos returned from the connection.""" + """ + Filtering options for Todos returned from the connection. + """ where: TodoWhereInput ): TodoList category: Category } -"""An edge in a connection.""" +""" +An edge in a connection. +""" type TodoEdge { - """The item at the end of the edge.""" + """ + The item at the end of the edge. + """ node: Todo } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type TodoList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [Todo]! - """The list of edges where each edge holds a data node and possibly metadata.""" + """ + The list of edges where each edge holds a data node and possibly metadata. + """ edges: [TodoEdge] } -"""Ordering options for Todo connections""" +""" +Ordering options for Todo connections +""" input TodoOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Todos.""" + """ + The field by which to order Todos. + """ field: TodoOrderField! } -"""Properties by which Todo connections can be ordered.""" +""" +Properties by which Todo connections can be ordered. +""" enum TodoOrderField { CREATED_AT STATUS @@ -598,18 +893,24 @@ enum TodoOrderField { CHILDREN_COUNT CATEGORY_TEXT } -"""TodoStatus is enum for the field status""" +""" +TodoStatus is enum for the field status +""" enum TodoStatus @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent/todo.Status") { IN_PROGRESS COMPLETED PENDING } -"""TodoWhereInput is used for filtering Todo objects.""" +""" +TodoWhereInput is used for filtering Todo objects. +""" input TodoWhereInput { not: TodoWhereInput and: [TodoWhereInput!] or: [TodoWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -618,7 +919,9 @@ input TodoWhereInput { idGTE: ID idLT: ID idLTE: ID - """created_at field predicates""" + """ + created_at field predicates + """ createdAt: Time createdAtNEQ: Time createdAtIn: [Time!] @@ -627,12 +930,16 @@ input TodoWhereInput { createdAtGTE: Time createdAtLT: Time createdAtLTE: Time - """status field predicates""" + """ + status field predicates + """ status: TodoStatus statusNEQ: TodoStatus statusIn: [TodoStatus!] statusNotIn: [TodoStatus!] - """priority field predicates""" + """ + priority field predicates + """ priority: Int priorityNEQ: Int priorityIn: [Int!] @@ -641,7 +948,9 @@ input TodoWhereInput { priorityGTE: Int priorityLT: Int priorityLTE: Int - """text field predicates""" + """ + text field predicates + """ text: String textNEQ: String textIn: [String!] @@ -655,31 +964,45 @@ input TodoWhereInput { textHasSuffix: String textEqualFold: String textContainsFold: String - """category_id field predicates""" + """ + category_id field predicates + """ categoryID: ID categoryIDNEQ: ID categoryIDIn: [ID!] categoryIDNotIn: [ID!] categoryIDIsNil: Boolean categoryIDNotNil: Boolean - """parent edge predicates""" + """ + parent edge predicates + """ hasParent: Boolean hasParentWith: [TodoWhereInput!] - """children edge predicates""" + """ + children edge predicates + """ hasChildren: Boolean hasChildrenWith: [TodoWhereInput!] - """category edge predicates""" + """ + category edge predicates + """ hasCategory: Boolean hasCategoryWith: [CategoryWhereInput!] } -"""The builtin Uint64 type""" +""" +The builtin Uint64 type +""" scalar Uint64 -"""UpdateCategoryInput is used for update Category object.""" +""" +UpdateCategoryInput is used for update Category object. +""" input UpdateCategoryInput { text: String status: CategoryStatus config: CategoryConfig clearConfig: Boolean + types: CategoryTypes + clearTypes: Boolean duration: Duration clearDuration: Boolean count: Uint64 @@ -694,13 +1017,17 @@ input UpdateCategoryInput { removeSubCategoryIDs: [ID!] clearSubCategories: Boolean } -"""UpdateFriendshipInput is used for update Friendship object.""" +""" +UpdateFriendshipInput is used for update Friendship object. +""" input UpdateFriendshipInput { createdAt: Time userID: ID friendID: ID } -"""UpdateTodoInput is used for update Todo object.""" +""" +UpdateTodoInput is used for update Todo object. +""" input UpdateTodoInput { status: TodoStatus priority: Int @@ -715,12 +1042,15 @@ input UpdateTodoInput { secretID: ID clearSecret: Boolean } -"""UpdateUserInput is used for update User object.""" +""" +UpdateUserInput is used for update User object. +""" input UpdateUserInput { name: String username: UUID password: String clearPassword: Boolean + requiredMetadata: Map metadata: Map clearMetadata: Boolean addGroupIDs: [ID!] @@ -734,73 +1064,120 @@ type User implements Node { id: ID! name: String! username: UUID! + requiredMetadata: Map! metadata: Map - """The groups of the user""" + """ + The groups of the user + """ groups( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Groups returned from the connection.""" + """ + Filtering options for Groups returned from the connection. + """ where: GroupWhereInput ): GroupList friends( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Ordering options for Users returned from the connection.""" + """ + Ordering options for Users returned from the connection. + """ orderBy: UserOrder - """Filtering options for Users returned from the connection.""" + """ + Filtering options for Users returned from the connection. + """ where: UserWhereInput ): UserList friendships( - """Pagination limit.""" + """ + Pagination limit. + """ limit: Int = 100 - """Pagination offset.""" + """ + Pagination offset. + """ offset: Int = 0 - """Filtering options for Friendships returned from the connection.""" + """ + Filtering options for Friendships returned from the connection. + """ where: FriendshipWhereInput ): FriendshipList } -"""An edge in a connection.""" +""" +An edge in a connection. +""" type UserEdge { - """The item at the end of the edge.""" + """ + The item at the end of the edge. + """ node: User } -"""A connection to a list of items.""" +""" +A connection to a list of items. +""" type UserList { - """Identifies the total count of data items.""" + """ + Identifies the total count of data items. + """ totalCount: Int! - """The list of data items.""" + """ + The list of data items. + """ items: [User]! - """The list of edges where each edge holds a data node and possibly metadata.""" + """ + The list of edges where each edge holds a data node and possibly metadata. + """ edges: [UserEdge] } -"""Ordering options for User connections""" +""" +Ordering options for User connections +""" input UserOrder { - """The ordering direction.""" + """ + The ordering direction. + """ direction: OrderDirection! = ASC - """The field by which to order Users.""" + """ + The field by which to order Users. + """ field: UserOrderField! } -"""Properties by which User connections can be ordered.""" +""" +Properties by which User connections can be ordered. +""" enum UserOrderField { GROUPS_COUNT } -"""UserWhereInput is used for filtering User objects.""" +""" +UserWhereInput is used for filtering User objects. +""" input UserWhereInput { not: UserWhereInput and: [UserWhereInput!] or: [UserWhereInput!] - """id field predicates""" + """ + id field predicates + """ id: ID idNEQ: ID idIn: [ID!] @@ -809,7 +1186,9 @@ input UserWhereInput { idGTE: ID idLT: ID idLTE: ID - """name field predicates""" + """ + name field predicates + """ name: String nameNEQ: String nameIn: [String!] @@ -823,7 +1202,9 @@ input UserWhereInput { nameHasSuffix: String nameEqualFold: String nameContainsFold: String - """username field predicates""" + """ + username field predicates + """ username: UUID usernameNEQ: UUID usernameIn: [UUID!] @@ -832,13 +1213,19 @@ input UserWhereInput { usernameGTE: UUID usernameLT: UUID usernameLTE: UUID - """groups edge predicates""" + """ + groups edge predicates + """ hasGroups: Boolean hasGroupsWith: [GroupWhereInput!] - """friends edge predicates""" + """ + friends edge predicates + """ hasFriends: Boolean hasFriendsWith: [UserWhereInput!] - """friendships edge predicates""" + """ + friendships edge predicates + """ hasFriendships: Boolean hasFriendshipsWith: [FriendshipWhereInput!] } diff --git a/entgql/transaction.go b/entgql/transaction.go index d3f0d42d3..ff9a81fdb 100644 --- a/entgql/transaction.go +++ b/entgql/transaction.go @@ -18,6 +18,7 @@ import ( "context" "database/sql/driver" "errors" + "slices" "sync" "github.com/99designs/gqlgen/graphql" @@ -39,8 +40,35 @@ func (f TxOpenerFunc) OpenTx(ctx context.Context) (context.Context, driver.Tx, e return f(ctx) } -// Transactioner for graphql mutations. -type Transactioner struct{ TxOpener } +type ( + // Transactioner for graphql mutations. + Transactioner struct { + TxOpener + SkipTxFunc + } + // SkipTxFunc allows skipping operations from + // running under a transaction. + SkipTxFunc func(*ast.OperationDefinition) bool +) + +// SkipOperations skips the given operation names from running +// under a transaction. +func SkipOperations(names ...string) SkipTxFunc { + return func(op *ast.OperationDefinition) bool { + return slices.Contains(names, op.Name) + } +} + +// SkipIfHasFields skips the operation has a mutation field +// with the given names. +func SkipIfHasFields(names ...string) SkipTxFunc { + return func(op *ast.OperationDefinition) bool { + return slices.ContainsFunc(op.SelectionSet, func(s ast.Selection) bool { + f, ok := s.(*ast.Field) + return ok && slices.Contains(names, f.Name) + }) + } +} var _ interface { graphql.HandlerExtension @@ -62,8 +90,8 @@ func (t Transactioner) Validate(graphql.ExecutableSchema) error { } // MutateOperationContext serializes field resolvers during mutations. -func (Transactioner) MutateOperationContext(_ context.Context, oc *graphql.OperationContext) *gqlerror.Error { - if op := oc.Operation; op != nil && op.Operation == ast.Mutation { +func (t Transactioner) MutateOperationContext(_ context.Context, oc *graphql.OperationContext) *gqlerror.Error { + if !t.skipTx(oc.Operation) { previous := oc.ResolverMiddleware var mu sync.Mutex oc.ResolverMiddleware = func(ctx context.Context, next graphql.Resolver) (interface{}, error) { @@ -77,7 +105,7 @@ func (Transactioner) MutateOperationContext(_ context.Context, oc *graphql.Opera // InterceptResponse runs graphql mutations under a transaction. func (t Transactioner) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { - if op := graphql.GetOperationContext(ctx).Operation; op == nil || op.Operation != ast.Mutation { + if t.skipTx(graphql.GetOperationContext(ctx).Operation) { return next(ctx) } txCtx, tx, err := t.OpenTx(ctx) @@ -108,3 +136,7 @@ func (t Transactioner) InterceptResponse(ctx context.Context, next graphql.Respo } return rsp } + +func (t Transactioner) skipTx(op *ast.OperationDefinition) bool { + return op == nil || op.Operation != ast.Mutation || (t.SkipTxFunc != nil && t.SkipTxFunc(op)) +} diff --git a/entgql/transaction_test.go b/entgql/transaction_test.go index ea75e04e8..9bbacfabb 100644 --- a/entgql/transaction_test.go +++ b/entgql/transaction_test.go @@ -30,10 +30,10 @@ import ( ) func TestTransaction(t *testing.T) { - newServer := func(opener entgql.TxOpener) *testserver.TestServer { + newServer := func(opener entgql.TxOpener, skip entgql.SkipTxFunc) *testserver.TestServer { srv := testserver.New() srv.AddTransport(transport.POST{}) - srv.Use(entgql.Transactioner{TxOpener: opener}) + srv.Use(entgql.Transactioner{TxOpener: opener, SkipTxFunc: skip}) return srv } fwdCtx := func(ctx context.Context) context.Context { @@ -44,7 +44,7 @@ func TestTransaction(t *testing.T) { t.Parallel() var opener mocks.TxOpener defer opener.AssertExpectations(t) - srv := newServer(&opener) + srv := newServer(&opener, nil) c := client.New(srv) err := c.Post(`query { name }`, &struct{ Name string }{}) @@ -65,7 +65,7 @@ func TestTransaction(t *testing.T) { Once() defer opener.AssertExpectations(t) - srv := newServer(&opener) + srv := newServer(&opener, nil) srv.AroundResponses(func(context.Context, graphql.ResponseHandler) *graphql.Response { return &graphql.Response{Data: []byte(`{"name":"test"}`)} }) @@ -74,6 +74,68 @@ func TestTransaction(t *testing.T) { err := c.Post(`mutation { name }`, &struct{ Name string }{}) require.NoError(t, err) }) + + t.Run("SkipOperation", func(t *testing.T) { + var ( + tx mocks.Tx + opener mocks.TxOpener + ) + tx.On("Commit"). + Return(nil). + Once() + defer tx.AssertExpectations(t) + + srv := newServer(&opener, entgql.SkipOperations("skipped")) + srv.AroundResponses(func(context.Context, graphql.ResponseHandler) *graphql.Response { + return &graphql.Response{Data: []byte(`{"name":"test"}`)} + }) + + c := client.New(srv) + err := c.Post(`mutation skipped { name }`, &struct{ Name string }{}) + require.NoError(t, err) + opener.AssertExpectations(t) + + opener.On("OpenTx", mock.Anything). + Return(fwdCtx, &tx, nil). + Once() + err = c.Post(`mutation notSkipped { name }`, &struct{ Name string }{}) + require.NoError(t, err) + opener.AssertExpectations(t) + }) + + t.Run("SkipIfHasFields", func(t *testing.T) { + var ( + tx mocks.Tx + opener mocks.TxOpener + ) + tx.On("Commit"). + Return(nil). + Once() + defer tx.AssertExpectations(t) + defer opener.AssertExpectations(t) + + srv := newServer(&opener, entgql.SkipIfHasFields("name")) + srv.AroundResponses(func(context.Context, graphql.ResponseHandler) *graphql.Response { + return &graphql.Response{Data: []byte(`{"name":"test"}`)} + }) + c := client.New(srv) + err := c.Post(`mutation { name }`, &struct{ Name string }{}) + require.NoError(t, err) + opener.AssertExpectations(t) + + opener.On("OpenTx", mock.Anything). + Return(fwdCtx, &tx, nil). + Once() + srv = newServer(&opener, entgql.SkipIfHasFields("work")) + srv.AroundResponses(func(context.Context, graphql.ResponseHandler) *graphql.Response { + return &graphql.Response{Data: []byte(`{"name":"test"}`)} + }) + c = client.New(srv) + err = c.Post(`mutation { name }`, &struct{ Name string }{}) + require.NoError(t, err) + opener.AssertExpectations(t) + }) + t.Run("Err", func(t *testing.T) { t.Parallel() var tx mocks.Tx @@ -88,7 +150,7 @@ func TestTransaction(t *testing.T) { Once() defer opener.AssertExpectations(t) - srv := newServer(&opener) + srv := newServer(&opener, nil) srv.AroundResponses(func(ctx context.Context, _ graphql.ResponseHandler) *graphql.Response { return graphql.ErrorResponse(ctx, "bad mutation") }) @@ -112,7 +174,7 @@ func TestTransaction(t *testing.T) { Once() defer opener.AssertExpectations(t) - srv := newServer(&opener) + srv := newServer(&opener, nil) srv.SetRecoverFunc(func(_ context.Context, err interface{}) error { return err.(error) }) @@ -133,7 +195,7 @@ func TestTransaction(t *testing.T) { Once() defer opener.AssertExpectations(t) - srv := newServer(&opener) + srv := newServer(&opener, nil) c := client.New(srv) err := c.Post(`mutation { name }`, &struct{ Name string }{}) require.Error(t, err) diff --git a/entoas/extension.go b/entoas/extension.go index e4ff4c950..5c155ec3b 100644 --- a/entoas/extension.go +++ b/entoas/extension.go @@ -43,6 +43,9 @@ type ( // By enabling she SimpleModels configuration the generator simply adds the defined schemas with all fields and edges. // Serialization groups have no effects in this mode. SimpleModels bool + // When enabled, allows the built-in "id" field as part of the POST payload for entity creation, allowing the client to supply UUIDs as primary keys and for idempotency. + // Defaults to false. + AllowClientUUIDs bool // Specify the minimum amount of itemsPerPage allowed in generated pagination. // Defaults to 1. MinItemsPerPage int64 @@ -134,6 +137,16 @@ func SimpleModels() ExtensionOption { } } +// AllowClientUUIDs enables the client supplied IDs feature. +// +// Further information can be found at Config.AllowClientUUIDs. +func AllowClientUUIDs() ExtensionOption { + return func(ex *Extension) error { + ex.config.AllowClientUUIDs = true + return nil + } +} + // WriteTo writes the current specs content to the given io.Writer. func WriteTo(out io.Writer) ExtensionOption { return func(ex *Extension) error { diff --git a/entoas/generator.go b/entoas/generator.go index c6ae5d059..0a2d6f8ee 100644 --- a/entoas/generator.go +++ b/entoas/generator.go @@ -25,6 +25,7 @@ import ( "strings" "entgo.io/ent/entc/gen" + "entgo.io/ent/schema/field" "github.com/go-openapi/inflect" "github.com/ogen-go/ogen" "github.com/stoewer/go-strcase" @@ -181,6 +182,11 @@ var rules = inflect.NewDefaultRuleset() // paths adds all operations to the spec paths. func paths(g *gen.Graph, spec *ogen.Spec) error { + cfg, err := GetConfig(g.Config) + if err != nil { + return err + } + for _, n := range g.Nodes { // Add schema operations. ops, err := NodeOperations(n) @@ -191,7 +197,7 @@ func paths(g *gen.Graph, spec *ogen.Spec) error { root := "/" + rules.Pluralize(strcase.KebabCase(n.Name)) // Create operation. if contains(ops, OpCreate) { - path(spec, root).Post, err = createOp(spec, n) + path(spec, root).Post, err = createOp(spec, n, cfg.AllowClientUUIDs) if err != nil { return err } @@ -262,8 +268,8 @@ func path(s *ogen.Spec, root string) *ogen.PathItem { } // createOp returns an ogen.Operation for a create operation on the given node. -func createOp(spec *ogen.Spec, n *gen.Type) (*ogen.Operation, error) { - req, err := reqBody(n, OpCreate) +func createOp(spec *ogen.Spec, n *gen.Type, allowClientUUIDs bool) (*ogen.Operation, error) { + req, err := reqBody(n, OpCreate, allowClientUUIDs) if err != nil { return nil, err } @@ -358,7 +364,7 @@ func readEdgeOp(spec *ogen.Spec, n *gen.Type, e *gen.Edge) (*ogen.Operation, err // updateOp returns a spec.OperationConfig for an update operation on the given node. func updateOp(spec *ogen.Spec, n *gen.Type) (*ogen.Operation, error) { - req, err := reqBody(n, OpUpdate) + req, err := reqBody(n, OpUpdate, false) if err != nil { return nil, err } @@ -677,17 +683,26 @@ func EdgeOperations(e *gen.Edge) ([]Operation, error) { } // reqBody returns the request body for the given node and operation. -func reqBody(n *gen.Type, op Operation) (*ogen.RequestBody, error) { +func reqBody(n *gen.Type, op Operation, allowClientUUIDs bool) (*ogen.RequestBody, error) { req := ogen.NewRequestBody().SetRequired(true) + c := ogen.NewSchema() switch op { case OpCreate: + // add the ID field as client setable if it is a UUID. + if allowClientUUIDs && n.ID.Type.Type == field.TypeUUID { + p, err := property(n.ID) + if err != nil { + return nil, err + } + addProperty(c, p, !n.ID.Default) + } + req.SetDescription(fmt.Sprintf("%s to create", n.Name)) case OpUpdate: req.SetDescription(fmt.Sprintf("%s properties to update", n.Name)) default: return nil, fmt.Errorf("requestBody: unsupported operation %q", op) } - c := ogen.NewSchema() for _, f := range n.Fields { a, err := FieldAnnotation(f) if err != nil { diff --git a/entoas/internal/cycle/client.go b/entoas/internal/cycle/client.go index 5cbeb5a87..0df7ce429 100644 --- a/entoas/internal/cycle/client.go +++ b/entoas/internal/cycle/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entoas/internal/cycle/migrate" "entgo.io/ent" @@ -28,9 +29,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -58,6 +57,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -105,11 +111,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("cycle: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("cycle: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -221,6 +230,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) diff --git a/entoas/internal/cycle/runtime/runtime.go b/entoas/internal/cycle/runtime/runtime.go index 780e60b13..22131ab7c 100644 --- a/entoas/internal/cycle/runtime/runtime.go +++ b/entoas/internal/cycle/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entoas/internal/cycle/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entoas/internal/cycle/user/where.go b/entoas/internal/cycle/user/where.go index b89c317a7..994776e74 100644 --- a/entoas/internal/cycle/user/where.go +++ b/entoas/internal/cycle/user/where.go @@ -170,32 +170,15 @@ func HasChildrenWith(preds ...predicate.User) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entoas/internal/cycle/user_create.go b/entoas/internal/cycle/user_create.go index d28c7c66c..d2577f3c2 100644 --- a/entoas/internal/cycle/user_create.go +++ b/entoas/internal/cycle/user_create.go @@ -104,7 +104,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -244,11 +244,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entoas/internal/cycle/user_delete.go b/entoas/internal/cycle/user_delete.go index 67e3ed79f..05a0b9937 100644 --- a/entoas/internal/cycle/user_delete.go +++ b/entoas/internal/cycle/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entoas/internal/cycle/user_update.go b/entoas/internal/cycle/user_update.go index 3fdea89de..8f4603ead 100644 --- a/entoas/internal/cycle/user_update.go +++ b/entoas/internal/cycle/user_update.go @@ -203,7 +203,7 @@ func (uu *UserUpdate) RemoveChildren(u ...*User) *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -655,7 +655,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entoas/internal/oastypes/client.go b/entoas/internal/oastypes/client.go index af2cb2130..95c8ba4ce 100644 --- a/entoas/internal/oastypes/client.go +++ b/entoas/internal/oastypes/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entoas/internal/oastypes/migrate" "entgo.io/ent" @@ -27,9 +28,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -57,6 +56,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -104,11 +110,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("oastypes: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("oastypes: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -220,6 +229,21 @@ func (c *OASTypesClient) CreateBulk(builders ...*OASTypesCreate) *OASTypesCreate return &OASTypesCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *OASTypesClient) MapCreateBulk(slice any, setFunc func(*OASTypesCreate, int)) *OASTypesCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &OASTypesCreateBulk{err: fmt.Errorf("calling to OASTypesClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*OASTypesCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &OASTypesCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for OASTypes. func (c *OASTypesClient) Update() *OASTypesUpdate { mutation := newOASTypesMutation(c.config, OpUpdate) diff --git a/entoas/internal/oastypes/oastypes/where.go b/entoas/internal/oastypes/oastypes/where.go index f368057d7..58c740ae6 100644 --- a/entoas/internal/oastypes/oastypes/where.go +++ b/entoas/internal/oastypes/oastypes/where.go @@ -1108,32 +1108,15 @@ func OptionalAndNillableNotNil() predicate.OASTypes { // And groups predicates with the AND operator between them. func And(predicates ...predicate.OASTypes) predicate.OASTypes { - return predicate.OASTypes(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.OASTypes(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.OASTypes) predicate.OASTypes { - return predicate.OASTypes(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.OASTypes(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.OASTypes) predicate.OASTypes { - return predicate.OASTypes(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.OASTypes(sql.NotPredicates(p)) } diff --git a/entoas/internal/oastypes/oastypes_create.go b/entoas/internal/oastypes/oastypes_create.go index 5e4699aa0..8ad55cb81 100644 --- a/entoas/internal/oastypes/oastypes_create.go +++ b/entoas/internal/oastypes/oastypes_create.go @@ -230,7 +230,7 @@ func (otc *OASTypesCreate) Mutation() *OASTypesMutation { // Save creates the OASTypes in the database. func (otc *OASTypesCreate) Save(ctx context.Context) (*OASTypes, error) { otc.defaults() - return withHooks[*OASTypes, OASTypesMutation](ctx, otc.sqlSave, otc.mutation, otc.hooks) + return withHooks(ctx, otc.sqlSave, otc.mutation, otc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -503,11 +503,15 @@ func (otc *OASTypesCreate) createSpec() (*OASTypes, *sqlgraph.CreateSpec) { // OASTypesCreateBulk is the builder for creating many OASTypes entities in bulk. type OASTypesCreateBulk struct { config + err error builders []*OASTypesCreate } // Save creates the OASTypes entities in the database. func (otcb *OASTypesCreateBulk) Save(ctx context.Context) ([]*OASTypes, error) { + if otcb.err != nil { + return nil, otcb.err + } specs := make([]*sqlgraph.CreateSpec, len(otcb.builders)) nodes := make([]*OASTypes, len(otcb.builders)) mutators := make([]Mutator, len(otcb.builders)) diff --git a/entoas/internal/oastypes/oastypes_delete.go b/entoas/internal/oastypes/oastypes_delete.go index 698546d6b..8497c85a3 100644 --- a/entoas/internal/oastypes/oastypes_delete.go +++ b/entoas/internal/oastypes/oastypes_delete.go @@ -27,7 +27,7 @@ func (otd *OASTypesDelete) Where(ps ...predicate.OASTypes) *OASTypesDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (otd *OASTypesDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, OASTypesMutation](ctx, otd.sqlExec, otd.mutation, otd.hooks) + return withHooks(ctx, otd.sqlExec, otd.mutation, otd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entoas/internal/oastypes/oastypes_update.go b/entoas/internal/oastypes/oastypes_update.go index d02b456a0..0146cc8f7 100644 --- a/entoas/internal/oastypes/oastypes_update.go +++ b/entoas/internal/oastypes/oastypes_update.go @@ -40,6 +40,14 @@ func (otu *OASTypesUpdate) SetInt(i int) *OASTypesUpdate { return otu } +// SetNillableInt sets the "int" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableInt(i *int) *OASTypesUpdate { + if i != nil { + otu.SetInt(*i) + } + return otu +} + // AddInt adds i to the "int" field. func (otu *OASTypesUpdate) AddInt(i int) *OASTypesUpdate { otu.mutation.AddInt(i) @@ -53,6 +61,14 @@ func (otu *OASTypesUpdate) SetInt8(i int8) *OASTypesUpdate { return otu } +// SetNillableInt8 sets the "int8" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableInt8(i *int8) *OASTypesUpdate { + if i != nil { + otu.SetInt8(*i) + } + return otu +} + // AddInt8 adds i to the "int8" field. func (otu *OASTypesUpdate) AddInt8(i int8) *OASTypesUpdate { otu.mutation.AddInt8(i) @@ -66,6 +82,14 @@ func (otu *OASTypesUpdate) SetInt16(i int16) *OASTypesUpdate { return otu } +// SetNillableInt16 sets the "int16" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableInt16(i *int16) *OASTypesUpdate { + if i != nil { + otu.SetInt16(*i) + } + return otu +} + // AddInt16 adds i to the "int16" field. func (otu *OASTypesUpdate) AddInt16(i int16) *OASTypesUpdate { otu.mutation.AddInt16(i) @@ -79,6 +103,14 @@ func (otu *OASTypesUpdate) SetInt32(i int32) *OASTypesUpdate { return otu } +// SetNillableInt32 sets the "int32" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableInt32(i *int32) *OASTypesUpdate { + if i != nil { + otu.SetInt32(*i) + } + return otu +} + // AddInt32 adds i to the "int32" field. func (otu *OASTypesUpdate) AddInt32(i int32) *OASTypesUpdate { otu.mutation.AddInt32(i) @@ -92,6 +124,14 @@ func (otu *OASTypesUpdate) SetInt64(i int64) *OASTypesUpdate { return otu } +// SetNillableInt64 sets the "int64" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableInt64(i *int64) *OASTypesUpdate { + if i != nil { + otu.SetInt64(*i) + } + return otu +} + // AddInt64 adds i to the "int64" field. func (otu *OASTypesUpdate) AddInt64(i int64) *OASTypesUpdate { otu.mutation.AddInt64(i) @@ -105,6 +145,14 @@ func (otu *OASTypesUpdate) SetUint(u uint) *OASTypesUpdate { return otu } +// SetNillableUint sets the "uint" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableUint(u *uint) *OASTypesUpdate { + if u != nil { + otu.SetUint(*u) + } + return otu +} + // AddUint adds u to the "uint" field. func (otu *OASTypesUpdate) AddUint(u int) *OASTypesUpdate { otu.mutation.AddUint(u) @@ -118,6 +166,14 @@ func (otu *OASTypesUpdate) SetUint8(u uint8) *OASTypesUpdate { return otu } +// SetNillableUint8 sets the "uint8" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableUint8(u *uint8) *OASTypesUpdate { + if u != nil { + otu.SetUint8(*u) + } + return otu +} + // AddUint8 adds u to the "uint8" field. func (otu *OASTypesUpdate) AddUint8(u int8) *OASTypesUpdate { otu.mutation.AddUint8(u) @@ -131,6 +187,14 @@ func (otu *OASTypesUpdate) SetUint16(u uint16) *OASTypesUpdate { return otu } +// SetNillableUint16 sets the "uint16" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableUint16(u *uint16) *OASTypesUpdate { + if u != nil { + otu.SetUint16(*u) + } + return otu +} + // AddUint16 adds u to the "uint16" field. func (otu *OASTypesUpdate) AddUint16(u int16) *OASTypesUpdate { otu.mutation.AddUint16(u) @@ -144,6 +208,14 @@ func (otu *OASTypesUpdate) SetUint32(u uint32) *OASTypesUpdate { return otu } +// SetNillableUint32 sets the "uint32" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableUint32(u *uint32) *OASTypesUpdate { + if u != nil { + otu.SetUint32(*u) + } + return otu +} + // AddUint32 adds u to the "uint32" field. func (otu *OASTypesUpdate) AddUint32(u int32) *OASTypesUpdate { otu.mutation.AddUint32(u) @@ -157,6 +229,14 @@ func (otu *OASTypesUpdate) SetUint64(u uint64) *OASTypesUpdate { return otu } +// SetNillableUint64 sets the "uint64" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableUint64(u *uint64) *OASTypesUpdate { + if u != nil { + otu.SetUint64(*u) + } + return otu +} + // AddUint64 adds u to the "uint64" field. func (otu *OASTypesUpdate) AddUint64(u int64) *OASTypesUpdate { otu.mutation.AddUint64(u) @@ -170,6 +250,14 @@ func (otu *OASTypesUpdate) SetFloat32(f float32) *OASTypesUpdate { return otu } +// SetNillableFloat32 sets the "float32" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableFloat32(f *float32) *OASTypesUpdate { + if f != nil { + otu.SetFloat32(*f) + } + return otu +} + // AddFloat32 adds f to the "float32" field. func (otu *OASTypesUpdate) AddFloat32(f float32) *OASTypesUpdate { otu.mutation.AddFloat32(f) @@ -183,6 +271,14 @@ func (otu *OASTypesUpdate) SetFloat64(f float64) *OASTypesUpdate { return otu } +// SetNillableFloat64 sets the "float64" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableFloat64(f *float64) *OASTypesUpdate { + if f != nil { + otu.SetFloat64(*f) + } + return otu +} + // AddFloat64 adds f to the "float64" field. func (otu *OASTypesUpdate) AddFloat64(f float64) *OASTypesUpdate { otu.mutation.AddFloat64(f) @@ -195,12 +291,28 @@ func (otu *OASTypesUpdate) SetStringField(s string) *OASTypesUpdate { return otu } +// SetNillableStringField sets the "string_field" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableStringField(s *string) *OASTypesUpdate { + if s != nil { + otu.SetStringField(*s) + } + return otu +} + // SetBool sets the "bool" field. func (otu *OASTypesUpdate) SetBool(b bool) *OASTypesUpdate { otu.mutation.SetBool(b) return otu } +// SetNillableBool sets the "bool" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableBool(b *bool) *OASTypesUpdate { + if b != nil { + otu.SetBool(*b) + } + return otu +} + // SetUUID sets the "uuid" field. func (otu *OASTypesUpdate) SetUUID(u uuid.UUID) *OASTypesUpdate { otu.mutation.SetUUID(u) @@ -221,18 +333,42 @@ func (otu *OASTypesUpdate) SetTime(t time.Time) *OASTypesUpdate { return otu } +// SetNillableTime sets the "time" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableTime(t *time.Time) *OASTypesUpdate { + if t != nil { + otu.SetTime(*t) + } + return otu +} + // SetText sets the "text" field. func (otu *OASTypesUpdate) SetText(s string) *OASTypesUpdate { otu.mutation.SetText(s) return otu } +// SetNillableText sets the "text" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableText(s *string) *OASTypesUpdate { + if s != nil { + otu.SetText(*s) + } + return otu +} + // SetState sets the "state" field. func (otu *OASTypesUpdate) SetState(o oastypes.State) *OASTypesUpdate { otu.mutation.SetState(o) return otu } +// SetNillableState sets the "state" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableState(o *oastypes.State) *OASTypesUpdate { + if o != nil { + otu.SetState(*o) + } + return otu +} + // SetStrings sets the "strings" field. func (otu *OASTypesUpdate) SetStrings(s []string) *OASTypesUpdate { otu.mutation.SetStrings(s) @@ -305,6 +441,14 @@ func (otu *OASTypesUpdate) SetJSONObj(u url.URL) *OASTypesUpdate { return otu } +// SetNillableJSONObj sets the "json_obj" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableJSONObj(u *url.URL) *OASTypesUpdate { + if u != nil { + otu.SetJSONObj(*u) + } + return otu +} + // SetOther sets the "other" field. func (otu *OASTypesUpdate) SetOther(s *schema.Link) *OASTypesUpdate { otu.mutation.SetOther(s) @@ -345,6 +489,14 @@ func (otu *OASTypesUpdate) SetNillable(i int) *OASTypesUpdate { return otu } +// SetNillableNillable sets the "nillable" field if the given value is not nil. +func (otu *OASTypesUpdate) SetNillableNillable(i *int) *OASTypesUpdate { + if i != nil { + otu.SetNillable(*i) + } + return otu +} + // AddNillable adds i to the "nillable" field. func (otu *OASTypesUpdate) AddNillable(i int) *OASTypesUpdate { otu.mutation.AddNillable(i) @@ -385,7 +537,7 @@ func (otu *OASTypesUpdate) Mutation() *OASTypesMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (otu *OASTypesUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, OASTypesMutation](ctx, otu.sqlSave, otu.mutation, otu.hooks) + return withHooks(ctx, otu.sqlSave, otu.mutation, otu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -622,6 +774,14 @@ func (otuo *OASTypesUpdateOne) SetInt(i int) *OASTypesUpdateOne { return otuo } +// SetNillableInt sets the "int" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableInt(i *int) *OASTypesUpdateOne { + if i != nil { + otuo.SetInt(*i) + } + return otuo +} + // AddInt adds i to the "int" field. func (otuo *OASTypesUpdateOne) AddInt(i int) *OASTypesUpdateOne { otuo.mutation.AddInt(i) @@ -635,6 +795,14 @@ func (otuo *OASTypesUpdateOne) SetInt8(i int8) *OASTypesUpdateOne { return otuo } +// SetNillableInt8 sets the "int8" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableInt8(i *int8) *OASTypesUpdateOne { + if i != nil { + otuo.SetInt8(*i) + } + return otuo +} + // AddInt8 adds i to the "int8" field. func (otuo *OASTypesUpdateOne) AddInt8(i int8) *OASTypesUpdateOne { otuo.mutation.AddInt8(i) @@ -648,6 +816,14 @@ func (otuo *OASTypesUpdateOne) SetInt16(i int16) *OASTypesUpdateOne { return otuo } +// SetNillableInt16 sets the "int16" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableInt16(i *int16) *OASTypesUpdateOne { + if i != nil { + otuo.SetInt16(*i) + } + return otuo +} + // AddInt16 adds i to the "int16" field. func (otuo *OASTypesUpdateOne) AddInt16(i int16) *OASTypesUpdateOne { otuo.mutation.AddInt16(i) @@ -661,6 +837,14 @@ func (otuo *OASTypesUpdateOne) SetInt32(i int32) *OASTypesUpdateOne { return otuo } +// SetNillableInt32 sets the "int32" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableInt32(i *int32) *OASTypesUpdateOne { + if i != nil { + otuo.SetInt32(*i) + } + return otuo +} + // AddInt32 adds i to the "int32" field. func (otuo *OASTypesUpdateOne) AddInt32(i int32) *OASTypesUpdateOne { otuo.mutation.AddInt32(i) @@ -674,6 +858,14 @@ func (otuo *OASTypesUpdateOne) SetInt64(i int64) *OASTypesUpdateOne { return otuo } +// SetNillableInt64 sets the "int64" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableInt64(i *int64) *OASTypesUpdateOne { + if i != nil { + otuo.SetInt64(*i) + } + return otuo +} + // AddInt64 adds i to the "int64" field. func (otuo *OASTypesUpdateOne) AddInt64(i int64) *OASTypesUpdateOne { otuo.mutation.AddInt64(i) @@ -687,6 +879,14 @@ func (otuo *OASTypesUpdateOne) SetUint(u uint) *OASTypesUpdateOne { return otuo } +// SetNillableUint sets the "uint" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableUint(u *uint) *OASTypesUpdateOne { + if u != nil { + otuo.SetUint(*u) + } + return otuo +} + // AddUint adds u to the "uint" field. func (otuo *OASTypesUpdateOne) AddUint(u int) *OASTypesUpdateOne { otuo.mutation.AddUint(u) @@ -700,6 +900,14 @@ func (otuo *OASTypesUpdateOne) SetUint8(u uint8) *OASTypesUpdateOne { return otuo } +// SetNillableUint8 sets the "uint8" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableUint8(u *uint8) *OASTypesUpdateOne { + if u != nil { + otuo.SetUint8(*u) + } + return otuo +} + // AddUint8 adds u to the "uint8" field. func (otuo *OASTypesUpdateOne) AddUint8(u int8) *OASTypesUpdateOne { otuo.mutation.AddUint8(u) @@ -713,6 +921,14 @@ func (otuo *OASTypesUpdateOne) SetUint16(u uint16) *OASTypesUpdateOne { return otuo } +// SetNillableUint16 sets the "uint16" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableUint16(u *uint16) *OASTypesUpdateOne { + if u != nil { + otuo.SetUint16(*u) + } + return otuo +} + // AddUint16 adds u to the "uint16" field. func (otuo *OASTypesUpdateOne) AddUint16(u int16) *OASTypesUpdateOne { otuo.mutation.AddUint16(u) @@ -726,6 +942,14 @@ func (otuo *OASTypesUpdateOne) SetUint32(u uint32) *OASTypesUpdateOne { return otuo } +// SetNillableUint32 sets the "uint32" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableUint32(u *uint32) *OASTypesUpdateOne { + if u != nil { + otuo.SetUint32(*u) + } + return otuo +} + // AddUint32 adds u to the "uint32" field. func (otuo *OASTypesUpdateOne) AddUint32(u int32) *OASTypesUpdateOne { otuo.mutation.AddUint32(u) @@ -739,6 +963,14 @@ func (otuo *OASTypesUpdateOne) SetUint64(u uint64) *OASTypesUpdateOne { return otuo } +// SetNillableUint64 sets the "uint64" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableUint64(u *uint64) *OASTypesUpdateOne { + if u != nil { + otuo.SetUint64(*u) + } + return otuo +} + // AddUint64 adds u to the "uint64" field. func (otuo *OASTypesUpdateOne) AddUint64(u int64) *OASTypesUpdateOne { otuo.mutation.AddUint64(u) @@ -752,6 +984,14 @@ func (otuo *OASTypesUpdateOne) SetFloat32(f float32) *OASTypesUpdateOne { return otuo } +// SetNillableFloat32 sets the "float32" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableFloat32(f *float32) *OASTypesUpdateOne { + if f != nil { + otuo.SetFloat32(*f) + } + return otuo +} + // AddFloat32 adds f to the "float32" field. func (otuo *OASTypesUpdateOne) AddFloat32(f float32) *OASTypesUpdateOne { otuo.mutation.AddFloat32(f) @@ -765,6 +1005,14 @@ func (otuo *OASTypesUpdateOne) SetFloat64(f float64) *OASTypesUpdateOne { return otuo } +// SetNillableFloat64 sets the "float64" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableFloat64(f *float64) *OASTypesUpdateOne { + if f != nil { + otuo.SetFloat64(*f) + } + return otuo +} + // AddFloat64 adds f to the "float64" field. func (otuo *OASTypesUpdateOne) AddFloat64(f float64) *OASTypesUpdateOne { otuo.mutation.AddFloat64(f) @@ -777,12 +1025,28 @@ func (otuo *OASTypesUpdateOne) SetStringField(s string) *OASTypesUpdateOne { return otuo } +// SetNillableStringField sets the "string_field" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableStringField(s *string) *OASTypesUpdateOne { + if s != nil { + otuo.SetStringField(*s) + } + return otuo +} + // SetBool sets the "bool" field. func (otuo *OASTypesUpdateOne) SetBool(b bool) *OASTypesUpdateOne { otuo.mutation.SetBool(b) return otuo } +// SetNillableBool sets the "bool" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableBool(b *bool) *OASTypesUpdateOne { + if b != nil { + otuo.SetBool(*b) + } + return otuo +} + // SetUUID sets the "uuid" field. func (otuo *OASTypesUpdateOne) SetUUID(u uuid.UUID) *OASTypesUpdateOne { otuo.mutation.SetUUID(u) @@ -803,18 +1067,42 @@ func (otuo *OASTypesUpdateOne) SetTime(t time.Time) *OASTypesUpdateOne { return otuo } +// SetNillableTime sets the "time" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableTime(t *time.Time) *OASTypesUpdateOne { + if t != nil { + otuo.SetTime(*t) + } + return otuo +} + // SetText sets the "text" field. func (otuo *OASTypesUpdateOne) SetText(s string) *OASTypesUpdateOne { otuo.mutation.SetText(s) return otuo } +// SetNillableText sets the "text" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableText(s *string) *OASTypesUpdateOne { + if s != nil { + otuo.SetText(*s) + } + return otuo +} + // SetState sets the "state" field. func (otuo *OASTypesUpdateOne) SetState(o oastypes.State) *OASTypesUpdateOne { otuo.mutation.SetState(o) return otuo } +// SetNillableState sets the "state" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableState(o *oastypes.State) *OASTypesUpdateOne { + if o != nil { + otuo.SetState(*o) + } + return otuo +} + // SetStrings sets the "strings" field. func (otuo *OASTypesUpdateOne) SetStrings(s []string) *OASTypesUpdateOne { otuo.mutation.SetStrings(s) @@ -887,6 +1175,14 @@ func (otuo *OASTypesUpdateOne) SetJSONObj(u url.URL) *OASTypesUpdateOne { return otuo } +// SetNillableJSONObj sets the "json_obj" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableJSONObj(u *url.URL) *OASTypesUpdateOne { + if u != nil { + otuo.SetJSONObj(*u) + } + return otuo +} + // SetOther sets the "other" field. func (otuo *OASTypesUpdateOne) SetOther(s *schema.Link) *OASTypesUpdateOne { otuo.mutation.SetOther(s) @@ -927,6 +1223,14 @@ func (otuo *OASTypesUpdateOne) SetNillable(i int) *OASTypesUpdateOne { return otuo } +// SetNillableNillable sets the "nillable" field if the given value is not nil. +func (otuo *OASTypesUpdateOne) SetNillableNillable(i *int) *OASTypesUpdateOne { + if i != nil { + otuo.SetNillable(*i) + } + return otuo +} + // AddNillable adds i to the "nillable" field. func (otuo *OASTypesUpdateOne) AddNillable(i int) *OASTypesUpdateOne { otuo.mutation.AddNillable(i) @@ -980,7 +1284,7 @@ func (otuo *OASTypesUpdateOne) Select(field string, fields ...string) *OASTypesU // Save executes the query and returns the updated OASTypes entity. func (otuo *OASTypesUpdateOne) Save(ctx context.Context) (*OASTypes, error) { - return withHooks[*OASTypes, OASTypesMutation](ctx, otuo.sqlSave, otuo.mutation, otuo.hooks) + return withHooks(ctx, otuo.sqlSave, otuo.mutation, otuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entoas/internal/oastypes/runtime/runtime.go b/entoas/internal/oastypes/runtime/runtime.go index d3dd7ed5a..ba153c431 100644 --- a/entoas/internal/oastypes/runtime/runtime.go +++ b/entoas/internal/oastypes/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entoas/internal/oastypes/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entoas/internal/pets/category/where.go b/entoas/internal/pets/category/where.go index 5b88fa91c..013b99511 100644 --- a/entoas/internal/pets/category/where.go +++ b/entoas/internal/pets/category/where.go @@ -148,32 +148,15 @@ func HasPetsWith(preds ...predicate.Pet) predicate.Category { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Category(sql.NotPredicates(p)) } diff --git a/entoas/internal/pets/category_create.go b/entoas/internal/pets/category_create.go index c923411e8..b713f8053 100644 --- a/entoas/internal/pets/category_create.go +++ b/entoas/internal/pets/category_create.go @@ -48,7 +48,7 @@ func (cc *CategoryCreate) Mutation() *CategoryMutation { // Save creates the Category in the database. func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) + return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -130,11 +130,15 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { // CategoryCreateBulk is the builder for creating many Category entities in bulk. type CategoryCreateBulk struct { config + err error builders []*CategoryCreate } // Save creates the Category entities in the database. func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error) { + if ccb.err != nil { + return nil, ccb.err + } specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) nodes := make([]*Category, len(ccb.builders)) mutators := make([]Mutator, len(ccb.builders)) diff --git a/entoas/internal/pets/category_delete.go b/entoas/internal/pets/category_delete.go index 40b60e689..2f1899049 100644 --- a/entoas/internal/pets/category_delete.go +++ b/entoas/internal/pets/category_delete.go @@ -27,7 +27,7 @@ func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (cd *CategoryDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) + return withHooks(ctx, cd.sqlExec, cd.mutation, cd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entoas/internal/pets/category_update.go b/entoas/internal/pets/category_update.go index dbcbfaf0f..9102aae89 100644 --- a/entoas/internal/pets/category_update.go +++ b/entoas/internal/pets/category_update.go @@ -34,6 +34,14 @@ func (cu *CategoryUpdate) SetName(s string) *CategoryUpdate { return cu } +// SetNillableName sets the "name" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableName(s *string) *CategoryUpdate { + if s != nil { + cu.SetName(*s) + } + return cu +} + // AddPetIDs adds the "pets" edge to the Pet entity by IDs. func (cu *CategoryUpdate) AddPetIDs(ids ...int) *CategoryUpdate { cu.mutation.AddPetIDs(ids...) @@ -77,7 +85,7 @@ func (cu *CategoryUpdate) RemovePets(p ...*Pet) *CategoryUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) + return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -185,6 +193,14 @@ func (cuo *CategoryUpdateOne) SetName(s string) *CategoryUpdateOne { return cuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableName(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetName(*s) + } + return cuo +} + // AddPetIDs adds the "pets" edge to the Pet entity by IDs. func (cuo *CategoryUpdateOne) AddPetIDs(ids ...int) *CategoryUpdateOne { cuo.mutation.AddPetIDs(ids...) @@ -241,7 +257,7 @@ func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUp // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) + return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entoas/internal/pets/client.go b/entoas/internal/pets/client.go index a8790f0b9..7676af76d 100644 --- a/entoas/internal/pets/client.go +++ b/entoas/internal/pets/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entoas/internal/pets/migrate" "entgo.io/ent" @@ -34,9 +35,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -66,6 +65,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -113,11 +119,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("pets: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("pets: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -241,6 +250,21 @@ func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreate return &CategoryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CategoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CategoryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Category. func (c *CategoryClient) Update() *CategoryUpdate { mutation := newCategoryMutation(c.config, OpUpdate) @@ -375,6 +399,21 @@ func (c *PetClient) CreateBulk(builders ...*PetCreate) *PetCreateBulk { return &PetCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PetClient) MapCreateBulk(slice any, setFunc func(*PetCreate, int)) *PetCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PetCreateBulk{err: fmt.Errorf("calling to PetClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PetCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PetCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Pet. func (c *PetClient) Update() *PetUpdate { mutation := newPetMutation(c.config, OpUpdate) @@ -541,6 +580,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) diff --git a/entoas/internal/pets/pet/where.go b/entoas/internal/pets/pet/where.go index 9cfafce0e..882c52ed2 100644 --- a/entoas/internal/pets/pet/where.go +++ b/entoas/internal/pets/pet/where.go @@ -259,32 +259,15 @@ func HasFriendsWith(preds ...predicate.Pet) predicate.Pet { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pet(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pet(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Pet(sql.NotPredicates(p)) } diff --git a/entoas/internal/pets/pet_create.go b/entoas/internal/pets/pet_create.go index 410012c2c..3caee9c84 100644 --- a/entoas/internal/pets/pet_create.go +++ b/entoas/internal/pets/pet_create.go @@ -109,7 +109,7 @@ func (pc *PetCreate) Mutation() *PetMutation { // Save creates the Pet in the database. func (pc *PetCreate) Save(ctx context.Context) (*Pet, error) { - return withHooks[*Pet, PetMutation](ctx, pc.sqlSave, pc.mutation, pc.hooks) + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -238,11 +238,15 @@ func (pc *PetCreate) createSpec() (*Pet, *sqlgraph.CreateSpec) { // PetCreateBulk is the builder for creating many Pet entities in bulk. type PetCreateBulk struct { config + err error builders []*PetCreate } // Save creates the Pet entities in the database. func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { + if pcb.err != nil { + return nil, pcb.err + } specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) nodes := make([]*Pet, len(pcb.builders)) mutators := make([]Mutator, len(pcb.builders)) diff --git a/entoas/internal/pets/pet_delete.go b/entoas/internal/pets/pet_delete.go index 936750f67..d03076b00 100644 --- a/entoas/internal/pets/pet_delete.go +++ b/entoas/internal/pets/pet_delete.go @@ -27,7 +27,7 @@ func (pd *PetDelete) Where(ps ...predicate.Pet) *PetDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (pd *PetDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, PetMutation](ctx, pd.sqlExec, pd.mutation, pd.hooks) + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entoas/internal/pets/pet_update.go b/entoas/internal/pets/pet_update.go index 75c0069c1..83836b93e 100644 --- a/entoas/internal/pets/pet_update.go +++ b/entoas/internal/pets/pet_update.go @@ -36,6 +36,14 @@ func (pu *PetUpdate) SetName(s string) *PetUpdate { return pu } +// SetNillableName sets the "name" field if the given value is not nil. +func (pu *PetUpdate) SetNillableName(s *string) *PetUpdate { + if s != nil { + pu.SetName(*s) + } + return pu +} + // SetNicknames sets the "nicknames" field. func (pu *PetUpdate) SetNicknames(s []string) *PetUpdate { pu.mutation.SetNicknames(s) @@ -185,7 +193,7 @@ func (pu *PetUpdate) RemoveFriends(p ...*Pet) *PetUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *PetUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, PetMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks) + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -387,6 +395,14 @@ func (puo *PetUpdateOne) SetName(s string) *PetUpdateOne { return puo } +// SetNillableName sets the "name" field if the given value is not nil. +func (puo *PetUpdateOne) SetNillableName(s *string) *PetUpdateOne { + if s != nil { + puo.SetName(*s) + } + return puo +} + // SetNicknames sets the "nicknames" field. func (puo *PetUpdateOne) SetNicknames(s []string) *PetUpdateOne { puo.mutation.SetNicknames(s) @@ -549,7 +565,7 @@ func (puo *PetUpdateOne) Select(field string, fields ...string) *PetUpdateOne { // Save executes the query and returns the updated Pet entity. func (puo *PetUpdateOne) Save(ctx context.Context) (*Pet, error) { - return withHooks[*Pet, PetMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks) + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entoas/internal/pets/runtime/runtime.go b/entoas/internal/pets/runtime/runtime.go index c05ba1a49..788a5c205 100644 --- a/entoas/internal/pets/runtime/runtime.go +++ b/entoas/internal/pets/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entoas/internal/pets/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entoas/internal/pets/user/where.go b/entoas/internal/pets/user/where.go index 88e7f8f5b..fa64e577d 100644 --- a/entoas/internal/pets/user/where.go +++ b/entoas/internal/pets/user/where.go @@ -193,32 +193,15 @@ func HasPetsWith(preds ...predicate.Pet) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entoas/internal/pets/user_create.go b/entoas/internal/pets/user_create.go index 943e7a9d0..494d07dbf 100644 --- a/entoas/internal/pets/user_create.go +++ b/entoas/internal/pets/user_create.go @@ -54,7 +54,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -143,11 +143,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entoas/internal/pets/user_delete.go b/entoas/internal/pets/user_delete.go index 83ac793c6..6bd875e8e 100644 --- a/entoas/internal/pets/user_delete.go +++ b/entoas/internal/pets/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entoas/internal/pets/user_update.go b/entoas/internal/pets/user_update.go index da0b1adc7..14c733fd3 100644 --- a/entoas/internal/pets/user_update.go +++ b/entoas/internal/pets/user_update.go @@ -34,6 +34,14 @@ func (uu *UserUpdate) SetName(s string) *UserUpdate { return uu } +// SetNillableName sets the "name" field if the given value is not nil. +func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate { + if s != nil { + uu.SetName(*s) + } + return uu +} + // SetAge sets the "age" field. func (uu *UserUpdate) SetAge(i int) *UserUpdate { uu.mutation.ResetAge() @@ -41,6 +49,14 @@ func (uu *UserUpdate) SetAge(i int) *UserUpdate { return uu } +// SetNillableAge sets the "age" field if the given value is not nil. +func (uu *UserUpdate) SetNillableAge(i *int) *UserUpdate { + if i != nil { + uu.SetAge(*i) + } + return uu +} + // AddAge adds i to the "age" field. func (uu *UserUpdate) AddAge(i int) *UserUpdate { uu.mutation.AddAge(i) @@ -90,7 +106,7 @@ func (uu *UserUpdate) RemovePets(p ...*Pet) *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -204,6 +220,14 @@ func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne { return uuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne { + if s != nil { + uuo.SetName(*s) + } + return uuo +} + // SetAge sets the "age" field. func (uuo *UserUpdateOne) SetAge(i int) *UserUpdateOne { uuo.mutation.ResetAge() @@ -211,6 +235,14 @@ func (uuo *UserUpdateOne) SetAge(i int) *UserUpdateOne { return uuo } +// SetNillableAge sets the "age" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableAge(i *int) *UserUpdateOne { + if i != nil { + uuo.SetAge(*i) + } + return uuo +} + // AddAge adds i to the "age" field. func (uuo *UserUpdateOne) AddAge(i int) *UserUpdateOne { uuo.mutation.AddAge(i) @@ -273,7 +305,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entoas/internal/simple/category/where.go b/entoas/internal/simple/category/where.go index ee67748fb..8b4b8a191 100644 --- a/entoas/internal/simple/category/where.go +++ b/entoas/internal/simple/category/where.go @@ -288,32 +288,15 @@ func HasPetsWith(preds ...predicate.Pet) predicate.Category { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Category(sql.NotPredicates(p)) } diff --git a/entoas/internal/simple/category_create.go b/entoas/internal/simple/category_create.go index a9153e787..d42201344 100644 --- a/entoas/internal/simple/category_create.go +++ b/entoas/internal/simple/category_create.go @@ -60,7 +60,7 @@ func (cc *CategoryCreate) Mutation() *CategoryMutation { // Save creates the Category in the database. func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) + return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -156,11 +156,15 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { // CategoryCreateBulk is the builder for creating many Category entities in bulk. type CategoryCreateBulk struct { config + err error builders []*CategoryCreate } // Save creates the Category entities in the database. func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error) { + if ccb.err != nil { + return nil, ccb.err + } specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) nodes := make([]*Category, len(ccb.builders)) mutators := make([]Mutator, len(ccb.builders)) diff --git a/entoas/internal/simple/category_delete.go b/entoas/internal/simple/category_delete.go index b4a612787..b277d470e 100644 --- a/entoas/internal/simple/category_delete.go +++ b/entoas/internal/simple/category_delete.go @@ -27,7 +27,7 @@ func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (cd *CategoryDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) + return withHooks(ctx, cd.sqlExec, cd.mutation, cd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entoas/internal/simple/category_update.go b/entoas/internal/simple/category_update.go index a281f7a4b..ed28fd92a 100644 --- a/entoas/internal/simple/category_update.go +++ b/entoas/internal/simple/category_update.go @@ -34,18 +34,42 @@ func (cu *CategoryUpdate) SetName(s string) *CategoryUpdate { return cu } +// SetNillableName sets the "name" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableName(s *string) *CategoryUpdate { + if s != nil { + cu.SetName(*s) + } + return cu +} + // SetReadonly sets the "readonly" field. func (cu *CategoryUpdate) SetReadonly(s string) *CategoryUpdate { cu.mutation.SetReadonly(s) return cu } +// SetNillableReadonly sets the "readonly" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableReadonly(s *string) *CategoryUpdate { + if s != nil { + cu.SetReadonly(*s) + } + return cu +} + // SetSkipInSpec sets the "skip_in_spec" field. func (cu *CategoryUpdate) SetSkipInSpec(s string) *CategoryUpdate { cu.mutation.SetSkipInSpec(s) return cu } +// SetNillableSkipInSpec sets the "skip_in_spec" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableSkipInSpec(s *string) *CategoryUpdate { + if s != nil { + cu.SetSkipInSpec(*s) + } + return cu +} + // AddPetIDs adds the "pets" edge to the Pet entity by IDs. func (cu *CategoryUpdate) AddPetIDs(ids ...int) *CategoryUpdate { cu.mutation.AddPetIDs(ids...) @@ -89,7 +113,7 @@ func (cu *CategoryUpdate) RemovePets(p ...*Pet) *CategoryUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) + return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -203,18 +227,42 @@ func (cuo *CategoryUpdateOne) SetName(s string) *CategoryUpdateOne { return cuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableName(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetName(*s) + } + return cuo +} + // SetReadonly sets the "readonly" field. func (cuo *CategoryUpdateOne) SetReadonly(s string) *CategoryUpdateOne { cuo.mutation.SetReadonly(s) return cuo } +// SetNillableReadonly sets the "readonly" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableReadonly(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetReadonly(*s) + } + return cuo +} + // SetSkipInSpec sets the "skip_in_spec" field. func (cuo *CategoryUpdateOne) SetSkipInSpec(s string) *CategoryUpdateOne { cuo.mutation.SetSkipInSpec(s) return cuo } +// SetNillableSkipInSpec sets the "skip_in_spec" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableSkipInSpec(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetSkipInSpec(*s) + } + return cuo +} + // AddPetIDs adds the "pets" edge to the Pet entity by IDs. func (cuo *CategoryUpdateOne) AddPetIDs(ids ...int) *CategoryUpdateOne { cuo.mutation.AddPetIDs(ids...) @@ -271,7 +319,7 @@ func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUp // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) + return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entoas/internal/simple/client.go b/entoas/internal/simple/client.go index 2aab140e1..7485324f3 100644 --- a/entoas/internal/simple/client.go +++ b/entoas/internal/simple/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entoas/internal/simple/migrate" "entgo.io/ent" @@ -34,9 +35,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -66,6 +65,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -113,11 +119,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("simple: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("simple: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -241,6 +250,21 @@ func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreate return &CategoryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CategoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CategoryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Category. func (c *CategoryClient) Update() *CategoryUpdate { mutation := newCategoryMutation(c.config, OpUpdate) @@ -375,6 +399,21 @@ func (c *PetClient) CreateBulk(builders ...*PetCreate) *PetCreateBulk { return &PetCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PetClient) MapCreateBulk(slice any, setFunc func(*PetCreate, int)) *PetCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PetCreateBulk{err: fmt.Errorf("calling to PetClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PetCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PetCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Pet. func (c *PetClient) Update() *PetUpdate { mutation := newPetMutation(c.config, OpUpdate) @@ -541,6 +580,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) diff --git a/entoas/internal/simple/pet/where.go b/entoas/internal/simple/pet/where.go index 95aecff15..3db68bf95 100644 --- a/entoas/internal/simple/pet/where.go +++ b/entoas/internal/simple/pet/where.go @@ -259,32 +259,15 @@ func HasFriendsWith(preds ...predicate.Pet) predicate.Pet { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pet(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pet(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Pet(sql.NotPredicates(p)) } diff --git a/entoas/internal/simple/pet_create.go b/entoas/internal/simple/pet_create.go index e6d540fa6..8053823ff 100644 --- a/entoas/internal/simple/pet_create.go +++ b/entoas/internal/simple/pet_create.go @@ -109,7 +109,7 @@ func (pc *PetCreate) Mutation() *PetMutation { // Save creates the Pet in the database. func (pc *PetCreate) Save(ctx context.Context) (*Pet, error) { - return withHooks[*Pet, PetMutation](ctx, pc.sqlSave, pc.mutation, pc.hooks) + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -238,11 +238,15 @@ func (pc *PetCreate) createSpec() (*Pet, *sqlgraph.CreateSpec) { // PetCreateBulk is the builder for creating many Pet entities in bulk. type PetCreateBulk struct { config + err error builders []*PetCreate } // Save creates the Pet entities in the database. func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { + if pcb.err != nil { + return nil, pcb.err + } specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) nodes := make([]*Pet, len(pcb.builders)) mutators := make([]Mutator, len(pcb.builders)) diff --git a/entoas/internal/simple/pet_delete.go b/entoas/internal/simple/pet_delete.go index 8d10408e6..9988fb8f0 100644 --- a/entoas/internal/simple/pet_delete.go +++ b/entoas/internal/simple/pet_delete.go @@ -27,7 +27,7 @@ func (pd *PetDelete) Where(ps ...predicate.Pet) *PetDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (pd *PetDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, PetMutation](ctx, pd.sqlExec, pd.mutation, pd.hooks) + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entoas/internal/simple/pet_update.go b/entoas/internal/simple/pet_update.go index 602ded5be..4129d65d8 100644 --- a/entoas/internal/simple/pet_update.go +++ b/entoas/internal/simple/pet_update.go @@ -36,6 +36,14 @@ func (pu *PetUpdate) SetName(s string) *PetUpdate { return pu } +// SetNillableName sets the "name" field if the given value is not nil. +func (pu *PetUpdate) SetNillableName(s *string) *PetUpdate { + if s != nil { + pu.SetName(*s) + } + return pu +} + // SetNicknames sets the "nicknames" field. func (pu *PetUpdate) SetNicknames(s []string) *PetUpdate { pu.mutation.SetNicknames(s) @@ -185,7 +193,7 @@ func (pu *PetUpdate) RemoveFriends(p ...*Pet) *PetUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *PetUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, PetMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks) + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -387,6 +395,14 @@ func (puo *PetUpdateOne) SetName(s string) *PetUpdateOne { return puo } +// SetNillableName sets the "name" field if the given value is not nil. +func (puo *PetUpdateOne) SetNillableName(s *string) *PetUpdateOne { + if s != nil { + puo.SetName(*s) + } + return puo +} + // SetNicknames sets the "nicknames" field. func (puo *PetUpdateOne) SetNicknames(s []string) *PetUpdateOne { puo.mutation.SetNicknames(s) @@ -549,7 +565,7 @@ func (puo *PetUpdateOne) Select(field string, fields ...string) *PetUpdateOne { // Save executes the query and returns the updated Pet entity. func (puo *PetUpdateOne) Save(ctx context.Context) (*Pet, error) { - return withHooks[*Pet, PetMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks) + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entoas/internal/simple/runtime/runtime.go b/entoas/internal/simple/runtime/runtime.go index c35d52eee..82d7f4ae6 100644 --- a/entoas/internal/simple/runtime/runtime.go +++ b/entoas/internal/simple/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entoas/internal/simple/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entoas/internal/simple/user/where.go b/entoas/internal/simple/user/where.go index bf14ee44e..0adf2307e 100644 --- a/entoas/internal/simple/user/where.go +++ b/entoas/internal/simple/user/where.go @@ -193,32 +193,15 @@ func HasPetsWith(preds ...predicate.Pet) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entoas/internal/simple/user_create.go b/entoas/internal/simple/user_create.go index 28777712d..566f956fd 100644 --- a/entoas/internal/simple/user_create.go +++ b/entoas/internal/simple/user_create.go @@ -54,7 +54,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -143,11 +143,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entoas/internal/simple/user_delete.go b/entoas/internal/simple/user_delete.go index 80840662d..9261b861c 100644 --- a/entoas/internal/simple/user_delete.go +++ b/entoas/internal/simple/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entoas/internal/simple/user_update.go b/entoas/internal/simple/user_update.go index b3f00dd77..a7455b817 100644 --- a/entoas/internal/simple/user_update.go +++ b/entoas/internal/simple/user_update.go @@ -34,6 +34,14 @@ func (uu *UserUpdate) SetName(s string) *UserUpdate { return uu } +// SetNillableName sets the "name" field if the given value is not nil. +func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate { + if s != nil { + uu.SetName(*s) + } + return uu +} + // SetAge sets the "age" field. func (uu *UserUpdate) SetAge(i int) *UserUpdate { uu.mutation.ResetAge() @@ -41,6 +49,14 @@ func (uu *UserUpdate) SetAge(i int) *UserUpdate { return uu } +// SetNillableAge sets the "age" field if the given value is not nil. +func (uu *UserUpdate) SetNillableAge(i *int) *UserUpdate { + if i != nil { + uu.SetAge(*i) + } + return uu +} + // AddAge adds i to the "age" field. func (uu *UserUpdate) AddAge(i int) *UserUpdate { uu.mutation.AddAge(i) @@ -90,7 +106,7 @@ func (uu *UserUpdate) RemovePets(p ...*Pet) *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -204,6 +220,14 @@ func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne { return uuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne { + if s != nil { + uuo.SetName(*s) + } + return uuo +} + // SetAge sets the "age" field. func (uuo *UserUpdateOne) SetAge(i int) *UserUpdateOne { uuo.mutation.ResetAge() @@ -211,6 +235,14 @@ func (uuo *UserUpdateOne) SetAge(i int) *UserUpdateOne { return uuo } +// SetNillableAge sets the "age" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableAge(i *int) *UserUpdateOne { + if i != nil { + uuo.SetAge(*i) + } + return uuo +} + // AddAge adds i to the "age" field. func (uuo *UserUpdateOne) AddAge(i int) *UserUpdateOne { uuo.mutation.AddAge(i) @@ -273,7 +305,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/Dockerfile b/entproto/Dockerfile index 8042a1fa7..05310a66c 100644 --- a/entproto/Dockerfile +++ b/entproto/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19.0 +FROM golang:1.22.0 RUN apt update && apt install unzip RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip && \ unzip -o protoc-3.19.4-linux-x86_64.zip -d ./proto && \ diff --git a/entproto/README.md b/entproto/README.md index 0b0de7f98..23914246b 100644 --- a/entproto/README.md +++ b/entproto/README.md @@ -330,29 +330,29 @@ message User { Field type mappings: -| Ent Type | Proto Type | More considerations | -| ----------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| TypeBool | bool | -| TypeTime | google.protobuf.Timestamp | -| TypeJSON | X | -| TypeUUID | bytes | When receiving an arbitrary byte slice as input, 16-byte length must be validated | -| TypeBytes | bytes | -| TypeEnum | Enum | Proto enums like proto fields require stable numbers to be assigned to each value. Therefore we will need to add an extra annotation to map from field value to tag number. | -| TypeString | string | -| TypeOther | X | -| TypeInt8 | int32 | -| TypeInt16 | int32 | -| TypeInt32 | int32 | -| TypeInt | int32 | -| TypeInt64 | int64 | -| TypeUint8 | uint32 | -| TypeUint16 | uint32 | -| TypeUint32 | uint32 | -| TypeUint | uint32 | -| TypeUint64 | uint64 | -| TypeFloat32 | float | -| TypeFloat64 | double | -|   | +| Ent Type | Proto Type | More considerations | +|----------------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| TypeBool | bool | | +| TypeTime | google.protobuf.Timestamp | | +| TypeJSON\[[]T] | repeated T | T must be one of: `string`, `int32`, `int64`, `uint32`, `uint64` | +| TypeUUID | bytes | When receiving an arbitrary byte slice as input, 16-byte length must be validated | +| TypeBytes | bytes | | +| TypeEnum | Enum | Proto enums like proto fields require stable numbers to be assigned to each value. Therefore we will need to add an extra annotation to map from field value to tag number. | +| TypeString | string | | +| TypeOther | X | | +| TypeInt8 | int32 | | +| TypeInt16 | int32 | | +| TypeInt32 | int32 | | +| TypeInt | int32 | | +| TypeInt64 | int64 | | +| TypeUint8 | uint32 | | +| TypeUint16 | uint32 | | +| TypeUint32 | uint32 | | +| TypeUint | uint32 | | +| TypeUint64 | uint64 | | +| TypeFloat32 | float | | +| TypeFloat64 | double | | +|   | | | Validations: @@ -430,6 +430,8 @@ The Proto Style Guide suggests that we use `CAPS_WITH_UNDERSCORES` for value nam - If no default value is defined for the enum, we generate a `_UNSPECIFIED = 0;` option on the enum and verify that no option received the 0 number in the enproto.Enum Options field. - If a default value is defined for the enum, we verify that it receives the 0 value on the Options field. +Ent allows special characters in enum values. For such values, any special character is replaced by an underscore to preserve the `CAPS_WITH_UNDERSCORES` protobuf format. + ## Edges Edges are annotated in the same way as fields: using `entproto.Field` annotation to specify the field number for the generated field. Unique relations are mapped to normal fields, non-unique relations are mapped to `repeated` fields. diff --git a/entproto/adapter.go b/entproto/adapter.go index 9886d85a3..3c42e16c7 100644 --- a/entproto/adapter.go +++ b/entproto/adapter.go @@ -441,7 +441,7 @@ func toProtoEnumDescriptor(fld *gen.Field) (*descriptorpb.EnumDescriptorProto, e }) } for _, opt := range fld.Enums { - n := strings.ToUpper(snake(opt.Value)) + n := strings.ToUpper(snake(NormalizeEnumIdentifier(opt.Value))) if !enumAnnotation.OmitFieldPrefix { n = strings.ToUpper(snake(fld.Name)) + "_" + n } @@ -515,11 +515,32 @@ func extractProtoTypeDetails(f *gen.Field) (fieldType, error) { } func extractJSONDetails(f *gen.Field) (fieldType, error) { - if f.Type.Ident == "[]string" { + switch f.Type.Ident { + case "[]string": return fieldType{ protoType: descriptorpb.FieldDescriptorProto_TYPE_STRING, repeated: true, }, nil + case "[]int32": + return fieldType{ + protoType: descriptorpb.FieldDescriptorProto_TYPE_INT32, + repeated: true, + }, nil + case "[]int64": + return fieldType{ + protoType: descriptorpb.FieldDescriptorProto_TYPE_INT64, + repeated: true, + }, nil + case "[]uint32": + return fieldType{ + protoType: descriptorpb.FieldDescriptorProto_TYPE_UINT32, + repeated: true, + }, nil + case "[]uint64": + return fieldType{ + protoType: descriptorpb.FieldDescriptorProto_TYPE_UINT64, + repeated: true, + }, nil } return fieldType{}, unsupportedTypeError{Type: f.Type} } diff --git a/entproto/cmd/entproto/main.go b/entproto/cmd/entproto/main.go index 53db11d2f..4632d2b06 100644 --- a/entproto/cmd/entproto/main.go +++ b/entproto/cmd/entproto/main.go @@ -17,6 +17,7 @@ package main import ( "flag" "log" + "path/filepath" "entgo.io/contrib/entproto" "entgo.io/ent/entc" @@ -31,7 +32,13 @@ func main() { if *schemaPath == "" { log.Fatal("entproto: must specify schema path. use entproto -path ./ent/schema") } - graph, err := entc.LoadGraph(*schemaPath, &gen.Config{}) + abs, err := filepath.Abs(*schemaPath) + if err != nil { + log.Fatalf("entproto: failed getting absolute path: %v", err) + } + graph, err := entc.LoadGraph(*schemaPath, &gen.Config{ + Target: filepath.Dir(abs), + }) if err != nil { log.Fatalf("entproto: failed loading ent graph: %v", err) } diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment/where.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment/where.go index e63d083d0..a39f6c93f 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment/where.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment/where.go @@ -134,32 +134,15 @@ func ContentsContainsFold(v string) predicate.Attachment { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Attachment(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Attachment(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Attachment(sql.NotPredicates(p)) } diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_create.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_create.go index 8ae46a6cb..9abdd2def 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_create.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_create.go @@ -38,7 +38,7 @@ func (ac *AttachmentCreate) Mutation() *AttachmentMutation { // Save creates the Attachment in the database. func (ac *AttachmentCreate) Save(ctx context.Context) (*Attachment, error) { - return withHooks[*Attachment, AttachmentMutation](ctx, ac.sqlSave, ac.mutation, ac.hooks) + return withHooks(ctx, ac.sqlSave, ac.mutation, ac.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -113,11 +113,15 @@ func (ac *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { // AttachmentCreateBulk is the builder for creating many Attachment entities in bulk. type AttachmentCreateBulk struct { config + err error builders []*AttachmentCreate } // Save creates the Attachment entities in the database. func (acb *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error) { + if acb.err != nil { + return nil, acb.err + } specs := make([]*sqlgraph.CreateSpec, len(acb.builders)) nodes := make([]*Attachment, len(acb.builders)) mutators := make([]Mutator, len(acb.builders)) diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_delete.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_delete.go index 449c8cf64..829b0ef5a 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_delete.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_delete.go @@ -27,7 +27,7 @@ func (ad *AttachmentDelete) Where(ps ...predicate.Attachment) *AttachmentDelete // Exec executes the deletion query and returns how many vertices were deleted. func (ad *AttachmentDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, AttachmentMutation](ctx, ad.sqlExec, ad.mutation, ad.hooks) + return withHooks(ctx, ad.sqlExec, ad.mutation, ad.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_update.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_update.go index 89e095c55..bafd472fa 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_update.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/attachment_update.go @@ -33,6 +33,14 @@ func (au *AttachmentUpdate) SetContents(s string) *AttachmentUpdate { return au } +// SetNillableContents sets the "contents" field if the given value is not nil. +func (au *AttachmentUpdate) SetNillableContents(s *string) *AttachmentUpdate { + if s != nil { + au.SetContents(*s) + } + return au +} + // Mutation returns the AttachmentMutation object of the builder. func (au *AttachmentUpdate) Mutation() *AttachmentMutation { return au.mutation @@ -40,7 +48,7 @@ func (au *AttachmentUpdate) Mutation() *AttachmentMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (au *AttachmentUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, AttachmentMutation](ctx, au.sqlSave, au.mutation, au.hooks) + return withHooks(ctx, au.sqlSave, au.mutation, au.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -103,6 +111,14 @@ func (auo *AttachmentUpdateOne) SetContents(s string) *AttachmentUpdateOne { return auo } +// SetNillableContents sets the "contents" field if the given value is not nil. +func (auo *AttachmentUpdateOne) SetNillableContents(s *string) *AttachmentUpdateOne { + if s != nil { + auo.SetContents(*s) + } + return auo +} + // Mutation returns the AttachmentMutation object of the builder. func (auo *AttachmentUpdateOne) Mutation() *AttachmentMutation { return auo.mutation @@ -123,7 +139,7 @@ func (auo *AttachmentUpdateOne) Select(field string, fields ...string) *Attachme // Save executes the query and returns the updated Attachment entity. func (auo *AttachmentUpdateOne) Save(ctx context.Context) (*Attachment, error) { - return withHooks[*Attachment, AttachmentMutation](ctx, auo.sqlSave, auo.mutation, auo.hooks) + return withHooks(ctx, auo.sqlSave, auo.mutation, auo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/client.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/client.go index 6633654f3..c8919dd97 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/client.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entproto/cmd/protoc-gen-ent/internal/todo/ent/migrate" "entgo.io/ent" @@ -36,9 +37,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -69,6 +68,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -116,11 +122,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -250,6 +259,21 @@ func (c *AttachmentClient) CreateBulk(builders ...*AttachmentCreate) *Attachment return &AttachmentCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AttachmentClient) MapCreateBulk(slice any, setFunc func(*AttachmentCreate, int)) *AttachmentCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AttachmentCreateBulk{err: fmt.Errorf("calling to AttachmentClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AttachmentCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AttachmentCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Attachment. func (c *AttachmentClient) Update() *AttachmentUpdate { mutation := newAttachmentMutation(c.config, OpUpdate) @@ -368,6 +392,21 @@ func (c *FileClient) CreateBulk(builders ...*FileCreate) *FileCreateBulk { return &FileCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *FileClient) MapCreateBulk(slice any, setFunc func(*FileCreate, int)) *FileCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &FileCreateBulk{err: fmt.Errorf("calling to FileClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*FileCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &FileCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for File. func (c *FileClient) Update() *FileUpdate { mutation := newFileMutation(c.config, OpUpdate) @@ -486,6 +525,21 @@ func (c *TaskClient) CreateBulk(builders ...*TaskCreate) *TaskCreateBulk { return &TaskCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TaskClient) MapCreateBulk(slice any, setFunc func(*TaskCreate, int)) *TaskCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TaskCreateBulk{err: fmt.Errorf("calling to TaskClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TaskCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TaskCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Task. func (c *TaskClient) Update() *TaskUpdate { mutation := newTaskMutation(c.config, OpUpdate) @@ -604,6 +658,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/file/where.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/file/where.go index 92c47c9af..51f67ce7f 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/file/where.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/file/where.go @@ -134,32 +134,15 @@ func ContentsContainsFold(v string) predicate.File { // And groups predicates with the AND operator between them. func And(predicates ...predicate.File) predicate.File { - return predicate.File(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.File(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.File) predicate.File { - return predicate.File(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.File(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.File) predicate.File { - return predicate.File(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.File(sql.NotPredicates(p)) } diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_create.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_create.go index 466a6c71a..0814f52bd 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_create.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_create.go @@ -38,7 +38,7 @@ func (fc *FileCreate) Mutation() *FileMutation { // Save creates the File in the database. func (fc *FileCreate) Save(ctx context.Context) (*File, error) { - return withHooks[*File, FileMutation](ctx, fc.sqlSave, fc.mutation, fc.hooks) + return withHooks(ctx, fc.sqlSave, fc.mutation, fc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -113,11 +113,15 @@ func (fc *FileCreate) createSpec() (*File, *sqlgraph.CreateSpec) { // FileCreateBulk is the builder for creating many File entities in bulk. type FileCreateBulk struct { config + err error builders []*FileCreate } // Save creates the File entities in the database. func (fcb *FileCreateBulk) Save(ctx context.Context) ([]*File, error) { + if fcb.err != nil { + return nil, fcb.err + } specs := make([]*sqlgraph.CreateSpec, len(fcb.builders)) nodes := make([]*File, len(fcb.builders)) mutators := make([]Mutator, len(fcb.builders)) diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_delete.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_delete.go index c096e5417..d9f466011 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_delete.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_delete.go @@ -27,7 +27,7 @@ func (fd *FileDelete) Where(ps ...predicate.File) *FileDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (fd *FileDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, FileMutation](ctx, fd.sqlExec, fd.mutation, fd.hooks) + return withHooks(ctx, fd.sqlExec, fd.mutation, fd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_update.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_update.go index 0578f8e72..5008d7e8d 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_update.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/file_update.go @@ -33,6 +33,14 @@ func (fu *FileUpdate) SetContents(s string) *FileUpdate { return fu } +// SetNillableContents sets the "contents" field if the given value is not nil. +func (fu *FileUpdate) SetNillableContents(s *string) *FileUpdate { + if s != nil { + fu.SetContents(*s) + } + return fu +} + // Mutation returns the FileMutation object of the builder. func (fu *FileUpdate) Mutation() *FileMutation { return fu.mutation @@ -40,7 +48,7 @@ func (fu *FileUpdate) Mutation() *FileMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (fu *FileUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, FileMutation](ctx, fu.sqlSave, fu.mutation, fu.hooks) + return withHooks(ctx, fu.sqlSave, fu.mutation, fu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -103,6 +111,14 @@ func (fuo *FileUpdateOne) SetContents(s string) *FileUpdateOne { return fuo } +// SetNillableContents sets the "contents" field if the given value is not nil. +func (fuo *FileUpdateOne) SetNillableContents(s *string) *FileUpdateOne { + if s != nil { + fuo.SetContents(*s) + } + return fuo +} + // Mutation returns the FileMutation object of the builder. func (fuo *FileUpdateOne) Mutation() *FileMutation { return fuo.mutation @@ -123,7 +139,7 @@ func (fuo *FileUpdateOne) Select(field string, fields ...string) *FileUpdateOne // Save executes the query and returns the updated File entity. func (fuo *FileUpdateOne) Save(ctx context.Context) (*File, error) { - return withHooks[*File, FileMutation](ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) + return withHooks(ctx, fuo.sqlSave, fuo.mutation, fuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/runtime/runtime.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/runtime/runtime.go index 7d9abdad6..dae115fbe 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/runtime/runtime.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entproto/cmd/protoc-gen-ent/internal/todo/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/task/where.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/task/where.go index 976c10083..299f87267 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/task/where.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/task/where.go @@ -289,32 +289,15 @@ func SignatureContainsFold(v string) predicate.Task { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Task) predicate.Task { - return predicate.Task(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Task(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Task) predicate.Task { - return predicate.Task(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Task(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Task) predicate.Task { - return predicate.Task(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Task(sql.NotPredicates(p)) } diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_create.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_create.go index 865566ad1..370a917cf 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_create.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_create.go @@ -58,7 +58,7 @@ func (tc *TaskCreate) Mutation() *TaskMutation { // Save creates the Task in the database. func (tc *TaskCreate) Save(ctx context.Context) (*Task, error) { - return withHooks[*Task, TaskMutation](ctx, tc.sqlSave, tc.mutation, tc.hooks) + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -142,11 +142,15 @@ func (tc *TaskCreate) createSpec() (*Task, *sqlgraph.CreateSpec) { // TaskCreateBulk is the builder for creating many Task entities in bulk. type TaskCreateBulk struct { config + err error builders []*TaskCreate } // Save creates the Task entities in the database. func (tcb *TaskCreateBulk) Save(ctx context.Context) ([]*Task, error) { + if tcb.err != nil { + return nil, tcb.err + } specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) nodes := make([]*Task, len(tcb.builders)) mutators := make([]Mutator, len(tcb.builders)) diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_delete.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_delete.go index 2429ad7c1..ad5234ba6 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_delete.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_delete.go @@ -27,7 +27,7 @@ func (td *TaskDelete) Where(ps ...predicate.Task) *TaskDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (td *TaskDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, TaskMutation](ctx, td.sqlExec, td.mutation, td.hooks) + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_update.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_update.go index 8e1c03f0b..54a95390c 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_update.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/task_update.go @@ -53,12 +53,28 @@ func (tu *TaskUpdate) SetComplete(b bool) *TaskUpdate { return tu } +// SetNillableComplete sets the "complete" field if the given value is not nil. +func (tu *TaskUpdate) SetNillableComplete(b *bool) *TaskUpdate { + if b != nil { + tu.SetComplete(*b) + } + return tu +} + // SetSignature sets the "signature" field. func (tu *TaskUpdate) SetSignature(s string) *TaskUpdate { tu.mutation.SetSignature(s) return tu } +// SetNillableSignature sets the "signature" field if the given value is not nil. +func (tu *TaskUpdate) SetNillableSignature(s *string) *TaskUpdate { + if s != nil { + tu.SetSignature(*s) + } + return tu +} + // Mutation returns the TaskMutation object of the builder. func (tu *TaskUpdate) Mutation() *TaskMutation { return tu.mutation @@ -66,7 +82,7 @@ func (tu *TaskUpdate) Mutation() *TaskMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TaskUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, TaskMutation](ctx, tu.sqlSave, tu.mutation, tu.hooks) + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -158,12 +174,28 @@ func (tuo *TaskUpdateOne) SetComplete(b bool) *TaskUpdateOne { return tuo } +// SetNillableComplete sets the "complete" field if the given value is not nil. +func (tuo *TaskUpdateOne) SetNillableComplete(b *bool) *TaskUpdateOne { + if b != nil { + tuo.SetComplete(*b) + } + return tuo +} + // SetSignature sets the "signature" field. func (tuo *TaskUpdateOne) SetSignature(s string) *TaskUpdateOne { tuo.mutation.SetSignature(s) return tuo } +// SetNillableSignature sets the "signature" field if the given value is not nil. +func (tuo *TaskUpdateOne) SetNillableSignature(s *string) *TaskUpdateOne { + if s != nil { + tuo.SetSignature(*s) + } + return tuo +} + // Mutation returns the TaskMutation object of the builder. func (tuo *TaskUpdateOne) Mutation() *TaskMutation { return tuo.mutation @@ -184,7 +216,7 @@ func (tuo *TaskUpdateOne) Select(field string, fields ...string) *TaskUpdateOne // Save executes the query and returns the updated Task entity. func (tuo *TaskUpdateOne) Save(ctx context.Context) (*Task, error) { - return withHooks[*Task, TaskMutation](ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/user/where.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/user/where.go index 79c82154b..eb926275d 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/user/where.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/user/where.go @@ -124,32 +124,15 @@ func NameContainsFold(v string) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_create.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_create.go index a84b3e081..94c779fd9 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_create.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_create.go @@ -32,7 +32,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -98,11 +98,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_delete.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_delete.go index 698f9cef7..3eca051e3 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_delete.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_update.go b/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_update.go index 89154a909..012d453e9 100644 --- a/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_update.go +++ b/entproto/cmd/protoc-gen-ent/internal/todo/ent/user_update.go @@ -33,6 +33,14 @@ func (uu *UserUpdate) SetName(s string) *UserUpdate { return uu } +// SetNillableName sets the "name" field if the given value is not nil. +func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate { + if s != nil { + uu.SetName(*s) + } + return uu +} + // Mutation returns the UserMutation object of the builder. func (uu *UserUpdate) Mutation() *UserMutation { return uu.mutation @@ -40,7 +48,7 @@ func (uu *UserUpdate) Mutation() *UserMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -103,6 +111,14 @@ func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne { return uuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne { + if s != nil { + uuo.SetName(*s) + } + return uuo +} + // Mutation returns the UserMutation object of the builder. func (uuo *UserUpdateOne) Mutation() *UserMutation { return uuo.mutation @@ -123,7 +139,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/cmd/protoc-gen-entgrpc/converter.go b/entproto/cmd/protoc-gen-entgrpc/converter.go index 07fdaadd9..1f12078b7 100644 --- a/entproto/cmd/protoc-gen-entgrpc/converter.go +++ b/entproto/cmd/protoc-gen-entgrpc/converter.go @@ -111,7 +111,14 @@ func (g *serviceGenerator) newConverter(fld *entproto.FieldMappingDescriptor) (* enumName := fld.PbFieldDescriptor.GetEnumType().GetName() method := fmt.Sprintf("toEnt%s_%s", g.EntType.Name, enumName) out.ToEntConstructor = g.File.GoImportPath.Ident(method) - case efld.IsJSON() && efld.Type.Ident == "[]string": + case efld.IsJSON(): + switch efld.Type.Ident { + case "[]string": + case "[]int32", "[]int64", "[]uint32", "[]uint64": + out.ToProtoConversion = "" + default: + return nil, fmt.Errorf("entproto: no mapping to ent field type %q", efld.Type.ConstName()) + } default: return nil, fmt.Errorf("entproto: no mapping to ent field type %q", efld.Type.ConstName()) } diff --git a/entproto/cmd/protoc-gen-entgrpc/main.go b/entproto/cmd/protoc-gen-entgrpc/main.go index cf5da7321..5e98698ed 100644 --- a/entproto/cmd/protoc-gen-entgrpc/main.go +++ b/entproto/cmd/protoc-gen-entgrpc/main.go @@ -125,6 +125,7 @@ func (g *serviceGenerator) generate() error { "qualify": func(pkg, ident string) string { return g.QualifiedGoIdent(protogen.GoImportPath(pkg).Ident(ident)) }, + "protoIdentNormalize": entproto.NormalizeEnumIdentifier, "statusErr": func(code, msg string) string { return fmt.Sprintf("%s(%s, %q)", g.QualifiedGoIdent(status.Ident("Error")), diff --git a/entproto/cmd/protoc-gen-entgrpc/template/enums.tmpl b/entproto/cmd/protoc-gen-entgrpc/template/enums.tmpl index 571c6509b..40a2c3d6b 100644 --- a/entproto/cmd/protoc-gen-entgrpc/template/enums.tmpl +++ b/entproto/cmd/protoc-gen-entgrpc/template/enums.tmpl @@ -8,8 +8,13 @@ {{ $entEnumIdent := entIdent $entLcase .PbStructField }} {{ $enumFieldPrefix := snake $enumType.GetName | upper | printf "%s_" }} {{ $omitPrefix := .EntField.Annotations.ProtoEnum.OmitFieldPrefix }} - func toProto{{ $pbEnumIdent.GoName }} (e {{ ident $entEnumIdent }}) {{ ident $pbEnumIdent }} { - if v, ok := {{ $pbEnumIdent.GoName }}_value[{{ qualify "strings" "ToUpper" }}({{ if not $omitPrefix }}"{{ $enumFieldPrefix }}" +{{ end }} string(e))]; ok { + var protoIdentNormalizeRegexp{{ $pbEnumIdent.GoName }} = {{ qualify "regexp" "MustCompile" }}(`[^a-zA-Z0-9_]+`) + func protoIdentNormalize{{ $pbEnumIdent.GoName }}(e string) string { + return protoIdentNormalizeRegexp{{ $pbEnumIdent.GoName }}.ReplaceAllString(e, "_") + } + + func toProto{{ $pbEnumIdent.GoName }} (e {{ ident $entEnumIdent }}) {{ ident $pbEnumIdent }} { + if v, ok := {{ $pbEnumIdent.GoName }}_value[{{ qualify "strings" "ToUpper" }}({{ if not $omitPrefix }}"{{ $enumFieldPrefix }}" + {{ end }}protoIdentNormalize{{ $pbEnumIdent.GoName }}(string(e)))]; ok { return {{ $pbEnumIdent | ident }}(v) } return {{ $pbEnumIdent | ident }}(0) @@ -19,7 +24,7 @@ if v, ok := {{ $pbEnumIdent.GoName }}_name[int32(e)]; ok { entVal := map[string]string{ {{- range .EntField.Enums }} - "{{ if not $omitPrefix }}{{ $enumFieldPrefix }}{{ end }}{{ upper .Value }}": "{{ .Value }}", + "{{ if not $omitPrefix }}{{ $enumFieldPrefix }}{{ end }}{{ protoIdentNormalize .Value }}": "{{ .Value }}", {{- end }} }[v] return {{ ident $entEnumIdent }}(entVal) diff --git a/entproto/enum.go b/entproto/enum.go index 7911f21eb..dabf45497 100644 --- a/entproto/enum.go +++ b/entproto/enum.go @@ -17,6 +17,8 @@ package entproto import ( "errors" "fmt" + "regexp" + "strings" "github.com/mitchellh/mapstructure" @@ -29,6 +31,7 @@ const ( var ( ErrEnumFieldsNotAnnotated = errors.New("entproto: all Enum options must be covered with an entproto.Enum annotation") + normalizeEnumIdent = regexp.MustCompile(`[^a-zA-Z0-9_]+`) ) type EnumOption func(*enum) @@ -76,11 +79,18 @@ func (e *enum) Verify(fld *gen.Field) error { if len(e.Options) != len(fld.Enums) { return ErrEnumFieldsNotAnnotated } + pbIdentifiers := make(map[string]struct{}, len(fld.Enums)) for _, opt := range fld.Enums { if _, ok := e.Options[opt.Value]; !ok { return fmt.Errorf("entproto: Enum option %s is not annotated with"+ " a pbfield number using entproto.Enum", opt.Name) } + pbIdent := NormalizeEnumIdentifier(opt.Value) + if _, ok := pbIdentifiers[pbIdent]; ok { + return fmt.Errorf("entproto: Enum option %q produces conflicting pbfield"+ + " name %q after normalization", opt.Name, pbIdent) + } + pbIdentifiers[pbIdent] = struct{}{} } // If default value is set on the pbfield, make sure it's option number is zero. @@ -126,3 +136,9 @@ func extractEnumAnnotation(fld *gen.Field) (*enum, error) { return &out, nil } + +// NormalizeEnumIdentifier normalizes the identifier of an enum pbfield +// to match the Proto Style Guide. +func NormalizeEnumIdentifier(s string) string { + return strings.ToUpper(normalizeEnumIdent.ReplaceAllString(s, "_")) +} diff --git a/entproto/extension.go b/entproto/extension.go index f4abda8cd..c1cd0667a 100644 --- a/entproto/extension.go +++ b/entproto/extension.go @@ -56,7 +56,8 @@ func NewExtension(opts ...ExtensionOption) (*Extension, error) { // } type Extension struct { entc.DefaultExtension - protoDir string + protoDir string + skipGenFile bool } // WithProtoDir sets the directory where the generated .proto files will be written. @@ -66,6 +67,13 @@ func WithProtoDir(dir string) ExtensionOption { } } +// SkipGenFile skips the generation of a generate.go file next to each .proto file. +func SkipGenFile() ExtensionOption { + return func(e *Extension) { + e.skipGenFile = true + } +} + // Hooks implements entc.Extension. func (e *Extension) Hooks() []gen.Hook { return []gen.Hook{e.hook()} @@ -101,9 +109,11 @@ func Hook() gen.Hook { return x.hook() } -// Generate takes a *gen.Graph and creates .proto files. Next to each .proto file, Generate creates a generate.go +// Generate takes a *gen.Graph and creates .proto files. +// Next to each .proto file, Generate creates a generate.go // file containing a //go:generate directive to invoke protoc and compile Go code from the protobuf definitions. // If generate.go already exists next to the .proto file, this step is skipped. +// To disable the generation of the generate.go file, use the `entproto.SkipGenFile()` option. func Generate(g *gen.Graph) error { x := &Extension{} return x.generate(g) @@ -138,24 +148,27 @@ func (e *Extension) generate(g *gen.Graph) error { if err = printer.PrintProtosToFileSystem(allDescriptors, entProtoDir); err != nil { return fmt.Errorf("entproto: failed writing .proto files: %w", err) } - // Print a generate.go file with protoc command for go file generation - for _, fd := range allDescriptors { - protoFilePath := filepath.Join(entProtoDir, fd.GetName()) - dir := filepath.Dir(protoFilePath) - genGoPath := filepath.Join(dir, "generate.go") - if !fileExists(genGoPath) { - abs, err := filepath.Abs(dir) - if err != nil { - return fmt.Errorf("entproto: failed generating generate.go file for %q: %w", protoFilePath, err) - } - toBase, err := filepath.Rel(abs, g.Config.Target) - if err != nil { - return fmt.Errorf("entproto: failed generating generate.go file for %q: %w", protoFilePath, err) - } - toSchema := filepath.Join(toBase, "schema") - contents := protocGenerateGo(fd, toSchema) - if err := os.WriteFile(genGoPath, []byte(contents), 0600); err != nil { - return fmt.Errorf("entproto: failed generating generate.go file for %q: %w", protoFilePath, err) + + if !e.skipGenFile { + // Print a generate.go file with protoc command for go file generation + for _, fd := range allDescriptors { + protoFilePath := filepath.Join(entProtoDir, fd.GetName()) + dir := filepath.Dir(protoFilePath) + genGoPath := filepath.Join(dir, "generate.go") + if !fileExists(genGoPath) { + abs, err := filepath.Abs(dir) + if err != nil { + return fmt.Errorf("entproto: failed generating generate.go file for %q: %w", protoFilePath, err) + } + toBase, err := filepath.Rel(abs, g.Config.Target) + if err != nil { + return fmt.Errorf("entproto: failed generating generate.go file for %q: %w", protoFilePath, err) + } + toSchema := filepath.Join(toBase, "schema") + contents := protocGenerateGo(fd, toSchema) + if err := os.WriteFile(genGoPath, []byte(contents), 0600); err != nil { + return fmt.Errorf("entproto: failed generating generate.go file for %q: %w", protoFilePath, err) + } } } } diff --git a/entproto/internal/altdir/ent/client.go b/entproto/internal/altdir/ent/client.go index 34b06fdef..e96ef9164 100644 --- a/entproto/internal/altdir/ent/client.go +++ b/entproto/internal/altdir/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entproto/internal/altdir/ent/migrate" "entgo.io/ent" @@ -27,9 +28,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -57,6 +56,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -104,11 +110,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -220,6 +229,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) diff --git a/entproto/internal/altdir/ent/runtime/runtime.go b/entproto/internal/altdir/ent/runtime/runtime.go index f615b5e44..138a05ce2 100644 --- a/entproto/internal/altdir/ent/runtime/runtime.go +++ b/entproto/internal/altdir/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entproto/internal/altdir/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entproto/internal/altdir/ent/user/where.go b/entproto/internal/altdir/ent/user/where.go index 494b8165c..c3e1cb08c 100644 --- a/entproto/internal/altdir/ent/user/where.go +++ b/entproto/internal/altdir/ent/user/where.go @@ -124,32 +124,15 @@ func NameContainsFold(v string) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entproto/internal/altdir/ent/user_create.go b/entproto/internal/altdir/ent/user_create.go index 587a219c1..a208a6d1d 100644 --- a/entproto/internal/altdir/ent/user_create.go +++ b/entproto/internal/altdir/ent/user_create.go @@ -32,7 +32,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -98,11 +98,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entproto/internal/altdir/ent/user_delete.go b/entproto/internal/altdir/ent/user_delete.go index b1fcac1ea..848a5d9e6 100644 --- a/entproto/internal/altdir/ent/user_delete.go +++ b/entproto/internal/altdir/ent/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/altdir/ent/user_update.go b/entproto/internal/altdir/ent/user_update.go index 66e12b926..4d5849a75 100644 --- a/entproto/internal/altdir/ent/user_update.go +++ b/entproto/internal/altdir/ent/user_update.go @@ -33,6 +33,14 @@ func (uu *UserUpdate) SetName(s string) *UserUpdate { return uu } +// SetNillableName sets the "name" field if the given value is not nil. +func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate { + if s != nil { + uu.SetName(*s) + } + return uu +} + // Mutation returns the UserMutation object of the builder. func (uu *UserUpdate) Mutation() *UserMutation { return uu.mutation @@ -40,7 +48,7 @@ func (uu *UserUpdate) Mutation() *UserMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -103,6 +111,14 @@ func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne { return uuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne { + if s != nil { + uuo.SetName(*s) + } + return uuo +} + // Mutation returns the UserMutation object of the builder. func (uuo *UserUpdateOne) Mutation() *UserMutation { return uuo.mutation @@ -123,7 +139,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/bare/ent/client.go b/entproto/internal/bare/ent/client.go new file mode 100644 index 000000000..7bd2946e5 --- /dev/null +++ b/entproto/internal/bare/ent/client.go @@ -0,0 +1,340 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "entgo.io/contrib/entproto/internal/bare/ent/migrate" + "entgo.io/ent" + + "entgo.io/contrib/entproto/internal/bare/ent/user" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // User is the client for interacting with the User builders. + User *UserClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + client := &Client{config: newConfig(opts...)} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.User = NewUserClient(c.config) +} + +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, ErrTxStarted + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + User: NewUserClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, errors.New("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + User: NewUserClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// User. +// Query(). +// Count(ctx) +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + c.User.Use(hooks...) +} + +// Intercept adds the query interceptors to all the entity clients. +// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. +func (c *Client) Intercept(interceptors ...Interceptor) { + c.User.Intercept(interceptors...) +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *UserMutation: + return c.User.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// UserClient is a client for the User schema. +type UserClient struct { + config +} + +// NewUserClient returns a client for the User from the given config. +func NewUserClient(c config) *UserClient { + return &UserClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`. +func (c *UserClient) Use(hooks ...Hook) { + c.hooks.User = append(c.hooks.User, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`. +func (c *UserClient) Intercept(interceptors ...Interceptor) { + c.inters.User = append(c.inters.User, interceptors...) +} + +// Create returns a builder for creating a User entity. +func (c *UserClient) Create() *UserCreate { + mutation := newUserMutation(c.config, OpCreate) + return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of User entities. +func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { + return &UserCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for User. +func (c *UserClient) Update() *UserUpdate { + mutation := newUserMutation(c.config, OpUpdate) + return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserClient) UpdateOne(u *User) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUser(u)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserClient) UpdateOneID(id int) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for User. +func (c *UserClient) Delete() *UserDelete { + mutation := newUserMutation(c.config, OpDelete) + return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserClient) DeleteOne(u *User) *UserDeleteOne { + return c.DeleteOneID(u.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserClient) DeleteOneID(id int) *UserDeleteOne { + builder := c.Delete().Where(user.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserDeleteOne{builder} +} + +// Query returns a query builder for User. +func (c *UserClient) Query() *UserQuery { + return &UserQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUser}, + inters: c.Interceptors(), + } +} + +// Get returns a User entity by its id. +func (c *UserClient) Get(ctx context.Context, id int) (*User, error) { + return c.Query().Where(user.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserClient) GetX(ctx context.Context, id int) *User { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *UserClient) Hooks() []Hook { + return c.hooks.User +} + +// Interceptors returns the client interceptors. +func (c *UserClient) Interceptors() []Interceptor { + return c.inters.User +} + +func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + User []ent.Hook + } + inters struct { + User []ent.Interceptor + } +) diff --git a/entproto/internal/bare/ent/ent.go b/entproto/internal/bare/ent/ent.go new file mode 100644 index 000000000..be98c0fec --- /dev/null +++ b/entproto/internal/bare/ent/ent.go @@ -0,0 +1,608 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "reflect" + "sync" + + "entgo.io/contrib/entproto/internal/bare/ent/user" + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + +// OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. +type OrderFunc func(*sql.Selector) + +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// columnChecker checks if the column exists in the given table. +func checkColumn(table, column string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + user.Table: user.ValidColumn, + }) + }) + return columnCheck(table, column) +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +// selector embedded by the different Select/GroupBy builders. +type selector struct { + label string + flds *[]string + fns []AggregateFunc + scan func(context.Context, any) error +} + +// ScanX is like Scan, but panics if an error occurs. +func (s *selector) ScanX(ctx context.Context, v any) { + if err := s.scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (s *selector) Strings(ctx context.Context) ([]string, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (s *selector) StringsX(ctx context.Context) []string { + v, err := s.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (s *selector) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = s.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (s *selector) StringX(ctx context.Context) string { + v, err := s.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (s *selector) Ints(ctx context.Context) ([]int, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (s *selector) IntsX(ctx context.Context) []int { + v, err := s.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (s *selector) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = s.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (s *selector) IntX(ctx context.Context) int { + v, err := s.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (s *selector) Float64s(ctx context.Context) ([]float64, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (s *selector) Float64sX(ctx context.Context) []float64 { + v, err := s.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (s *selector) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = s.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (s *selector) Float64X(ctx context.Context) float64 { + v, err := s.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (s *selector) Bools(ctx context.Context) ([]bool, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (s *selector) BoolsX(ctx context.Context) []bool { + v, err := s.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (s *selector) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = s.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (s *selector) BoolX(ctx context.Context) bool { + v, err := s.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := any(m).(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + +// queryHook describes an internal hook for the different sqlAll methods. +type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/entproto/internal/bare/ent/enttest/enttest.go b/entproto/internal/bare/ent/enttest/enttest.go new file mode 100644 index 000000000..a7f248f33 --- /dev/null +++ b/entproto/internal/bare/ent/enttest/enttest.go @@ -0,0 +1,84 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + + "entgo.io/contrib/entproto/internal/bare/ent" + // required by schema hooks. + _ "entgo.io/contrib/entproto/internal/bare/ent/runtime" + + "entgo.io/contrib/entproto/internal/bare/ent/migrate" + "entgo.io/ent/dialect/sql/schema" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...any) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + migrateSchema(t, c, o) + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + migrateSchema(t, c, o) + return c +} +func migrateSchema(t TestingT, c *ent.Client, o *options) { + tables, err := schema.CopyTables(migrate.Tables) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } +} diff --git a/entproto/internal/bare/ent/generate.go b/entproto/internal/bare/ent/generate.go new file mode 100644 index 000000000..58178a99a --- /dev/null +++ b/entproto/internal/bare/ent/generate.go @@ -0,0 +1,18 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ent + +//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema +//go:generate go run -mod=mod entgo.io/contrib/entproto/cmd/entproto -path ./schema diff --git a/entproto/internal/bare/ent/hook/hook.go b/entproto/internal/bare/ent/hook/hook.go new file mode 100644 index 000000000..0febcc54a --- /dev/null +++ b/entproto/internal/bare/ent/hook/hook.go @@ -0,0 +1,199 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + + "entgo.io/contrib/entproto/internal/bare/ent" +) + +// The UserFunc type is an adapter to allow the use of ordinary +// function as User mutator. +type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/entproto/internal/bare/ent/migrate/migrate.go b/entproto/internal/bare/ent/migrate/migrate.go new file mode 100644 index 000000000..1956a6bf6 --- /dev/null +++ b/entproto/internal/bare/ent/migrate/migrate.go @@ -0,0 +1,64 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + return Create(ctx, s, Tables, opts...) +} + +// Create creates all table resources using the given schema driver. +func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) +} diff --git a/entproto/internal/bare/ent/migrate/schema.go b/entproto/internal/bare/ent/migrate/schema.go new file mode 100644 index 000000000..cb1345e82 --- /dev/null +++ b/entproto/internal/bare/ent/migrate/schema.go @@ -0,0 +1,30 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // UsersColumns holds the columns for the "users" table. + UsersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "name", Type: field.TypeString, Unique: true}, + {Name: "email_address", Type: field.TypeString, Unique: true}, + } + // UsersTable holds the schema information for the "users" table. + UsersTable = &schema.Table{ + Name: "users", + Columns: UsersColumns, + PrimaryKey: []*schema.Column{UsersColumns[0]}, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + UsersTable, + } +) + +func init() { +} diff --git a/entproto/internal/bare/ent/mutation.go b/entproto/internal/bare/ent/mutation.go new file mode 100644 index 000000000..e9503fb00 --- /dev/null +++ b/entproto/internal/bare/ent/mutation.go @@ -0,0 +1,407 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "sync" + + "entgo.io/contrib/entproto/internal/bare/ent/predicate" + "entgo.io/contrib/entproto/internal/bare/ent/user" + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeUser = "User" +) + +// UserMutation represents an operation that mutates the User nodes in the graph. +type UserMutation struct { + config + op Op + typ string + id *int + name *string + email_address *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*User, error) + predicates []predicate.User +} + +var _ ent.Mutation = (*UserMutation)(nil) + +// userOption allows management of the mutation configuration using functional options. +type userOption func(*UserMutation) + +// newUserMutation creates new mutation for the User entity. +func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { + m := &UserMutation{ + config: c, + op: op, + typ: TypeUser, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserID sets the ID field of the mutation. +func withUserID(id int) userOption { + return func(m *UserMutation) { + var ( + err error + once sync.Once + value *User + ) + m.oldValue = func(ctx context.Context) (*User, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().User.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUser sets the old User of the mutation. +func withUser(node *User) userOption { + return func(m *UserMutation) { + m.oldValue = func(context.Context) (*User, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UserMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UserMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UserMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().User.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetName sets the "name" field. +func (m *UserMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *UserMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *UserMutation) ResetName() { + m.name = nil +} + +// SetEmailAddress sets the "email_address" field. +func (m *UserMutation) SetEmailAddress(s string) { + m.email_address = &s +} + +// EmailAddress returns the value of the "email_address" field in the mutation. +func (m *UserMutation) EmailAddress() (r string, exists bool) { + v := m.email_address + if v == nil { + return + } + return *v, true +} + +// OldEmailAddress returns the old "email_address" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldEmailAddress(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEmailAddress is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEmailAddress requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEmailAddress: %w", err) + } + return oldValue.EmailAddress, nil +} + +// ResetEmailAddress resets all changes to the "email_address" field. +func (m *UserMutation) ResetEmailAddress() { + m.email_address = nil +} + +// Where appends a list predicates to the UserMutation builder. +func (m *UserMutation) Where(ps ...predicate.User) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.User, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (User). +func (m *UserMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.name != nil { + fields = append(fields, user.FieldName) + } + if m.email_address != nil { + fields = append(fields, user.FieldEmailAddress) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserMutation) Field(name string) (ent.Value, bool) { + switch name { + case user.FieldName: + return m.Name() + case user.FieldEmailAddress: + return m.EmailAddress() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case user.FieldName: + return m.OldName(ctx) + case user.FieldEmailAddress: + return m.OldEmailAddress(ctx) + } + return nil, fmt.Errorf("unknown User field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) SetField(name string, value ent.Value) error { + switch name { + case user.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case user.FieldEmailAddress: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmailAddress(v) + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown User numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserMutation) ClearField(name string) error { + return fmt.Errorf("unknown User nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserMutation) ResetField(name string) error { + switch name { + case user.FieldName: + m.ResetName() + return nil + case user.FieldEmailAddress: + m.ResetEmailAddress() + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown User unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown User edge %s", name) +} diff --git a/entproto/internal/bare/ent/predicate/predicate.go b/entproto/internal/bare/ent/predicate/predicate.go new file mode 100644 index 000000000..af21dfe34 --- /dev/null +++ b/entproto/internal/bare/ent/predicate/predicate.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// User is the predicate function for user builders. +type User func(*sql.Selector) diff --git a/entproto/internal/bare/ent/proto/entpb/entpb.pb.go b/entproto/internal/bare/ent/proto/entpb/entpb.pb.go new file mode 100644 index 000000000..ab7ec610d --- /dev/null +++ b/entproto/internal/bare/ent/proto/entpb/entpb.pb.go @@ -0,0 +1,165 @@ +// Code generated by entproto. DO NOT EDIT. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.19.4 +// source: entpb/entpb.proto + +package entpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type User struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + EmailAddress string `protobuf:"bytes,3,opt,name=email_address,json=emailAddress,proto3" json:"email_address,omitempty"` +} + +func (x *User) Reset() { + *x = User{} + if protoimpl.UnsafeEnabled { + mi := &file_entpb_entpb_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *User) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*User) ProtoMessage() {} + +func (x *User) ProtoReflect() protoreflect.Message { + mi := &file_entpb_entpb_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use User.ProtoReflect.Descriptor instead. +func (*User) Descriptor() ([]byte, []int) { + return file_entpb_entpb_proto_rawDescGZIP(), []int{0} +} + +func (x *User) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *User) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *User) GetEmailAddress() string { + if x != nil { + return x.EmailAddress + } + return "" +} + +var File_entpb_entpb_proto protoreflect.FileDescriptor + +var file_entpb_entpb_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2f, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x22, 0x4f, 0x0a, 0x04, 0x55, 0x73, + 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x39, 0x5a, 0x37, 0x65, + 0x6e, 0x74, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x2f, + 0x65, 0x6e, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2f, 0x62, 0x61, 0x72, 0x65, 0x2f, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_entpb_entpb_proto_rawDescOnce sync.Once + file_entpb_entpb_proto_rawDescData = file_entpb_entpb_proto_rawDesc +) + +func file_entpb_entpb_proto_rawDescGZIP() []byte { + file_entpb_entpb_proto_rawDescOnce.Do(func() { + file_entpb_entpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_entpb_entpb_proto_rawDescData) + }) + return file_entpb_entpb_proto_rawDescData +} + +var file_entpb_entpb_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_entpb_entpb_proto_goTypes = []interface{}{ + (*User)(nil), // 0: entpb.User +} +var file_entpb_entpb_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_entpb_entpb_proto_init() } +func file_entpb_entpb_proto_init() { + if File_entpb_entpb_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_entpb_entpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*User); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_entpb_entpb_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_entpb_entpb_proto_goTypes, + DependencyIndexes: file_entpb_entpb_proto_depIdxs, + MessageInfos: file_entpb_entpb_proto_msgTypes, + }.Build() + File_entpb_entpb_proto = out.File + file_entpb_entpb_proto_rawDesc = nil + file_entpb_entpb_proto_goTypes = nil + file_entpb_entpb_proto_depIdxs = nil +} diff --git a/entproto/internal/bare/ent/proto/entpb/entpb.proto b/entproto/internal/bare/ent/proto/entpb/entpb.proto new file mode 100644 index 000000000..911e603fc --- /dev/null +++ b/entproto/internal/bare/ent/proto/entpb/entpb.proto @@ -0,0 +1,14 @@ +// Code generated by entproto. DO NOT EDIT. +syntax = "proto3"; + +package entpb; + +option go_package = "entgo.io/contrib/entproto/internal/bare/ent/proto/entpb"; + +message User { + int64 id = 1; + + string name = 2; + + string email_address = 3; +} diff --git a/entproto/internal/bare/ent/proto/entpb/generate.go b/entproto/internal/bare/ent/proto/entpb/generate.go new file mode 100644 index 000000000..6d63d4d7b --- /dev/null +++ b/entproto/internal/bare/ent/proto/entpb/generate.go @@ -0,0 +1,17 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package entpb + +//go:generate protoc -I=.. --go_out=.. --go-grpc_out=.. --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --entgrpc_out=.. --entgrpc_opt=paths=source_relative,schema_path=../../schema entpb/entpb.proto diff --git a/entproto/internal/bare/ent/runtime.go b/entproto/internal/bare/ent/runtime.go new file mode 100644 index 000000000..793d053b5 --- /dev/null +++ b/entproto/internal/bare/ent/runtime.go @@ -0,0 +1,9 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { +} diff --git a/entproto/internal/bare/ent/runtime/runtime.go b/entproto/internal/bare/ent/runtime/runtime.go new file mode 100644 index 000000000..13ff8e40d --- /dev/null +++ b/entproto/internal/bare/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in entgo.io/contrib/entproto/internal/bare/ent/runtime.go + +const ( + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. +) diff --git a/entproto/internal/bare/ent/schema/user.go b/entproto/internal/bare/ent/schema/user.go new file mode 100644 index 000000000..a1ae230c3 --- /dev/null +++ b/entproto/internal/bare/ent/schema/user.go @@ -0,0 +1,49 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "entgo.io/contrib/entproto" + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" +) + +// User holds the schema definition for the User entity. +type User struct { + ent.Schema +} + +// Fields of the User. +func (User) Fields() []ent.Field { + return []ent.Field{ + field.String("name"). + Unique(). + Annotations( + entproto.Field(2), + ), + field.String("email_address"). + Unique(). + Annotations( + entproto.Field(3), + ), + } +} + +func (User) Annotations() []schema.Annotation { + return []schema.Annotation{ + entproto.Message(), + } +} diff --git a/entproto/internal/bare/ent/tx.go b/entproto/internal/bare/ent/tx.go new file mode 100644 index 000000000..8bbe7fa76 --- /dev/null +++ b/entproto/internal/bare/ent/tx.go @@ -0,0 +1,210 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // User is the client for interacting with the User builders. + User *UserClient + + // lazily loaded. + client *Client + clientOnce sync.Once + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Commit method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + txDriver.mu.Lock() + hooks := append([]CommitHook(nil), txDriver.onCommit...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onCommit = append(txDriver.onCommit, f) + txDriver.mu.Unlock() +} + +type ( + // Rollbacker is the interface that wraps the Rollback method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + txDriver.mu.Lock() + hooks := append([]RollbackHook(nil), txDriver.onRollback...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onRollback = append(txDriver.onRollback, f) + txDriver.mu.Unlock() +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.User = NewUserClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: User.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx + // completion hooks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) diff --git a/entproto/internal/bare/ent/user.go b/entproto/internal/bare/ent/user.go new file mode 100644 index 000000000..f1c49c39f --- /dev/null +++ b/entproto/internal/bare/ent/user.go @@ -0,0 +1,114 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/contrib/entproto/internal/bare/ent/user" + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// User is the model entity for the User schema. +type User struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // EmailAddress holds the value of the "email_address" field. + EmailAddress string `json:"email_address,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*User) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case user.FieldID: + values[i] = new(sql.NullInt64) + case user.FieldName, user.FieldEmailAddress: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the User fields. +func (u *User) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case user.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + u.ID = int(value.Int64) + case user.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + u.Name = value.String + } + case user.FieldEmailAddress: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field email_address", values[i]) + } else if value.Valid { + u.EmailAddress = value.String + } + default: + u.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the User. +// This includes values selected through modifiers, order, etc. +func (u *User) Value(name string) (ent.Value, error) { + return u.selectValues.Get(name) +} + +// Update returns a builder for updating this User. +// Note that you need to call User.Unwrap() before calling this method if this User +// was returned from a transaction, and the transaction was committed or rolled back. +func (u *User) Update() *UserUpdateOne { + return NewUserClient(u.config).UpdateOne(u) +} + +// Unwrap unwraps the User entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (u *User) Unwrap() *User { + _tx, ok := u.config.driver.(*txDriver) + if !ok { + panic("ent: User is not a transactional entity") + } + u.config.driver = _tx.drv + return u +} + +// String implements the fmt.Stringer. +func (u *User) String() string { + var builder strings.Builder + builder.WriteString("User(") + builder.WriteString(fmt.Sprintf("id=%v, ", u.ID)) + builder.WriteString("name=") + builder.WriteString(u.Name) + builder.WriteString(", ") + builder.WriteString("email_address=") + builder.WriteString(u.EmailAddress) + builder.WriteByte(')') + return builder.String() +} + +// Users is a parsable slice of User. +type Users []*User diff --git a/entproto/internal/bare/ent/user/user.go b/entproto/internal/bare/ent/user/user.go new file mode 100644 index 000000000..2bd9bb532 --- /dev/null +++ b/entproto/internal/bare/ent/user/user.go @@ -0,0 +1,55 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the user type in the database. + Label = "user" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldEmailAddress holds the string denoting the email_address field in the database. + FieldEmailAddress = "email_address" + // Table holds the table name of the user in the database. + Table = "users" +) + +// Columns holds all SQL columns for user fields. +var Columns = []string{ + FieldID, + FieldName, + FieldEmailAddress, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the User queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByEmailAddress orders the results by the email_address field. +func ByEmailAddress(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEmailAddress, opts...).ToFunc() +} diff --git a/entproto/internal/bare/ent/user/where.go b/entproto/internal/bare/ent/user/where.go new file mode 100644 index 000000000..7ad3895bd --- /dev/null +++ b/entproto/internal/bare/ent/user/where.go @@ -0,0 +1,208 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "entgo.io/contrib/entproto/internal/bare/ent/predicate" + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.User { + return predicate.User(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.User { + return predicate.User(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.User { + return predicate.User(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.User { + return predicate.User(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.User { + return predicate.User(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.User { + return predicate.User(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.User { + return predicate.User(sql.FieldLTE(FieldID, id)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldName, v)) +} + +// EmailAddress applies equality check predicate on the "email_address" field. It's identical to EmailAddressEQ. +func EmailAddress(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmailAddress, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldName, v)) +} + +// EmailAddressEQ applies the EQ predicate on the "email_address" field. +func EmailAddressEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmailAddress, v)) +} + +// EmailAddressNEQ applies the NEQ predicate on the "email_address" field. +func EmailAddressNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldEmailAddress, v)) +} + +// EmailAddressIn applies the In predicate on the "email_address" field. +func EmailAddressIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldEmailAddress, vs...)) +} + +// EmailAddressNotIn applies the NotIn predicate on the "email_address" field. +func EmailAddressNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldEmailAddress, vs...)) +} + +// EmailAddressGT applies the GT predicate on the "email_address" field. +func EmailAddressGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldEmailAddress, v)) +} + +// EmailAddressGTE applies the GTE predicate on the "email_address" field. +func EmailAddressGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldEmailAddress, v)) +} + +// EmailAddressLT applies the LT predicate on the "email_address" field. +func EmailAddressLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldEmailAddress, v)) +} + +// EmailAddressLTE applies the LTE predicate on the "email_address" field. +func EmailAddressLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldEmailAddress, v)) +} + +// EmailAddressContains applies the Contains predicate on the "email_address" field. +func EmailAddressContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldEmailAddress, v)) +} + +// EmailAddressHasPrefix applies the HasPrefix predicate on the "email_address" field. +func EmailAddressHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldEmailAddress, v)) +} + +// EmailAddressHasSuffix applies the HasSuffix predicate on the "email_address" field. +func EmailAddressHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldEmailAddress, v)) +} + +// EmailAddressEqualFold applies the EqualFold predicate on the "email_address" field. +func EmailAddressEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldEmailAddress, v)) +} + +// EmailAddressContainsFold applies the ContainsFold predicate on the "email_address" field. +func EmailAddressContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldEmailAddress, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.User) predicate.User { + return predicate.User(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.User) predicate.User { + return predicate.User(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.User) predicate.User { + return predicate.User(sql.NotPredicates(p)) +} diff --git a/entproto/internal/bare/ent/user_create.go b/entproto/internal/bare/ent/user_create.go new file mode 100644 index 000000000..faa9ca5ec --- /dev/null +++ b/entproto/internal/bare/ent/user_create.go @@ -0,0 +1,196 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/contrib/entproto/internal/bare/ent/user" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserCreate is the builder for creating a User entity. +type UserCreate struct { + config + mutation *UserMutation + hooks []Hook +} + +// SetName sets the "name" field. +func (uc *UserCreate) SetName(s string) *UserCreate { + uc.mutation.SetName(s) + return uc +} + +// SetEmailAddress sets the "email_address" field. +func (uc *UserCreate) SetEmailAddress(s string) *UserCreate { + uc.mutation.SetEmailAddress(s) + return uc +} + +// Mutation returns the UserMutation object of the builder. +func (uc *UserCreate) Mutation() *UserMutation { + return uc.mutation +} + +// Save creates the User in the database. +func (uc *UserCreate) Save(ctx context.Context) (*User, error) { + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (uc *UserCreate) SaveX(ctx context.Context) *User { + v, err := uc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (uc *UserCreate) Exec(ctx context.Context) error { + _, err := uc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uc *UserCreate) ExecX(ctx context.Context) { + if err := uc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (uc *UserCreate) check() error { + if _, ok := uc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "User.name"`)} + } + if _, ok := uc.mutation.EmailAddress(); !ok { + return &ValidationError{Name: "email_address", err: errors.New(`ent: missing required field "User.email_address"`)} + } + return nil +} + +func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { + if err := uc.check(); err != nil { + return nil, err + } + _node, _spec := uc.createSpec() + if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + uc.mutation.id = &_node.ID + uc.mutation.done = true + return _node, nil +} + +func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { + var ( + _node = &User{config: uc.config} + _spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + ) + if value, ok := uc.mutation.Name(); ok { + _spec.SetField(user.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := uc.mutation.EmailAddress(); ok { + _spec.SetField(user.FieldEmailAddress, field.TypeString, value) + _node.EmailAddress = value + } + return _node, _spec +} + +// UserCreateBulk is the builder for creating many User entities in bulk. +type UserCreateBulk struct { + config + err error + builders []*UserCreate +} + +// Save creates the User entities in the database. +func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } + specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) + nodes := make([]*User, len(ucb.builders)) + mutators := make([]Mutator, len(ucb.builders)) + for i := range ucb.builders { + func(i int, root context.Context) { + builder := ucb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User { + v, err := ucb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ucb *UserCreateBulk) Exec(ctx context.Context) error { + _, err := ucb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ucb *UserCreateBulk) ExecX(ctx context.Context) { + if err := ucb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/entproto/internal/bare/ent/user_delete.go b/entproto/internal/bare/ent/user_delete.go new file mode 100644 index 000000000..6e580c429 --- /dev/null +++ b/entproto/internal/bare/ent/user_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/contrib/entproto/internal/bare/ent/predicate" + "entgo.io/contrib/entproto/internal/bare/ent/user" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserDelete is the builder for deleting a User entity. +type UserDelete struct { + config + hooks []Hook + mutation *UserMutation +} + +// Where appends a list predicates to the UserDelete builder. +func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { + ud.mutation.Where(ps...) + return ud +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ud *UserDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (ud *UserDelete) ExecX(ctx context.Context) int { + n, err := ud.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + if ps := ud.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + ud.mutation.done = true + return affected, err +} + +// UserDeleteOne is the builder for deleting a single User entity. +type UserDeleteOne struct { + ud *UserDelete +} + +// Where appends a list predicates to the UserDelete builder. +func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne { + udo.ud.mutation.Where(ps...) + return udo +} + +// Exec executes the deletion query. +func (udo *UserDeleteOne) Exec(ctx context.Context) error { + n, err := udo.ud.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{user.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (udo *UserDeleteOne) ExecX(ctx context.Context) { + if err := udo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/entproto/internal/bare/ent/user_query.go b/entproto/internal/bare/ent/user_query.go new file mode 100644 index 000000000..1d6491232 --- /dev/null +++ b/entproto/internal/bare/ent/user_query.go @@ -0,0 +1,526 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/contrib/entproto/internal/bare/ent/predicate" + "entgo.io/contrib/entproto/internal/bare/ent/user" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserQuery is the builder for querying User entities. +type UserQuery struct { + config + ctx *QueryContext + order []user.OrderOption + inters []Interceptor + predicates []predicate.User + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserQuery builder. +func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery { + uq.predicates = append(uq.predicates, ps...) + return uq +} + +// Limit the number of records to be returned by this query. +func (uq *UserQuery) Limit(limit int) *UserQuery { + uq.ctx.Limit = &limit + return uq +} + +// Offset to start from. +func (uq *UserQuery) Offset(offset int) *UserQuery { + uq.ctx.Offset = &offset + return uq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (uq *UserQuery) Unique(unique bool) *UserQuery { + uq.ctx.Unique = &unique + return uq +} + +// Order specifies how the records should be ordered. +func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery { + uq.order = append(uq.order, o...) + return uq +} + +// First returns the first User entity from the query. +// Returns a *NotFoundError when no User was found. +func (uq *UserQuery) First(ctx context.Context) (*User, error) { + nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{user.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (uq *UserQuery) FirstX(ctx context.Context) *User { + node, err := uq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first User ID from the query. +// Returns a *NotFoundError when no User ID was found. +func (uq *UserQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{user.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (uq *UserQuery) FirstIDX(ctx context.Context) int { + id, err := uq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single User entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one User entity is found. +// Returns a *NotFoundError when no User entities are found. +func (uq *UserQuery) Only(ctx context.Context) (*User, error) { + nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{user.Label} + default: + return nil, &NotSingularError{user.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (uq *UserQuery) OnlyX(ctx context.Context) *User { + node, err := uq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only User ID in the query. +// Returns a *NotSingularError when more than one User ID is found. +// Returns a *NotFoundError when no entities are found. +func (uq *UserQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{user.Label} + default: + err = &NotSingularError{user.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (uq *UserQuery) OnlyIDX(ctx context.Context) int { + id, err := uq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Users. +func (uq *UserQuery) All(ctx context.Context) ([]*User, error) { + ctx = setContextOp(ctx, uq.ctx, "All") + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*User, *UserQuery]() + return withInterceptors[[]*User](ctx, uq, qr, uq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (uq *UserQuery) AllX(ctx context.Context) []*User { + nodes, err := uq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of User IDs. +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } + ctx = setContextOp(ctx, uq.ctx, "IDs") + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (uq *UserQuery) IDsX(ctx context.Context) []int { + ids, err := uq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (uq *UserQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, uq.ctx, "Count") + if err := uq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, uq, querierCount[*UserQuery](), uq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (uq *UserQuery) CountX(ctx context.Context) int { + count, err := uq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, uq.ctx, "Exist") + switch _, err := uq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (uq *UserQuery) ExistX(ctx context.Context) bool { + exist, err := uq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (uq *UserQuery) Clone() *UserQuery { + if uq == nil { + return nil + } + return &UserQuery{ + config: uq.config, + ctx: uq.ctx.Clone(), + order: append([]user.OrderOption{}, uq.order...), + inters: append([]Interceptor{}, uq.inters...), + predicates: append([]predicate.User{}, uq.predicates...), + // clone intermediate query. + sql: uq.sql.Clone(), + path: uq.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.User.Query(). +// GroupBy(user.FieldName). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { + uq.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserGroupBy{build: uq} + grbuild.flds = &uq.ctx.Fields + grbuild.label = user.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// } +// +// client.User.Query(). +// Select(user.FieldName). +// Scan(ctx, &v) +func (uq *UserQuery) Select(fields ...string) *UserSelect { + uq.ctx.Fields = append(uq.ctx.Fields, fields...) + sbuild := &UserSelect{UserQuery: uq} + sbuild.label = user.Label + sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserSelect configured with the given aggregations. +func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect { + return uq.Select().Aggregate(fns...) +} + +func (uq *UserQuery) prepareQuery(ctx context.Context) error { + for _, inter := range uq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, uq); err != nil { + return err + } + } + } + for _, f := range uq.ctx.Fields { + if !user.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if uq.path != nil { + prev, err := uq.path(ctx) + if err != nil { + return err + } + uq.sql = prev + } + return nil +} + +func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { + var ( + nodes = []*User{} + _spec = uq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*User).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &User{config: uq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { + _spec := uq.querySpec() + _spec.Node.Columns = uq.ctx.Fields + if len(uq.ctx.Fields) > 0 { + _spec.Unique = uq.ctx.Unique != nil && *uq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, uq.driver, _spec) +} + +func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql + if unique := uq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true + } + if fields := uq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for i := range fields { + if fields[i] != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := uq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := uq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := uq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := uq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(uq.driver.Dialect()) + t1 := builder.Table(user.Table) + columns := uq.ctx.Fields + if len(columns) == 0 { + columns = user.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if uq.sql != nil { + selector = uq.sql + selector.Select(selector.Columns(columns...)...) + } + if uq.ctx.Unique != nil && *uq.ctx.Unique { + selector.Distinct() + } + for _, p := range uq.predicates { + p(selector) + } + for _, p := range uq.order { + p(selector) + } + if offset := uq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := uq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// UserGroupBy is the group-by builder for User entities. +type UserGroupBy struct { + selector + build *UserQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { + ugb.fns = append(ugb.fns, fns...) + return ugb +} + +// Scan applies the selector query and scans the result into the given value. +func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ugb.build.ctx, "GroupBy") + if err := ugb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v) +} + +func (ugb *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ugb.fns)) + for _, fn := range ugb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns)) + for _, f := range *ugb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ugb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserSelect is the builder for selecting fields of User entities. +type UserSelect struct { + *UserQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { + us.fns = append(us.fns, fns...) + return us +} + +// Scan applies the selector query and scans the result into the given value. +func (us *UserSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, us.ctx, "Select") + if err := us.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserQuery, *UserSelect](ctx, us.UserQuery, us, us.inters, v) +} + +func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(us.fns)) + for _, fn := range us.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*us.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := us.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/entproto/internal/bare/ent/user_update.go b/entproto/internal/bare/ent/user_update.go new file mode 100644 index 000000000..a9b1f9403 --- /dev/null +++ b/entproto/internal/bare/ent/user_update.go @@ -0,0 +1,243 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/contrib/entproto/internal/bare/ent/predicate" + "entgo.io/contrib/entproto/internal/bare/ent/user" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserUpdate is the builder for updating User entities. +type UserUpdate struct { + config + hooks []Hook + mutation *UserMutation +} + +// Where appends a list predicates to the UserUpdate builder. +func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate { + uu.mutation.Where(ps...) + return uu +} + +// SetName sets the "name" field. +func (uu *UserUpdate) SetName(s string) *UserUpdate { + uu.mutation.SetName(s) + return uu +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate { + if s != nil { + uu.SetName(*s) + } + return uu +} + +// SetEmailAddress sets the "email_address" field. +func (uu *UserUpdate) SetEmailAddress(s string) *UserUpdate { + uu.mutation.SetEmailAddress(s) + return uu +} + +// SetNillableEmailAddress sets the "email_address" field if the given value is not nil. +func (uu *UserUpdate) SetNillableEmailAddress(s *string) *UserUpdate { + if s != nil { + uu.SetEmailAddress(*s) + } + return uu +} + +// Mutation returns the UserMutation object of the builder. +func (uu *UserUpdate) Mutation() *UserMutation { + return uu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (uu *UserUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (uu *UserUpdate) SaveX(ctx context.Context) int { + affected, err := uu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (uu *UserUpdate) Exec(ctx context.Context) error { + _, err := uu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uu *UserUpdate) ExecX(ctx context.Context) { + if err := uu.Exec(ctx); err != nil { + panic(err) + } +} + +func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + if ps := uu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uu.mutation.Name(); ok { + _spec.SetField(user.FieldName, field.TypeString, value) + } + if value, ok := uu.mutation.EmailAddress(); ok { + _spec.SetField(user.FieldEmailAddress, field.TypeString, value) + } + if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + uu.mutation.done = true + return n, nil +} + +// UserUpdateOne is the builder for updating a single User entity. +type UserUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserMutation +} + +// SetName sets the "name" field. +func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne { + uuo.mutation.SetName(s) + return uuo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne { + if s != nil { + uuo.SetName(*s) + } + return uuo +} + +// SetEmailAddress sets the "email_address" field. +func (uuo *UserUpdateOne) SetEmailAddress(s string) *UserUpdateOne { + uuo.mutation.SetEmailAddress(s) + return uuo +} + +// SetNillableEmailAddress sets the "email_address" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableEmailAddress(s *string) *UserUpdateOne { + if s != nil { + uuo.SetEmailAddress(*s) + } + return uuo +} + +// Mutation returns the UserMutation object of the builder. +func (uuo *UserUpdateOne) Mutation() *UserMutation { + return uuo.mutation +} + +// Where appends a list predicates to the UserUpdate builder. +func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { + uuo.mutation.Where(ps...) + return uuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { + uuo.fields = append([]string{field}, fields...) + return uuo +} + +// Save executes the query and returns the updated User entity. +func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User { + node, err := uuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (uuo *UserUpdateOne) Exec(ctx context.Context) error { + _, err := uuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uuo *UserUpdateOne) ExecX(ctx context.Context) { + if err := uuo.Exec(ctx); err != nil { + panic(err) + } +} + +func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { + _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + id, ok := uuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := uuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for _, f := range fields { + if !user.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := uuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uuo.mutation.Name(); ok { + _spec.SetField(user.FieldName, field.TypeString, value) + } + if value, ok := uuo.mutation.EmailAddress(); ok { + _spec.SetField(user.FieldEmailAddress, field.TypeString, value) + } + _node = &User{config: uuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + uuo.mutation.done = true + return _node, nil +} diff --git a/entproto/internal/entprototest/adapter_test.go b/entproto/internal/entprototest/adapter_test.go index a17eb8ece..6e91d2286 100644 --- a/entproto/internal/entprototest/adapter_test.go +++ b/entproto/internal/entprototest/adapter_test.go @@ -102,6 +102,23 @@ func (suite *AdapterTestSuite) TestMessageWithStrings() { suite.Require().True(field.IsRepeated(), "expected repeated") } +func (suite *AdapterTestSuite) TestMessageWithInts() { + message, err := suite.adapter.GetMessageDescriptor("MessageWithInts") + suite.NoError(err) + field := message.FindFieldByName("int32s") + suite.Require().EqualValues(descriptorpb.FieldDescriptorProto_TYPE_INT32, field.GetType(), "expected repeated") + suite.Require().True(field.IsRepeated(), "expected repeated") + field = message.FindFieldByName("int64s") + suite.Require().EqualValues(descriptorpb.FieldDescriptorProto_TYPE_INT64, field.GetType(), "expected repeated") + suite.Require().True(field.IsRepeated(), "expected repeated") + field = message.FindFieldByName("uint32s") + suite.Require().EqualValues(descriptorpb.FieldDescriptorProto_TYPE_UINT32, field.GetType(), "expected repeated") + suite.Require().True(field.IsRepeated(), "expected repeated") + field = message.FindFieldByName("uint64s") + suite.Require().EqualValues(descriptorpb.FieldDescriptorProto_TYPE_UINT64, field.GetType(), "expected repeated") + suite.Require().True(field.IsRepeated(), "expected repeated") +} + func (suite *AdapterTestSuite) TestExplicitSkippedMessage() { _, err := suite.adapter.GetFileDescriptor("ExplicitSkippedMessage") suite.EqualError(err, entproto.ErrSchemaSkipped.Error()) @@ -123,6 +140,11 @@ func (suite *AdapterTestSuite) TestInvalidField() { suite.EqualError(err, "unsupported field type \"TypeJSON\"") } +func (suite *AdapterTestSuite) TestEnumWithConflictingValue() { + _, err := suite.adapter.GetFileDescriptor("EnumWithConflictingValue") + suite.EqualError(err, "entproto: Enum option \"EnumJpegAlt\" produces conflicting pbfield name \"IMAGE_JPEG\" after normalization") +} + func (suite *AdapterTestSuite) TestDuplicateNumber() { _, err := suite.adapter.GetFileDescriptor("DuplicateNumberMessage") suite.EqualError(err, "entproto: field 2 already defined on message \"DuplicateNumberMessage\"") @@ -180,7 +202,7 @@ func (suite *AdapterTestSuite) TestEnumMessage() { suite.NoError(err) message := fd.FindMessage("entpb.MessageWithEnum") - suite.Len(message.GetFields(), 3) + suite.Len(message.GetFields(), 4) // an enum field with defaults enumField := message.FindFieldByName("enum_type") @@ -202,6 +224,16 @@ func (suite *AdapterTestSuite) TestEnumMessage() { suite.EqualValues(0, enumDesc.FindValueByName("ENUM_WITHOUT_DEFAULT_UNSPECIFIED").GetNumber()) suite.EqualValues(1, enumDesc.FindValueByName("ENUM_WITHOUT_DEFAULT_FIRST").GetNumber()) suite.EqualValues(2, enumDesc.FindValueByName("ENUM_WITHOUT_DEFAULT_SECOND").GetNumber()) + + // an enum field with special characters + enumField = message.FindFieldByName("enum_with_special_characters") + suite.EqualValues(4, enumField.GetNumber()) + suite.EqualValues(descriptorpb.FieldDescriptorProto_TYPE_ENUM, enumField.GetType()) + enumDesc = enumField.GetEnumType() + suite.EqualValues("entpb.MessageWithEnum.EnumWithSpecialCharacters", enumDesc.GetFullyQualifiedName()) + suite.EqualValues(0, enumDesc.FindValueByName("ENUM_WITH_SPECIAL_CHARACTERS_UNSPECIFIED").GetNumber()) + suite.EqualValues(1, enumDesc.FindValueByName("ENUM_WITH_SPECIAL_CHARACTERS_IMAGE_JPEG").GetNumber()) + suite.EqualValues(2, enumDesc.FindValueByName("ENUM_WITH_SPECIAL_CHARACTERS_IMAGE_PNG").GetNumber()) } func (suite *AdapterTestSuite) TestMessageWithId() { diff --git a/entproto/internal/entprototest/ent/allmethodsservice/where.go b/entproto/internal/entprototest/ent/allmethodsservice/where.go index 8b8a3bb4e..2bf627e72 100644 --- a/entproto/internal/entprototest/ent/allmethodsservice/where.go +++ b/entproto/internal/entprototest/ent/allmethodsservice/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.AllMethodsService { // And groups predicates with the AND operator between them. func And(predicates ...predicate.AllMethodsService) predicate.AllMethodsService { - return predicate.AllMethodsService(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.AllMethodsService(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.AllMethodsService) predicate.AllMethodsService { - return predicate.AllMethodsService(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.AllMethodsService(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.AllMethodsService) predicate.AllMethodsService { - return predicate.AllMethodsService(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.AllMethodsService(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/allmethodsservice_create.go b/entproto/internal/entprototest/ent/allmethodsservice_create.go index bdb3e8924..81ad28020 100644 --- a/entproto/internal/entprototest/ent/allmethodsservice_create.go +++ b/entproto/internal/entprototest/ent/allmethodsservice_create.go @@ -25,7 +25,7 @@ func (amsc *AllMethodsServiceCreate) Mutation() *AllMethodsServiceMutation { // Save creates the AllMethodsService in the database. func (amsc *AllMethodsServiceCreate) Save(ctx context.Context) (*AllMethodsService, error) { - return withHooks[*AllMethodsService, AllMethodsServiceMutation](ctx, amsc.sqlSave, amsc.mutation, amsc.hooks) + return withHooks(ctx, amsc.sqlSave, amsc.mutation, amsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (amsc *AllMethodsServiceCreate) createSpec() (*AllMethodsService, *sqlgraph // AllMethodsServiceCreateBulk is the builder for creating many AllMethodsService entities in bulk. type AllMethodsServiceCreateBulk struct { config + err error builders []*AllMethodsServiceCreate } // Save creates the AllMethodsService entities in the database. func (amscb *AllMethodsServiceCreateBulk) Save(ctx context.Context) ([]*AllMethodsService, error) { + if amscb.err != nil { + return nil, amscb.err + } specs := make([]*sqlgraph.CreateSpec, len(amscb.builders)) nodes := make([]*AllMethodsService, len(amscb.builders)) mutators := make([]Mutator, len(amscb.builders)) diff --git a/entproto/internal/entprototest/ent/allmethodsservice_delete.go b/entproto/internal/entprototest/ent/allmethodsservice_delete.go index bbb70520b..30ec3ae8b 100644 --- a/entproto/internal/entprototest/ent/allmethodsservice_delete.go +++ b/entproto/internal/entprototest/ent/allmethodsservice_delete.go @@ -27,7 +27,7 @@ func (amsd *AllMethodsServiceDelete) Where(ps ...predicate.AllMethodsService) *A // Exec executes the deletion query and returns how many vertices were deleted. func (amsd *AllMethodsServiceDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, AllMethodsServiceMutation](ctx, amsd.sqlExec, amsd.mutation, amsd.hooks) + return withHooks(ctx, amsd.sqlExec, amsd.mutation, amsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/allmethodsservice_update.go b/entproto/internal/entprototest/ent/allmethodsservice_update.go index 7ae621f2e..72340e181 100644 --- a/entproto/internal/entprototest/ent/allmethodsservice_update.go +++ b/entproto/internal/entprototest/ent/allmethodsservice_update.go @@ -34,7 +34,7 @@ func (amsu *AllMethodsServiceUpdate) Mutation() *AllMethodsServiceMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (amsu *AllMethodsServiceUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, AllMethodsServiceMutation](ctx, amsu.sqlSave, amsu.mutation, amsu.hooks) + return withHooks(ctx, amsu.sqlSave, amsu.mutation, amsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (amsuo *AllMethodsServiceUpdateOne) Select(field string, fields ...string) // Save executes the query and returns the updated AllMethodsService entity. func (amsuo *AllMethodsServiceUpdateOne) Save(ctx context.Context) (*AllMethodsService, error) { - return withHooks[*AllMethodsService, AllMethodsServiceMutation](ctx, amsuo.sqlSave, amsuo.mutation, amsuo.hooks) + return withHooks(ctx, amsuo.sqlSave, amsuo.mutation, amsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/blogpost/where.go b/entproto/internal/entprototest/ent/blogpost/where.go index 13305de0e..1e01832e4 100644 --- a/entproto/internal/entprototest/ent/blogpost/where.go +++ b/entproto/internal/entprototest/ent/blogpost/where.go @@ -286,32 +286,15 @@ func HasCategoriesWith(preds ...predicate.Category) predicate.BlogPost { // And groups predicates with the AND operator between them. func And(predicates ...predicate.BlogPost) predicate.BlogPost { - return predicate.BlogPost(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BlogPost(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.BlogPost) predicate.BlogPost { - return predicate.BlogPost(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.BlogPost(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.BlogPost) predicate.BlogPost { - return predicate.BlogPost(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.BlogPost(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/blogpost_create.go b/entproto/internal/entprototest/ent/blogpost_create.go index 2e6dc9d29..26cb87b67 100644 --- a/entproto/internal/entprototest/ent/blogpost_create.go +++ b/entproto/internal/entprototest/ent/blogpost_create.go @@ -80,7 +80,7 @@ func (bpc *BlogPostCreate) Mutation() *BlogPostMutation { // Save creates the BlogPost in the database. func (bpc *BlogPostCreate) Save(ctx context.Context) (*BlogPost, error) { - return withHooks[*BlogPost, BlogPostMutation](ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) + return withHooks(ctx, bpc.sqlSave, bpc.mutation, bpc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -193,11 +193,15 @@ func (bpc *BlogPostCreate) createSpec() (*BlogPost, *sqlgraph.CreateSpec) { // BlogPostCreateBulk is the builder for creating many BlogPost entities in bulk. type BlogPostCreateBulk struct { config + err error builders []*BlogPostCreate } // Save creates the BlogPost entities in the database. func (bpcb *BlogPostCreateBulk) Save(ctx context.Context) ([]*BlogPost, error) { + if bpcb.err != nil { + return nil, bpcb.err + } specs := make([]*sqlgraph.CreateSpec, len(bpcb.builders)) nodes := make([]*BlogPost, len(bpcb.builders)) mutators := make([]Mutator, len(bpcb.builders)) diff --git a/entproto/internal/entprototest/ent/blogpost_delete.go b/entproto/internal/entprototest/ent/blogpost_delete.go index 4766e3300..b0db08a69 100644 --- a/entproto/internal/entprototest/ent/blogpost_delete.go +++ b/entproto/internal/entprototest/ent/blogpost_delete.go @@ -27,7 +27,7 @@ func (bpd *BlogPostDelete) Where(ps ...predicate.BlogPost) *BlogPostDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (bpd *BlogPostDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, BlogPostMutation](ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) + return withHooks(ctx, bpd.sqlExec, bpd.mutation, bpd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/blogpost_update.go b/entproto/internal/entprototest/ent/blogpost_update.go index 0567dbd9f..47922d683 100644 --- a/entproto/internal/entprototest/ent/blogpost_update.go +++ b/entproto/internal/entprototest/ent/blogpost_update.go @@ -35,12 +35,28 @@ func (bpu *BlogPostUpdate) SetTitle(s string) *BlogPostUpdate { return bpu } +// SetNillableTitle sets the "title" field if the given value is not nil. +func (bpu *BlogPostUpdate) SetNillableTitle(s *string) *BlogPostUpdate { + if s != nil { + bpu.SetTitle(*s) + } + return bpu +} + // SetBody sets the "body" field. func (bpu *BlogPostUpdate) SetBody(s string) *BlogPostUpdate { bpu.mutation.SetBody(s) return bpu } +// SetNillableBody sets the "body" field if the given value is not nil. +func (bpu *BlogPostUpdate) SetNillableBody(s *string) *BlogPostUpdate { + if s != nil { + bpu.SetBody(*s) + } + return bpu +} + // SetExternalID sets the "external_id" field. func (bpu *BlogPostUpdate) SetExternalID(i int) *BlogPostUpdate { bpu.mutation.ResetExternalID() @@ -48,6 +64,14 @@ func (bpu *BlogPostUpdate) SetExternalID(i int) *BlogPostUpdate { return bpu } +// SetNillableExternalID sets the "external_id" field if the given value is not nil. +func (bpu *BlogPostUpdate) SetNillableExternalID(i *int) *BlogPostUpdate { + if i != nil { + bpu.SetExternalID(*i) + } + return bpu +} + // AddExternalID adds i to the "external_id" field. func (bpu *BlogPostUpdate) AddExternalID(i int) *BlogPostUpdate { bpu.mutation.AddExternalID(i) @@ -122,7 +146,7 @@ func (bpu *BlogPostUpdate) RemoveCategories(c ...*Category) *BlogPostUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (bpu *BlogPostUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, BlogPostMutation](ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) + return withHooks(ctx, bpu.sqlSave, bpu.mutation, bpu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -268,12 +292,28 @@ func (bpuo *BlogPostUpdateOne) SetTitle(s string) *BlogPostUpdateOne { return bpuo } +// SetNillableTitle sets the "title" field if the given value is not nil. +func (bpuo *BlogPostUpdateOne) SetNillableTitle(s *string) *BlogPostUpdateOne { + if s != nil { + bpuo.SetTitle(*s) + } + return bpuo +} + // SetBody sets the "body" field. func (bpuo *BlogPostUpdateOne) SetBody(s string) *BlogPostUpdateOne { bpuo.mutation.SetBody(s) return bpuo } +// SetNillableBody sets the "body" field if the given value is not nil. +func (bpuo *BlogPostUpdateOne) SetNillableBody(s *string) *BlogPostUpdateOne { + if s != nil { + bpuo.SetBody(*s) + } + return bpuo +} + // SetExternalID sets the "external_id" field. func (bpuo *BlogPostUpdateOne) SetExternalID(i int) *BlogPostUpdateOne { bpuo.mutation.ResetExternalID() @@ -281,6 +321,14 @@ func (bpuo *BlogPostUpdateOne) SetExternalID(i int) *BlogPostUpdateOne { return bpuo } +// SetNillableExternalID sets the "external_id" field if the given value is not nil. +func (bpuo *BlogPostUpdateOne) SetNillableExternalID(i *int) *BlogPostUpdateOne { + if i != nil { + bpuo.SetExternalID(*i) + } + return bpuo +} + // AddExternalID adds i to the "external_id" field. func (bpuo *BlogPostUpdateOne) AddExternalID(i int) *BlogPostUpdateOne { bpuo.mutation.AddExternalID(i) @@ -368,7 +416,7 @@ func (bpuo *BlogPostUpdateOne) Select(field string, fields ...string) *BlogPostU // Save executes the query and returns the updated BlogPost entity. func (bpuo *BlogPostUpdateOne) Save(ctx context.Context) (*BlogPost, error) { - return withHooks[*BlogPost, BlogPostMutation](ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) + return withHooks(ctx, bpuo.sqlSave, bpuo.mutation, bpuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/category/where.go b/entproto/internal/entprototest/ent/category/where.go index 8c0a7a021..85bfd2831 100644 --- a/entproto/internal/entprototest/ent/category/where.go +++ b/entproto/internal/entprototest/ent/category/where.go @@ -218,32 +218,15 @@ func HasBlogPostsWith(preds ...predicate.BlogPost) predicate.Category { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Category(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Category) predicate.Category { - return predicate.Category(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Category(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/category_create.go b/entproto/internal/entprototest/ent/category_create.go index 9cf6978a5..8db0e51b7 100644 --- a/entproto/internal/entprototest/ent/category_create.go +++ b/entproto/internal/entprototest/ent/category_create.go @@ -54,7 +54,7 @@ func (cc *CategoryCreate) Mutation() *CategoryMutation { // Save creates the Category in the database. func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cc.sqlSave, cc.mutation, cc.hooks) + return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -143,11 +143,15 @@ func (cc *CategoryCreate) createSpec() (*Category, *sqlgraph.CreateSpec) { // CategoryCreateBulk is the builder for creating many Category entities in bulk. type CategoryCreateBulk struct { config + err error builders []*CategoryCreate } // Save creates the Category entities in the database. func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error) { + if ccb.err != nil { + return nil, ccb.err + } specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) nodes := make([]*Category, len(ccb.builders)) mutators := make([]Mutator, len(ccb.builders)) diff --git a/entproto/internal/entprototest/ent/category_delete.go b/entproto/internal/entprototest/ent/category_delete.go index 35ad982ac..c00b51679 100644 --- a/entproto/internal/entprototest/ent/category_delete.go +++ b/entproto/internal/entprototest/ent/category_delete.go @@ -27,7 +27,7 @@ func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (cd *CategoryDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cd.sqlExec, cd.mutation, cd.hooks) + return withHooks(ctx, cd.sqlExec, cd.mutation, cd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/category_update.go b/entproto/internal/entprototest/ent/category_update.go index 742b7e10a..9657a0f77 100644 --- a/entproto/internal/entprototest/ent/category_update.go +++ b/entproto/internal/entprototest/ent/category_update.go @@ -34,12 +34,28 @@ func (cu *CategoryUpdate) SetName(s string) *CategoryUpdate { return cu } +// SetNillableName sets the "name" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableName(s *string) *CategoryUpdate { + if s != nil { + cu.SetName(*s) + } + return cu +} + // SetDescription sets the "description" field. func (cu *CategoryUpdate) SetDescription(s string) *CategoryUpdate { cu.mutation.SetDescription(s) return cu } +// SetNillableDescription sets the "description" field if the given value is not nil. +func (cu *CategoryUpdate) SetNillableDescription(s *string) *CategoryUpdate { + if s != nil { + cu.SetDescription(*s) + } + return cu +} + // AddBlogPostIDs adds the "blog_posts" edge to the BlogPost entity by IDs. func (cu *CategoryUpdate) AddBlogPostIDs(ids ...int) *CategoryUpdate { cu.mutation.AddBlogPostIDs(ids...) @@ -83,7 +99,7 @@ func (cu *CategoryUpdate) RemoveBlogPosts(b ...*BlogPost) *CategoryUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CategoryUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, CategoryMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks) + return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -194,12 +210,28 @@ func (cuo *CategoryUpdateOne) SetName(s string) *CategoryUpdateOne { return cuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableName(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetName(*s) + } + return cuo +} + // SetDescription sets the "description" field. func (cuo *CategoryUpdateOne) SetDescription(s string) *CategoryUpdateOne { cuo.mutation.SetDescription(s) return cuo } +// SetNillableDescription sets the "description" field if the given value is not nil. +func (cuo *CategoryUpdateOne) SetNillableDescription(s *string) *CategoryUpdateOne { + if s != nil { + cuo.SetDescription(*s) + } + return cuo +} + // AddBlogPostIDs adds the "blog_posts" edge to the BlogPost entity by IDs. func (cuo *CategoryUpdateOne) AddBlogPostIDs(ids ...int) *CategoryUpdateOne { cuo.mutation.AddBlogPostIDs(ids...) @@ -256,7 +288,7 @@ func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUp // Save executes the query and returns the updated Category entity. func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error) { - return withHooks[*Category, CategoryMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) + return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/client.go b/entproto/internal/entprototest/ent/client.go index e6dbe8dab..61b24d983 100644 --- a/entproto/internal/entprototest/ent/client.go +++ b/entproto/internal/entprototest/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entproto/internal/entprototest/ent/migrate" "entgo.io/ent" @@ -17,6 +18,7 @@ import ( "entgo.io/contrib/entproto/internal/entprototest/ent/category" "entgo.io/contrib/entproto/internal/entprototest/ent/dependsonskipped" "entgo.io/contrib/entproto/internal/entprototest/ent/duplicatenumbermessage" + "entgo.io/contrib/entproto/internal/entprototest/ent/enumwithconflictingvalue" "entgo.io/contrib/entproto/internal/entprototest/ent/explicitskippedmessage" "entgo.io/contrib/entproto/internal/entprototest/ent/image" "entgo.io/contrib/entproto/internal/entprototest/ent/implicitskippedmessage" @@ -24,6 +26,7 @@ import ( "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithenum" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithfieldone" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithid" + "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithints" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithoptionals" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithpackagename" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithstrings" @@ -54,6 +57,8 @@ type Client struct { DependsOnSkipped *DependsOnSkippedClient // DuplicateNumberMessage is the client for interacting with the DuplicateNumberMessage builders. DuplicateNumberMessage *DuplicateNumberMessageClient + // EnumWithConflictingValue is the client for interacting with the EnumWithConflictingValue builders. + EnumWithConflictingValue *EnumWithConflictingValueClient // ExplicitSkippedMessage is the client for interacting with the ExplicitSkippedMessage builders. ExplicitSkippedMessage *ExplicitSkippedMessageClient // Image is the client for interacting with the Image builders. @@ -68,6 +73,8 @@ type Client struct { MessageWithFieldOne *MessageWithFieldOneClient // MessageWithID is the client for interacting with the MessageWithID builders. MessageWithID *MessageWithIDClient + // MessageWithInts is the client for interacting with the MessageWithInts builders. + MessageWithInts *MessageWithIntsClient // MessageWithOptionals is the client for interacting with the MessageWithOptionals builders. MessageWithOptionals *MessageWithOptionalsClient // MessageWithPackageName is the client for interacting with the MessageWithPackageName builders. @@ -92,9 +99,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -106,6 +111,7 @@ func (c *Client) init() { c.Category = NewCategoryClient(c.config) c.DependsOnSkipped = NewDependsOnSkippedClient(c.config) c.DuplicateNumberMessage = NewDuplicateNumberMessageClient(c.config) + c.EnumWithConflictingValue = NewEnumWithConflictingValueClient(c.config) c.ExplicitSkippedMessage = NewExplicitSkippedMessageClient(c.config) c.Image = NewImageClient(c.config) c.ImplicitSkippedMessage = NewImplicitSkippedMessageClient(c.config) @@ -113,6 +119,7 @@ func (c *Client) init() { c.MessageWithEnum = NewMessageWithEnumClient(c.config) c.MessageWithFieldOne = NewMessageWithFieldOneClient(c.config) c.MessageWithID = NewMessageWithIDClient(c.config) + c.MessageWithInts = NewMessageWithIntsClient(c.config) c.MessageWithOptionals = NewMessageWithOptionalsClient(c.config) c.MessageWithPackageName = NewMessageWithPackageNameClient(c.config) c.MessageWithStrings = NewMessageWithStringsClient(c.config) @@ -143,6 +150,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -190,11 +204,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -203,30 +220,32 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { cfg := c.config cfg.driver = tx return &Tx{ - ctx: ctx, - config: cfg, - AllMethodsService: NewAllMethodsServiceClient(cfg), - BlogPost: NewBlogPostClient(cfg), - Category: NewCategoryClient(cfg), - DependsOnSkipped: NewDependsOnSkippedClient(cfg), - DuplicateNumberMessage: NewDuplicateNumberMessageClient(cfg), - ExplicitSkippedMessage: NewExplicitSkippedMessageClient(cfg), - Image: NewImageClient(cfg), - ImplicitSkippedMessage: NewImplicitSkippedMessageClient(cfg), - InvalidFieldMessage: NewInvalidFieldMessageClient(cfg), - MessageWithEnum: NewMessageWithEnumClient(cfg), - MessageWithFieldOne: NewMessageWithFieldOneClient(cfg), - MessageWithID: NewMessageWithIDClient(cfg), - MessageWithOptionals: NewMessageWithOptionalsClient(cfg), - MessageWithPackageName: NewMessageWithPackageNameClient(cfg), - MessageWithStrings: NewMessageWithStringsClient(cfg), - NoBackref: NewNoBackrefClient(cfg), - OneMethodService: NewOneMethodServiceClient(cfg), - Portal: NewPortalClient(cfg), - SkipEdgeExample: NewSkipEdgeExampleClient(cfg), - TwoMethodService: NewTwoMethodServiceClient(cfg), - User: NewUserClient(cfg), - ValidMessage: NewValidMessageClient(cfg), + ctx: ctx, + config: cfg, + AllMethodsService: NewAllMethodsServiceClient(cfg), + BlogPost: NewBlogPostClient(cfg), + Category: NewCategoryClient(cfg), + DependsOnSkipped: NewDependsOnSkippedClient(cfg), + DuplicateNumberMessage: NewDuplicateNumberMessageClient(cfg), + EnumWithConflictingValue: NewEnumWithConflictingValueClient(cfg), + ExplicitSkippedMessage: NewExplicitSkippedMessageClient(cfg), + Image: NewImageClient(cfg), + ImplicitSkippedMessage: NewImplicitSkippedMessageClient(cfg), + InvalidFieldMessage: NewInvalidFieldMessageClient(cfg), + MessageWithEnum: NewMessageWithEnumClient(cfg), + MessageWithFieldOne: NewMessageWithFieldOneClient(cfg), + MessageWithID: NewMessageWithIDClient(cfg), + MessageWithInts: NewMessageWithIntsClient(cfg), + MessageWithOptionals: NewMessageWithOptionalsClient(cfg), + MessageWithPackageName: NewMessageWithPackageNameClient(cfg), + MessageWithStrings: NewMessageWithStringsClient(cfg), + NoBackref: NewNoBackrefClient(cfg), + OneMethodService: NewOneMethodServiceClient(cfg), + Portal: NewPortalClient(cfg), + SkipEdgeExample: NewSkipEdgeExampleClient(cfg), + TwoMethodService: NewTwoMethodServiceClient(cfg), + User: NewUserClient(cfg), + ValidMessage: NewValidMessageClient(cfg), }, nil } @@ -244,30 +263,32 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) cfg := c.config cfg.driver = &txDriver{tx: tx, drv: c.driver} return &Tx{ - ctx: ctx, - config: cfg, - AllMethodsService: NewAllMethodsServiceClient(cfg), - BlogPost: NewBlogPostClient(cfg), - Category: NewCategoryClient(cfg), - DependsOnSkipped: NewDependsOnSkippedClient(cfg), - DuplicateNumberMessage: NewDuplicateNumberMessageClient(cfg), - ExplicitSkippedMessage: NewExplicitSkippedMessageClient(cfg), - Image: NewImageClient(cfg), - ImplicitSkippedMessage: NewImplicitSkippedMessageClient(cfg), - InvalidFieldMessage: NewInvalidFieldMessageClient(cfg), - MessageWithEnum: NewMessageWithEnumClient(cfg), - MessageWithFieldOne: NewMessageWithFieldOneClient(cfg), - MessageWithID: NewMessageWithIDClient(cfg), - MessageWithOptionals: NewMessageWithOptionalsClient(cfg), - MessageWithPackageName: NewMessageWithPackageNameClient(cfg), - MessageWithStrings: NewMessageWithStringsClient(cfg), - NoBackref: NewNoBackrefClient(cfg), - OneMethodService: NewOneMethodServiceClient(cfg), - Portal: NewPortalClient(cfg), - SkipEdgeExample: NewSkipEdgeExampleClient(cfg), - TwoMethodService: NewTwoMethodServiceClient(cfg), - User: NewUserClient(cfg), - ValidMessage: NewValidMessageClient(cfg), + ctx: ctx, + config: cfg, + AllMethodsService: NewAllMethodsServiceClient(cfg), + BlogPost: NewBlogPostClient(cfg), + Category: NewCategoryClient(cfg), + DependsOnSkipped: NewDependsOnSkippedClient(cfg), + DuplicateNumberMessage: NewDuplicateNumberMessageClient(cfg), + EnumWithConflictingValue: NewEnumWithConflictingValueClient(cfg), + ExplicitSkippedMessage: NewExplicitSkippedMessageClient(cfg), + Image: NewImageClient(cfg), + ImplicitSkippedMessage: NewImplicitSkippedMessageClient(cfg), + InvalidFieldMessage: NewInvalidFieldMessageClient(cfg), + MessageWithEnum: NewMessageWithEnumClient(cfg), + MessageWithFieldOne: NewMessageWithFieldOneClient(cfg), + MessageWithID: NewMessageWithIDClient(cfg), + MessageWithInts: NewMessageWithIntsClient(cfg), + MessageWithOptionals: NewMessageWithOptionalsClient(cfg), + MessageWithPackageName: NewMessageWithPackageNameClient(cfg), + MessageWithStrings: NewMessageWithStringsClient(cfg), + NoBackref: NewNoBackrefClient(cfg), + OneMethodService: NewOneMethodServiceClient(cfg), + Portal: NewPortalClient(cfg), + SkipEdgeExample: NewSkipEdgeExampleClient(cfg), + TwoMethodService: NewTwoMethodServiceClient(cfg), + User: NewUserClient(cfg), + ValidMessage: NewValidMessageClient(cfg), }, nil } @@ -298,12 +319,12 @@ func (c *Client) Close() error { func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.AllMethodsService, c.BlogPost, c.Category, c.DependsOnSkipped, - c.DuplicateNumberMessage, c.ExplicitSkippedMessage, c.Image, - c.ImplicitSkippedMessage, c.InvalidFieldMessage, c.MessageWithEnum, - c.MessageWithFieldOne, c.MessageWithID, c.MessageWithOptionals, - c.MessageWithPackageName, c.MessageWithStrings, c.NoBackref, - c.OneMethodService, c.Portal, c.SkipEdgeExample, c.TwoMethodService, c.User, - c.ValidMessage, + c.DuplicateNumberMessage, c.EnumWithConflictingValue, c.ExplicitSkippedMessage, + c.Image, c.ImplicitSkippedMessage, c.InvalidFieldMessage, c.MessageWithEnum, + c.MessageWithFieldOne, c.MessageWithID, c.MessageWithInts, + c.MessageWithOptionals, c.MessageWithPackageName, c.MessageWithStrings, + c.NoBackref, c.OneMethodService, c.Portal, c.SkipEdgeExample, + c.TwoMethodService, c.User, c.ValidMessage, } { n.Use(hooks...) } @@ -314,12 +335,12 @@ func (c *Client) Use(hooks ...Hook) { func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.AllMethodsService, c.BlogPost, c.Category, c.DependsOnSkipped, - c.DuplicateNumberMessage, c.ExplicitSkippedMessage, c.Image, - c.ImplicitSkippedMessage, c.InvalidFieldMessage, c.MessageWithEnum, - c.MessageWithFieldOne, c.MessageWithID, c.MessageWithOptionals, - c.MessageWithPackageName, c.MessageWithStrings, c.NoBackref, - c.OneMethodService, c.Portal, c.SkipEdgeExample, c.TwoMethodService, c.User, - c.ValidMessage, + c.DuplicateNumberMessage, c.EnumWithConflictingValue, c.ExplicitSkippedMessage, + c.Image, c.ImplicitSkippedMessage, c.InvalidFieldMessage, c.MessageWithEnum, + c.MessageWithFieldOne, c.MessageWithID, c.MessageWithInts, + c.MessageWithOptionals, c.MessageWithPackageName, c.MessageWithStrings, + c.NoBackref, c.OneMethodService, c.Portal, c.SkipEdgeExample, + c.TwoMethodService, c.User, c.ValidMessage, } { n.Intercept(interceptors...) } @@ -338,6 +359,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.DependsOnSkipped.mutate(ctx, m) case *DuplicateNumberMessageMutation: return c.DuplicateNumberMessage.mutate(ctx, m) + case *EnumWithConflictingValueMutation: + return c.EnumWithConflictingValue.mutate(ctx, m) case *ExplicitSkippedMessageMutation: return c.ExplicitSkippedMessage.mutate(ctx, m) case *ImageMutation: @@ -352,6 +375,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.MessageWithFieldOne.mutate(ctx, m) case *MessageWithIDMutation: return c.MessageWithID.mutate(ctx, m) + case *MessageWithIntsMutation: + return c.MessageWithInts.mutate(ctx, m) case *MessageWithOptionalsMutation: return c.MessageWithOptionals.mutate(ctx, m) case *MessageWithPackageNameMutation: @@ -410,6 +435,21 @@ func (c *AllMethodsServiceClient) CreateBulk(builders ...*AllMethodsServiceCreat return &AllMethodsServiceCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AllMethodsServiceClient) MapCreateBulk(slice any, setFunc func(*AllMethodsServiceCreate, int)) *AllMethodsServiceCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AllMethodsServiceCreateBulk{err: fmt.Errorf("calling to AllMethodsServiceClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AllMethodsServiceCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AllMethodsServiceCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for AllMethodsService. func (c *AllMethodsServiceClient) Update() *AllMethodsServiceUpdate { mutation := newAllMethodsServiceMutation(c.config, OpUpdate) @@ -528,6 +568,21 @@ func (c *BlogPostClient) CreateBulk(builders ...*BlogPostCreate) *BlogPostCreate return &BlogPostCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BlogPostClient) MapCreateBulk(slice any, setFunc func(*BlogPostCreate, int)) *BlogPostCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BlogPostCreateBulk{err: fmt.Errorf("calling to BlogPostClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BlogPostCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BlogPostCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for BlogPost. func (c *BlogPostClient) Update() *BlogPostUpdate { mutation := newBlogPostMutation(c.config, OpUpdate) @@ -678,6 +733,21 @@ func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreate return &CategoryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CategoryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CategoryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Category. func (c *CategoryClient) Update() *CategoryUpdate { mutation := newCategoryMutation(c.config, OpUpdate) @@ -812,6 +882,21 @@ func (c *DependsOnSkippedClient) CreateBulk(builders ...*DependsOnSkippedCreate) return &DependsOnSkippedCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *DependsOnSkippedClient) MapCreateBulk(slice any, setFunc func(*DependsOnSkippedCreate, int)) *DependsOnSkippedCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &DependsOnSkippedCreateBulk{err: fmt.Errorf("calling to DependsOnSkippedClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*DependsOnSkippedCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &DependsOnSkippedCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for DependsOnSkipped. func (c *DependsOnSkippedClient) Update() *DependsOnSkippedUpdate { mutation := newDependsOnSkippedMutation(c.config, OpUpdate) @@ -946,6 +1031,21 @@ func (c *DuplicateNumberMessageClient) CreateBulk(builders ...*DuplicateNumberMe return &DuplicateNumberMessageCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *DuplicateNumberMessageClient) MapCreateBulk(slice any, setFunc func(*DuplicateNumberMessageCreate, int)) *DuplicateNumberMessageCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &DuplicateNumberMessageCreateBulk{err: fmt.Errorf("calling to DuplicateNumberMessageClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*DuplicateNumberMessageCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &DuplicateNumberMessageCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for DuplicateNumberMessage. func (c *DuplicateNumberMessageClient) Update() *DuplicateNumberMessageUpdate { mutation := newDuplicateNumberMessageMutation(c.config, OpUpdate) @@ -1031,6 +1131,139 @@ func (c *DuplicateNumberMessageClient) mutate(ctx context.Context, m *DuplicateN } } +// EnumWithConflictingValueClient is a client for the EnumWithConflictingValue schema. +type EnumWithConflictingValueClient struct { + config +} + +// NewEnumWithConflictingValueClient returns a client for the EnumWithConflictingValue from the given config. +func NewEnumWithConflictingValueClient(c config) *EnumWithConflictingValueClient { + return &EnumWithConflictingValueClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `enumwithconflictingvalue.Hooks(f(g(h())))`. +func (c *EnumWithConflictingValueClient) Use(hooks ...Hook) { + c.hooks.EnumWithConflictingValue = append(c.hooks.EnumWithConflictingValue, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `enumwithconflictingvalue.Intercept(f(g(h())))`. +func (c *EnumWithConflictingValueClient) Intercept(interceptors ...Interceptor) { + c.inters.EnumWithConflictingValue = append(c.inters.EnumWithConflictingValue, interceptors...) +} + +// Create returns a builder for creating a EnumWithConflictingValue entity. +func (c *EnumWithConflictingValueClient) Create() *EnumWithConflictingValueCreate { + mutation := newEnumWithConflictingValueMutation(c.config, OpCreate) + return &EnumWithConflictingValueCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EnumWithConflictingValue entities. +func (c *EnumWithConflictingValueClient) CreateBulk(builders ...*EnumWithConflictingValueCreate) *EnumWithConflictingValueCreateBulk { + return &EnumWithConflictingValueCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EnumWithConflictingValueClient) MapCreateBulk(slice any, setFunc func(*EnumWithConflictingValueCreate, int)) *EnumWithConflictingValueCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EnumWithConflictingValueCreateBulk{err: fmt.Errorf("calling to EnumWithConflictingValueClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EnumWithConflictingValueCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EnumWithConflictingValueCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EnumWithConflictingValue. +func (c *EnumWithConflictingValueClient) Update() *EnumWithConflictingValueUpdate { + mutation := newEnumWithConflictingValueMutation(c.config, OpUpdate) + return &EnumWithConflictingValueUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EnumWithConflictingValueClient) UpdateOne(ewcv *EnumWithConflictingValue) *EnumWithConflictingValueUpdateOne { + mutation := newEnumWithConflictingValueMutation(c.config, OpUpdateOne, withEnumWithConflictingValue(ewcv)) + return &EnumWithConflictingValueUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EnumWithConflictingValueClient) UpdateOneID(id int) *EnumWithConflictingValueUpdateOne { + mutation := newEnumWithConflictingValueMutation(c.config, OpUpdateOne, withEnumWithConflictingValueID(id)) + return &EnumWithConflictingValueUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EnumWithConflictingValue. +func (c *EnumWithConflictingValueClient) Delete() *EnumWithConflictingValueDelete { + mutation := newEnumWithConflictingValueMutation(c.config, OpDelete) + return &EnumWithConflictingValueDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EnumWithConflictingValueClient) DeleteOne(ewcv *EnumWithConflictingValue) *EnumWithConflictingValueDeleteOne { + return c.DeleteOneID(ewcv.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EnumWithConflictingValueClient) DeleteOneID(id int) *EnumWithConflictingValueDeleteOne { + builder := c.Delete().Where(enumwithconflictingvalue.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EnumWithConflictingValueDeleteOne{builder} +} + +// Query returns a query builder for EnumWithConflictingValue. +func (c *EnumWithConflictingValueClient) Query() *EnumWithConflictingValueQuery { + return &EnumWithConflictingValueQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEnumWithConflictingValue}, + inters: c.Interceptors(), + } +} + +// Get returns a EnumWithConflictingValue entity by its id. +func (c *EnumWithConflictingValueClient) Get(ctx context.Context, id int) (*EnumWithConflictingValue, error) { + return c.Query().Where(enumwithconflictingvalue.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EnumWithConflictingValueClient) GetX(ctx context.Context, id int) *EnumWithConflictingValue { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *EnumWithConflictingValueClient) Hooks() []Hook { + return c.hooks.EnumWithConflictingValue +} + +// Interceptors returns the client interceptors. +func (c *EnumWithConflictingValueClient) Interceptors() []Interceptor { + return c.inters.EnumWithConflictingValue +} + +func (c *EnumWithConflictingValueClient) mutate(ctx context.Context, m *EnumWithConflictingValueMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EnumWithConflictingValueCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EnumWithConflictingValueUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EnumWithConflictingValueUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EnumWithConflictingValueDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EnumWithConflictingValue mutation op: %q", m.Op()) + } +} + // ExplicitSkippedMessageClient is a client for the ExplicitSkippedMessage schema. type ExplicitSkippedMessageClient struct { config @@ -1064,6 +1297,21 @@ func (c *ExplicitSkippedMessageClient) CreateBulk(builders ...*ExplicitSkippedMe return &ExplicitSkippedMessageCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ExplicitSkippedMessageClient) MapCreateBulk(slice any, setFunc func(*ExplicitSkippedMessageCreate, int)) *ExplicitSkippedMessageCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ExplicitSkippedMessageCreateBulk{err: fmt.Errorf("calling to ExplicitSkippedMessageClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ExplicitSkippedMessageCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ExplicitSkippedMessageCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for ExplicitSkippedMessage. func (c *ExplicitSkippedMessageClient) Update() *ExplicitSkippedMessageUpdate { mutation := newExplicitSkippedMessageMutation(c.config, OpUpdate) @@ -1182,6 +1430,21 @@ func (c *ImageClient) CreateBulk(builders ...*ImageCreate) *ImageCreateBulk { return &ImageCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ImageClient) MapCreateBulk(slice any, setFunc func(*ImageCreate, int)) *ImageCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ImageCreateBulk{err: fmt.Errorf("calling to ImageClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ImageCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ImageCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Image. func (c *ImageClient) Update() *ImageUpdate { mutation := newImageMutation(c.config, OpUpdate) @@ -1316,6 +1579,21 @@ func (c *ImplicitSkippedMessageClient) CreateBulk(builders ...*ImplicitSkippedMe return &ImplicitSkippedMessageCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ImplicitSkippedMessageClient) MapCreateBulk(slice any, setFunc func(*ImplicitSkippedMessageCreate, int)) *ImplicitSkippedMessageCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ImplicitSkippedMessageCreateBulk{err: fmt.Errorf("calling to ImplicitSkippedMessageClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ImplicitSkippedMessageCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ImplicitSkippedMessageCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for ImplicitSkippedMessage. func (c *ImplicitSkippedMessageClient) Update() *ImplicitSkippedMessageUpdate { mutation := newImplicitSkippedMessageMutation(c.config, OpUpdate) @@ -1434,6 +1712,21 @@ func (c *InvalidFieldMessageClient) CreateBulk(builders ...*InvalidFieldMessageC return &InvalidFieldMessageCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *InvalidFieldMessageClient) MapCreateBulk(slice any, setFunc func(*InvalidFieldMessageCreate, int)) *InvalidFieldMessageCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &InvalidFieldMessageCreateBulk{err: fmt.Errorf("calling to InvalidFieldMessageClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*InvalidFieldMessageCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &InvalidFieldMessageCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for InvalidFieldMessage. func (c *InvalidFieldMessageClient) Update() *InvalidFieldMessageUpdate { mutation := newInvalidFieldMessageMutation(c.config, OpUpdate) @@ -1552,6 +1845,21 @@ func (c *MessageWithEnumClient) CreateBulk(builders ...*MessageWithEnumCreate) * return &MessageWithEnumCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageWithEnumClient) MapCreateBulk(slice any, setFunc func(*MessageWithEnumCreate, int)) *MessageWithEnumCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageWithEnumCreateBulk{err: fmt.Errorf("calling to MessageWithEnumClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageWithEnumCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageWithEnumCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MessageWithEnum. func (c *MessageWithEnumClient) Update() *MessageWithEnumUpdate { mutation := newMessageWithEnumMutation(c.config, OpUpdate) @@ -1670,6 +1978,21 @@ func (c *MessageWithFieldOneClient) CreateBulk(builders ...*MessageWithFieldOneC return &MessageWithFieldOneCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageWithFieldOneClient) MapCreateBulk(slice any, setFunc func(*MessageWithFieldOneCreate, int)) *MessageWithFieldOneCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageWithFieldOneCreateBulk{err: fmt.Errorf("calling to MessageWithFieldOneClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageWithFieldOneCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageWithFieldOneCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MessageWithFieldOne. func (c *MessageWithFieldOneClient) Update() *MessageWithFieldOneUpdate { mutation := newMessageWithFieldOneMutation(c.config, OpUpdate) @@ -1788,6 +2111,21 @@ func (c *MessageWithIDClient) CreateBulk(builders ...*MessageWithIDCreate) *Mess return &MessageWithIDCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageWithIDClient) MapCreateBulk(slice any, setFunc func(*MessageWithIDCreate, int)) *MessageWithIDCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageWithIDCreateBulk{err: fmt.Errorf("calling to MessageWithIDClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageWithIDCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageWithIDCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MessageWithID. func (c *MessageWithIDClient) Update() *MessageWithIDUpdate { mutation := newMessageWithIDMutation(c.config, OpUpdate) @@ -1873,6 +2211,139 @@ func (c *MessageWithIDClient) mutate(ctx context.Context, m *MessageWithIDMutati } } +// MessageWithIntsClient is a client for the MessageWithInts schema. +type MessageWithIntsClient struct { + config +} + +// NewMessageWithIntsClient returns a client for the MessageWithInts from the given config. +func NewMessageWithIntsClient(c config) *MessageWithIntsClient { + return &MessageWithIntsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `messagewithints.Hooks(f(g(h())))`. +func (c *MessageWithIntsClient) Use(hooks ...Hook) { + c.hooks.MessageWithInts = append(c.hooks.MessageWithInts, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `messagewithints.Intercept(f(g(h())))`. +func (c *MessageWithIntsClient) Intercept(interceptors ...Interceptor) { + c.inters.MessageWithInts = append(c.inters.MessageWithInts, interceptors...) +} + +// Create returns a builder for creating a MessageWithInts entity. +func (c *MessageWithIntsClient) Create() *MessageWithIntsCreate { + mutation := newMessageWithIntsMutation(c.config, OpCreate) + return &MessageWithIntsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of MessageWithInts entities. +func (c *MessageWithIntsClient) CreateBulk(builders ...*MessageWithIntsCreate) *MessageWithIntsCreateBulk { + return &MessageWithIntsCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageWithIntsClient) MapCreateBulk(slice any, setFunc func(*MessageWithIntsCreate, int)) *MessageWithIntsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageWithIntsCreateBulk{err: fmt.Errorf("calling to MessageWithIntsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageWithIntsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageWithIntsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for MessageWithInts. +func (c *MessageWithIntsClient) Update() *MessageWithIntsUpdate { + mutation := newMessageWithIntsMutation(c.config, OpUpdate) + return &MessageWithIntsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *MessageWithIntsClient) UpdateOne(mwi *MessageWithInts) *MessageWithIntsUpdateOne { + mutation := newMessageWithIntsMutation(c.config, OpUpdateOne, withMessageWithInts(mwi)) + return &MessageWithIntsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *MessageWithIntsClient) UpdateOneID(id int) *MessageWithIntsUpdateOne { + mutation := newMessageWithIntsMutation(c.config, OpUpdateOne, withMessageWithIntsID(id)) + return &MessageWithIntsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for MessageWithInts. +func (c *MessageWithIntsClient) Delete() *MessageWithIntsDelete { + mutation := newMessageWithIntsMutation(c.config, OpDelete) + return &MessageWithIntsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *MessageWithIntsClient) DeleteOne(mwi *MessageWithInts) *MessageWithIntsDeleteOne { + return c.DeleteOneID(mwi.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *MessageWithIntsClient) DeleteOneID(id int) *MessageWithIntsDeleteOne { + builder := c.Delete().Where(messagewithints.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &MessageWithIntsDeleteOne{builder} +} + +// Query returns a query builder for MessageWithInts. +func (c *MessageWithIntsClient) Query() *MessageWithIntsQuery { + return &MessageWithIntsQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeMessageWithInts}, + inters: c.Interceptors(), + } +} + +// Get returns a MessageWithInts entity by its id. +func (c *MessageWithIntsClient) Get(ctx context.Context, id int) (*MessageWithInts, error) { + return c.Query().Where(messagewithints.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *MessageWithIntsClient) GetX(ctx context.Context, id int) *MessageWithInts { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *MessageWithIntsClient) Hooks() []Hook { + return c.hooks.MessageWithInts +} + +// Interceptors returns the client interceptors. +func (c *MessageWithIntsClient) Interceptors() []Interceptor { + return c.inters.MessageWithInts +} + +func (c *MessageWithIntsClient) mutate(ctx context.Context, m *MessageWithIntsMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&MessageWithIntsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&MessageWithIntsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&MessageWithIntsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&MessageWithIntsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown MessageWithInts mutation op: %q", m.Op()) + } +} + // MessageWithOptionalsClient is a client for the MessageWithOptionals schema. type MessageWithOptionalsClient struct { config @@ -1906,6 +2377,21 @@ func (c *MessageWithOptionalsClient) CreateBulk(builders ...*MessageWithOptional return &MessageWithOptionalsCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageWithOptionalsClient) MapCreateBulk(slice any, setFunc func(*MessageWithOptionalsCreate, int)) *MessageWithOptionalsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageWithOptionalsCreateBulk{err: fmt.Errorf("calling to MessageWithOptionalsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageWithOptionalsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageWithOptionalsCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MessageWithOptionals. func (c *MessageWithOptionalsClient) Update() *MessageWithOptionalsUpdate { mutation := newMessageWithOptionalsMutation(c.config, OpUpdate) @@ -2024,6 +2510,21 @@ func (c *MessageWithPackageNameClient) CreateBulk(builders ...*MessageWithPackag return &MessageWithPackageNameCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageWithPackageNameClient) MapCreateBulk(slice any, setFunc func(*MessageWithPackageNameCreate, int)) *MessageWithPackageNameCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageWithPackageNameCreateBulk{err: fmt.Errorf("calling to MessageWithPackageNameClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageWithPackageNameCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageWithPackageNameCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MessageWithPackageName. func (c *MessageWithPackageNameClient) Update() *MessageWithPackageNameUpdate { mutation := newMessageWithPackageNameMutation(c.config, OpUpdate) @@ -2142,6 +2643,21 @@ func (c *MessageWithStringsClient) CreateBulk(builders ...*MessageWithStringsCre return &MessageWithStringsCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageWithStringsClient) MapCreateBulk(slice any, setFunc func(*MessageWithStringsCreate, int)) *MessageWithStringsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageWithStringsCreateBulk{err: fmt.Errorf("calling to MessageWithStringsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageWithStringsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageWithStringsCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MessageWithStrings. func (c *MessageWithStringsClient) Update() *MessageWithStringsUpdate { mutation := newMessageWithStringsMutation(c.config, OpUpdate) @@ -2260,6 +2776,21 @@ func (c *NoBackrefClient) CreateBulk(builders ...*NoBackrefCreate) *NoBackrefCre return &NoBackrefCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *NoBackrefClient) MapCreateBulk(slice any, setFunc func(*NoBackrefCreate, int)) *NoBackrefCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &NoBackrefCreateBulk{err: fmt.Errorf("calling to NoBackrefClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*NoBackrefCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &NoBackrefCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for NoBackref. func (c *NoBackrefClient) Update() *NoBackrefUpdate { mutation := newNoBackrefMutation(c.config, OpUpdate) @@ -2394,6 +2925,21 @@ func (c *OneMethodServiceClient) CreateBulk(builders ...*OneMethodServiceCreate) return &OneMethodServiceCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *OneMethodServiceClient) MapCreateBulk(slice any, setFunc func(*OneMethodServiceCreate, int)) *OneMethodServiceCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &OneMethodServiceCreateBulk{err: fmt.Errorf("calling to OneMethodServiceClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*OneMethodServiceCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &OneMethodServiceCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for OneMethodService. func (c *OneMethodServiceClient) Update() *OneMethodServiceUpdate { mutation := newOneMethodServiceMutation(c.config, OpUpdate) @@ -2512,6 +3058,21 @@ func (c *PortalClient) CreateBulk(builders ...*PortalCreate) *PortalCreateBulk { return &PortalCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PortalClient) MapCreateBulk(slice any, setFunc func(*PortalCreate, int)) *PortalCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PortalCreateBulk{err: fmt.Errorf("calling to PortalClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PortalCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PortalCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Portal. func (c *PortalClient) Update() *PortalUpdate { mutation := newPortalMutation(c.config, OpUpdate) @@ -2646,6 +3207,21 @@ func (c *SkipEdgeExampleClient) CreateBulk(builders ...*SkipEdgeExampleCreate) * return &SkipEdgeExampleCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *SkipEdgeExampleClient) MapCreateBulk(slice any, setFunc func(*SkipEdgeExampleCreate, int)) *SkipEdgeExampleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &SkipEdgeExampleCreateBulk{err: fmt.Errorf("calling to SkipEdgeExampleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*SkipEdgeExampleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &SkipEdgeExampleCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for SkipEdgeExample. func (c *SkipEdgeExampleClient) Update() *SkipEdgeExampleUpdate { mutation := newSkipEdgeExampleMutation(c.config, OpUpdate) @@ -2780,6 +3356,21 @@ func (c *TwoMethodServiceClient) CreateBulk(builders ...*TwoMethodServiceCreate) return &TwoMethodServiceCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TwoMethodServiceClient) MapCreateBulk(slice any, setFunc func(*TwoMethodServiceCreate, int)) *TwoMethodServiceCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TwoMethodServiceCreateBulk{err: fmt.Errorf("calling to TwoMethodServiceClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TwoMethodServiceCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TwoMethodServiceCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for TwoMethodService. func (c *TwoMethodServiceClient) Update() *TwoMethodServiceUpdate { mutation := newTwoMethodServiceMutation(c.config, OpUpdate) @@ -2898,6 +3489,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) @@ -3064,6 +3670,21 @@ func (c *ValidMessageClient) CreateBulk(builders ...*ValidMessageCreate) *ValidM return &ValidMessageCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ValidMessageClient) MapCreateBulk(slice any, setFunc func(*ValidMessageCreate, int)) *ValidMessageCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ValidMessageCreateBulk{err: fmt.Errorf("calling to ValidMessageClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ValidMessageCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ValidMessageCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for ValidMessage. func (c *ValidMessageClient) Update() *ValidMessageUpdate { mutation := newValidMessageMutation(c.config, OpUpdate) @@ -3153,15 +3774,17 @@ func (c *ValidMessageClient) mutate(ctx context.Context, m *ValidMessageMutation type ( hooks struct { AllMethodsService, BlogPost, Category, DependsOnSkipped, DuplicateNumberMessage, - ExplicitSkippedMessage, Image, ImplicitSkippedMessage, InvalidFieldMessage, - MessageWithEnum, MessageWithFieldOne, MessageWithID, MessageWithOptionals, + EnumWithConflictingValue, ExplicitSkippedMessage, Image, + ImplicitSkippedMessage, InvalidFieldMessage, MessageWithEnum, + MessageWithFieldOne, MessageWithID, MessageWithInts, MessageWithOptionals, MessageWithPackageName, MessageWithStrings, NoBackref, OneMethodService, Portal, SkipEdgeExample, TwoMethodService, User, ValidMessage []ent.Hook } inters struct { AllMethodsService, BlogPost, Category, DependsOnSkipped, DuplicateNumberMessage, - ExplicitSkippedMessage, Image, ImplicitSkippedMessage, InvalidFieldMessage, - MessageWithEnum, MessageWithFieldOne, MessageWithID, MessageWithOptionals, + EnumWithConflictingValue, ExplicitSkippedMessage, Image, + ImplicitSkippedMessage, InvalidFieldMessage, MessageWithEnum, + MessageWithFieldOne, MessageWithID, MessageWithInts, MessageWithOptionals, MessageWithPackageName, MessageWithStrings, NoBackref, OneMethodService, Portal, SkipEdgeExample, TwoMethodService, User, ValidMessage []ent.Interceptor } diff --git a/entproto/internal/entprototest/ent/dependsonskipped/where.go b/entproto/internal/entprototest/ent/dependsonskipped/where.go index 8ea1613cf..34c0721a4 100644 --- a/entproto/internal/entprototest/ent/dependsonskipped/where.go +++ b/entproto/internal/entprototest/ent/dependsonskipped/where.go @@ -148,32 +148,15 @@ func HasSkippedWith(preds ...predicate.ImplicitSkippedMessage) predicate.Depends // And groups predicates with the AND operator between them. func And(predicates ...predicate.DependsOnSkipped) predicate.DependsOnSkipped { - return predicate.DependsOnSkipped(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.DependsOnSkipped(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.DependsOnSkipped) predicate.DependsOnSkipped { - return predicate.DependsOnSkipped(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.DependsOnSkipped(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.DependsOnSkipped) predicate.DependsOnSkipped { - return predicate.DependsOnSkipped(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.DependsOnSkipped(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/dependsonskipped_create.go b/entproto/internal/entprototest/ent/dependsonskipped_create.go index 33a1a6643..54f3cb290 100644 --- a/entproto/internal/entprototest/ent/dependsonskipped_create.go +++ b/entproto/internal/entprototest/ent/dependsonskipped_create.go @@ -48,7 +48,7 @@ func (dosc *DependsOnSkippedCreate) Mutation() *DependsOnSkippedMutation { // Save creates the DependsOnSkipped in the database. func (dosc *DependsOnSkippedCreate) Save(ctx context.Context) (*DependsOnSkipped, error) { - return withHooks[*DependsOnSkipped, DependsOnSkippedMutation](ctx, dosc.sqlSave, dosc.mutation, dosc.hooks) + return withHooks(ctx, dosc.sqlSave, dosc.mutation, dosc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -130,11 +130,15 @@ func (dosc *DependsOnSkippedCreate) createSpec() (*DependsOnSkipped, *sqlgraph.C // DependsOnSkippedCreateBulk is the builder for creating many DependsOnSkipped entities in bulk. type DependsOnSkippedCreateBulk struct { config + err error builders []*DependsOnSkippedCreate } // Save creates the DependsOnSkipped entities in the database. func (doscb *DependsOnSkippedCreateBulk) Save(ctx context.Context) ([]*DependsOnSkipped, error) { + if doscb.err != nil { + return nil, doscb.err + } specs := make([]*sqlgraph.CreateSpec, len(doscb.builders)) nodes := make([]*DependsOnSkipped, len(doscb.builders)) mutators := make([]Mutator, len(doscb.builders)) diff --git a/entproto/internal/entprototest/ent/dependsonskipped_delete.go b/entproto/internal/entprototest/ent/dependsonskipped_delete.go index bdc611961..e9be096df 100644 --- a/entproto/internal/entprototest/ent/dependsonskipped_delete.go +++ b/entproto/internal/entprototest/ent/dependsonskipped_delete.go @@ -27,7 +27,7 @@ func (dosd *DependsOnSkippedDelete) Where(ps ...predicate.DependsOnSkipped) *Dep // Exec executes the deletion query and returns how many vertices were deleted. func (dosd *DependsOnSkippedDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, DependsOnSkippedMutation](ctx, dosd.sqlExec, dosd.mutation, dosd.hooks) + return withHooks(ctx, dosd.sqlExec, dosd.mutation, dosd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/dependsonskipped_update.go b/entproto/internal/entprototest/ent/dependsonskipped_update.go index 0722b9a4f..b9d6fc071 100644 --- a/entproto/internal/entprototest/ent/dependsonskipped_update.go +++ b/entproto/internal/entprototest/ent/dependsonskipped_update.go @@ -34,6 +34,14 @@ func (dosu *DependsOnSkippedUpdate) SetName(s string) *DependsOnSkippedUpdate { return dosu } +// SetNillableName sets the "name" field if the given value is not nil. +func (dosu *DependsOnSkippedUpdate) SetNillableName(s *string) *DependsOnSkippedUpdate { + if s != nil { + dosu.SetName(*s) + } + return dosu +} + // AddSkippedIDs adds the "skipped" edge to the ImplicitSkippedMessage entity by IDs. func (dosu *DependsOnSkippedUpdate) AddSkippedIDs(ids ...int) *DependsOnSkippedUpdate { dosu.mutation.AddSkippedIDs(ids...) @@ -77,7 +85,7 @@ func (dosu *DependsOnSkippedUpdate) RemoveSkipped(i ...*ImplicitSkippedMessage) // Save executes the query and returns the number of nodes affected by the update operation. func (dosu *DependsOnSkippedUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, DependsOnSkippedMutation](ctx, dosu.sqlSave, dosu.mutation, dosu.hooks) + return withHooks(ctx, dosu.sqlSave, dosu.mutation, dosu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -185,6 +193,14 @@ func (dosuo *DependsOnSkippedUpdateOne) SetName(s string) *DependsOnSkippedUpdat return dosuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (dosuo *DependsOnSkippedUpdateOne) SetNillableName(s *string) *DependsOnSkippedUpdateOne { + if s != nil { + dosuo.SetName(*s) + } + return dosuo +} + // AddSkippedIDs adds the "skipped" edge to the ImplicitSkippedMessage entity by IDs. func (dosuo *DependsOnSkippedUpdateOne) AddSkippedIDs(ids ...int) *DependsOnSkippedUpdateOne { dosuo.mutation.AddSkippedIDs(ids...) @@ -241,7 +257,7 @@ func (dosuo *DependsOnSkippedUpdateOne) Select(field string, fields ...string) * // Save executes the query and returns the updated DependsOnSkipped entity. func (dosuo *DependsOnSkippedUpdateOne) Save(ctx context.Context) (*DependsOnSkipped, error) { - return withHooks[*DependsOnSkipped, DependsOnSkippedMutation](ctx, dosuo.sqlSave, dosuo.mutation, dosuo.hooks) + return withHooks(ctx, dosuo.sqlSave, dosuo.mutation, dosuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/duplicatenumbermessage/where.go b/entproto/internal/entprototest/ent/duplicatenumbermessage/where.go index 628e57f51..6bf2adad1 100644 --- a/entproto/internal/entprototest/ent/duplicatenumbermessage/where.go +++ b/entproto/internal/entprototest/ent/duplicatenumbermessage/where.go @@ -194,32 +194,15 @@ func WorldContainsFold(v string) predicate.DuplicateNumberMessage { // And groups predicates with the AND operator between them. func And(predicates ...predicate.DuplicateNumberMessage) predicate.DuplicateNumberMessage { - return predicate.DuplicateNumberMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.DuplicateNumberMessage(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.DuplicateNumberMessage) predicate.DuplicateNumberMessage { - return predicate.DuplicateNumberMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.DuplicateNumberMessage(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.DuplicateNumberMessage) predicate.DuplicateNumberMessage { - return predicate.DuplicateNumberMessage(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.DuplicateNumberMessage(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/duplicatenumbermessage_create.go b/entproto/internal/entprototest/ent/duplicatenumbermessage_create.go index 271575231..b731a85e3 100644 --- a/entproto/internal/entprototest/ent/duplicatenumbermessage_create.go +++ b/entproto/internal/entprototest/ent/duplicatenumbermessage_create.go @@ -38,7 +38,7 @@ func (dnmc *DuplicateNumberMessageCreate) Mutation() *DuplicateNumberMessageMuta // Save creates the DuplicateNumberMessage in the database. func (dnmc *DuplicateNumberMessageCreate) Save(ctx context.Context) (*DuplicateNumberMessage, error) { - return withHooks[*DuplicateNumberMessage, DuplicateNumberMessageMutation](ctx, dnmc.sqlSave, dnmc.mutation, dnmc.hooks) + return withHooks(ctx, dnmc.sqlSave, dnmc.mutation, dnmc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -111,11 +111,15 @@ func (dnmc *DuplicateNumberMessageCreate) createSpec() (*DuplicateNumberMessage, // DuplicateNumberMessageCreateBulk is the builder for creating many DuplicateNumberMessage entities in bulk. type DuplicateNumberMessageCreateBulk struct { config + err error builders []*DuplicateNumberMessageCreate } // Save creates the DuplicateNumberMessage entities in the database. func (dnmcb *DuplicateNumberMessageCreateBulk) Save(ctx context.Context) ([]*DuplicateNumberMessage, error) { + if dnmcb.err != nil { + return nil, dnmcb.err + } specs := make([]*sqlgraph.CreateSpec, len(dnmcb.builders)) nodes := make([]*DuplicateNumberMessage, len(dnmcb.builders)) mutators := make([]Mutator, len(dnmcb.builders)) diff --git a/entproto/internal/entprototest/ent/duplicatenumbermessage_delete.go b/entproto/internal/entprototest/ent/duplicatenumbermessage_delete.go index 0e763c00d..c040002f1 100644 --- a/entproto/internal/entprototest/ent/duplicatenumbermessage_delete.go +++ b/entproto/internal/entprototest/ent/duplicatenumbermessage_delete.go @@ -27,7 +27,7 @@ func (dnmd *DuplicateNumberMessageDelete) Where(ps ...predicate.DuplicateNumberM // Exec executes the deletion query and returns how many vertices were deleted. func (dnmd *DuplicateNumberMessageDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, DuplicateNumberMessageMutation](ctx, dnmd.sqlExec, dnmd.mutation, dnmd.hooks) + return withHooks(ctx, dnmd.sqlExec, dnmd.mutation, dnmd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/duplicatenumbermessage_update.go b/entproto/internal/entprototest/ent/duplicatenumbermessage_update.go index ee855339a..208d3f7e1 100644 --- a/entproto/internal/entprototest/ent/duplicatenumbermessage_update.go +++ b/entproto/internal/entprototest/ent/duplicatenumbermessage_update.go @@ -33,12 +33,28 @@ func (dnmu *DuplicateNumberMessageUpdate) SetHello(s string) *DuplicateNumberMes return dnmu } +// SetNillableHello sets the "hello" field if the given value is not nil. +func (dnmu *DuplicateNumberMessageUpdate) SetNillableHello(s *string) *DuplicateNumberMessageUpdate { + if s != nil { + dnmu.SetHello(*s) + } + return dnmu +} + // SetWorld sets the "world" field. func (dnmu *DuplicateNumberMessageUpdate) SetWorld(s string) *DuplicateNumberMessageUpdate { dnmu.mutation.SetWorld(s) return dnmu } +// SetNillableWorld sets the "world" field if the given value is not nil. +func (dnmu *DuplicateNumberMessageUpdate) SetNillableWorld(s *string) *DuplicateNumberMessageUpdate { + if s != nil { + dnmu.SetWorld(*s) + } + return dnmu +} + // Mutation returns the DuplicateNumberMessageMutation object of the builder. func (dnmu *DuplicateNumberMessageUpdate) Mutation() *DuplicateNumberMessageMutation { return dnmu.mutation @@ -46,7 +62,7 @@ func (dnmu *DuplicateNumberMessageUpdate) Mutation() *DuplicateNumberMessageMuta // Save executes the query and returns the number of nodes affected by the update operation. func (dnmu *DuplicateNumberMessageUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, DuplicateNumberMessageMutation](ctx, dnmu.sqlSave, dnmu.mutation, dnmu.hooks) + return withHooks(ctx, dnmu.sqlSave, dnmu.mutation, dnmu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -112,12 +128,28 @@ func (dnmuo *DuplicateNumberMessageUpdateOne) SetHello(s string) *DuplicateNumbe return dnmuo } +// SetNillableHello sets the "hello" field if the given value is not nil. +func (dnmuo *DuplicateNumberMessageUpdateOne) SetNillableHello(s *string) *DuplicateNumberMessageUpdateOne { + if s != nil { + dnmuo.SetHello(*s) + } + return dnmuo +} + // SetWorld sets the "world" field. func (dnmuo *DuplicateNumberMessageUpdateOne) SetWorld(s string) *DuplicateNumberMessageUpdateOne { dnmuo.mutation.SetWorld(s) return dnmuo } +// SetNillableWorld sets the "world" field if the given value is not nil. +func (dnmuo *DuplicateNumberMessageUpdateOne) SetNillableWorld(s *string) *DuplicateNumberMessageUpdateOne { + if s != nil { + dnmuo.SetWorld(*s) + } + return dnmuo +} + // Mutation returns the DuplicateNumberMessageMutation object of the builder. func (dnmuo *DuplicateNumberMessageUpdateOne) Mutation() *DuplicateNumberMessageMutation { return dnmuo.mutation @@ -138,7 +170,7 @@ func (dnmuo *DuplicateNumberMessageUpdateOne) Select(field string, fields ...str // Save executes the query and returns the updated DuplicateNumberMessage entity. func (dnmuo *DuplicateNumberMessageUpdateOne) Save(ctx context.Context) (*DuplicateNumberMessage, error) { - return withHooks[*DuplicateNumberMessage, DuplicateNumberMessageMutation](ctx, dnmuo.sqlSave, dnmuo.mutation, dnmuo.hooks) + return withHooks(ctx, dnmuo.sqlSave, dnmuo.mutation, dnmuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/ent.go b/entproto/internal/entprototest/ent/ent.go index 55c8384e2..63b352a9f 100644 --- a/entproto/internal/entprototest/ent/ent.go +++ b/entproto/internal/entprototest/ent/ent.go @@ -14,6 +14,7 @@ import ( "entgo.io/contrib/entproto/internal/entprototest/ent/category" "entgo.io/contrib/entproto/internal/entprototest/ent/dependsonskipped" "entgo.io/contrib/entproto/internal/entprototest/ent/duplicatenumbermessage" + "entgo.io/contrib/entproto/internal/entprototest/ent/enumwithconflictingvalue" "entgo.io/contrib/entproto/internal/entprototest/ent/explicitskippedmessage" "entgo.io/contrib/entproto/internal/entprototest/ent/image" "entgo.io/contrib/entproto/internal/entprototest/ent/implicitskippedmessage" @@ -21,6 +22,7 @@ import ( "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithenum" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithfieldone" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithid" + "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithints" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithoptionals" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithpackagename" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithstrings" @@ -94,28 +96,30 @@ var ( func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ - allmethodsservice.Table: allmethodsservice.ValidColumn, - blogpost.Table: blogpost.ValidColumn, - category.Table: category.ValidColumn, - dependsonskipped.Table: dependsonskipped.ValidColumn, - duplicatenumbermessage.Table: duplicatenumbermessage.ValidColumn, - explicitskippedmessage.Table: explicitskippedmessage.ValidColumn, - image.Table: image.ValidColumn, - implicitskippedmessage.Table: implicitskippedmessage.ValidColumn, - invalidfieldmessage.Table: invalidfieldmessage.ValidColumn, - messagewithenum.Table: messagewithenum.ValidColumn, - messagewithfieldone.Table: messagewithfieldone.ValidColumn, - messagewithid.Table: messagewithid.ValidColumn, - messagewithoptionals.Table: messagewithoptionals.ValidColumn, - messagewithpackagename.Table: messagewithpackagename.ValidColumn, - messagewithstrings.Table: messagewithstrings.ValidColumn, - nobackref.Table: nobackref.ValidColumn, - onemethodservice.Table: onemethodservice.ValidColumn, - portal.Table: portal.ValidColumn, - skipedgeexample.Table: skipedgeexample.ValidColumn, - twomethodservice.Table: twomethodservice.ValidColumn, - user.Table: user.ValidColumn, - validmessage.Table: validmessage.ValidColumn, + allmethodsservice.Table: allmethodsservice.ValidColumn, + blogpost.Table: blogpost.ValidColumn, + category.Table: category.ValidColumn, + dependsonskipped.Table: dependsonskipped.ValidColumn, + duplicatenumbermessage.Table: duplicatenumbermessage.ValidColumn, + enumwithconflictingvalue.Table: enumwithconflictingvalue.ValidColumn, + explicitskippedmessage.Table: explicitskippedmessage.ValidColumn, + image.Table: image.ValidColumn, + implicitskippedmessage.Table: implicitskippedmessage.ValidColumn, + invalidfieldmessage.Table: invalidfieldmessage.ValidColumn, + messagewithenum.Table: messagewithenum.ValidColumn, + messagewithfieldone.Table: messagewithfieldone.ValidColumn, + messagewithid.Table: messagewithid.ValidColumn, + messagewithints.Table: messagewithints.ValidColumn, + messagewithoptionals.Table: messagewithoptionals.ValidColumn, + messagewithpackagename.Table: messagewithpackagename.ValidColumn, + messagewithstrings.Table: messagewithstrings.ValidColumn, + nobackref.Table: nobackref.ValidColumn, + onemethodservice.Table: onemethodservice.ValidColumn, + portal.Table: portal.ValidColumn, + skipedgeexample.Table: skipedgeexample.ValidColumn, + twomethodservice.Table: twomethodservice.ValidColumn, + user.Table: user.ValidColumn, + validmessage.Table: validmessage.ValidColumn, }) }) return columnCheck(table, column) diff --git a/entproto/internal/entprototest/ent/enumwithconflictingvalue.go b/entproto/internal/entprototest/ent/enumwithconflictingvalue.go new file mode 100644 index 000000000..801f2764b --- /dev/null +++ b/entproto/internal/entprototest/ent/enumwithconflictingvalue.go @@ -0,0 +1,103 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/contrib/entproto/internal/entprototest/ent/enumwithconflictingvalue" + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// EnumWithConflictingValue is the model entity for the EnumWithConflictingValue schema. +type EnumWithConflictingValue struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Enum holds the value of the "enum" field. + Enum enumwithconflictingvalue.Enum `json:"enum,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EnumWithConflictingValue) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case enumwithconflictingvalue.FieldID: + values[i] = new(sql.NullInt64) + case enumwithconflictingvalue.FieldEnum: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EnumWithConflictingValue fields. +func (ewcv *EnumWithConflictingValue) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case enumwithconflictingvalue.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + ewcv.ID = int(value.Int64) + case enumwithconflictingvalue.FieldEnum: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field enum", values[i]) + } else if value.Valid { + ewcv.Enum = enumwithconflictingvalue.Enum(value.String) + } + default: + ewcv.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the EnumWithConflictingValue. +// This includes values selected through modifiers, order, etc. +func (ewcv *EnumWithConflictingValue) Value(name string) (ent.Value, error) { + return ewcv.selectValues.Get(name) +} + +// Update returns a builder for updating this EnumWithConflictingValue. +// Note that you need to call EnumWithConflictingValue.Unwrap() before calling this method if this EnumWithConflictingValue +// was returned from a transaction, and the transaction was committed or rolled back. +func (ewcv *EnumWithConflictingValue) Update() *EnumWithConflictingValueUpdateOne { + return NewEnumWithConflictingValueClient(ewcv.config).UpdateOne(ewcv) +} + +// Unwrap unwraps the EnumWithConflictingValue entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (ewcv *EnumWithConflictingValue) Unwrap() *EnumWithConflictingValue { + _tx, ok := ewcv.config.driver.(*txDriver) + if !ok { + panic("ent: EnumWithConflictingValue is not a transactional entity") + } + ewcv.config.driver = _tx.drv + return ewcv +} + +// String implements the fmt.Stringer. +func (ewcv *EnumWithConflictingValue) String() string { + var builder strings.Builder + builder.WriteString("EnumWithConflictingValue(") + builder.WriteString(fmt.Sprintf("id=%v, ", ewcv.ID)) + builder.WriteString("enum=") + builder.WriteString(fmt.Sprintf("%v", ewcv.Enum)) + builder.WriteByte(')') + return builder.String() +} + +// EnumWithConflictingValues is a parsable slice of EnumWithConflictingValue. +type EnumWithConflictingValues []*EnumWithConflictingValue diff --git a/entproto/internal/entprototest/ent/enumwithconflictingvalue/enumwithconflictingvalue.go b/entproto/internal/entprototest/ent/enumwithconflictingvalue/enumwithconflictingvalue.go new file mode 100644 index 000000000..0261af61b --- /dev/null +++ b/entproto/internal/entprototest/ent/enumwithconflictingvalue/enumwithconflictingvalue.go @@ -0,0 +1,72 @@ +// Code generated by ent, DO NOT EDIT. + +package enumwithconflictingvalue + +import ( + "fmt" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the enumwithconflictingvalue type in the database. + Label = "enum_with_conflicting_value" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldEnum holds the string denoting the enum field in the database. + FieldEnum = "enum" + // Table holds the table name of the enumwithconflictingvalue in the database. + Table = "enum_with_conflicting_values" +) + +// Columns holds all SQL columns for enumwithconflictingvalue fields. +var Columns = []string{ + FieldID, + FieldEnum, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// Enum defines the type for the "enum" enum field. +type Enum string + +// Enum values. +const ( + EnumJpeg Enum = "image/jpeg" + EnumJpegAlt Enum = "IMAGE_JPEG" +) + +func (e Enum) String() string { + return string(e) +} + +// EnumValidator is a validator for the "enum" field enum values. It is called by the builders before save. +func EnumValidator(e Enum) error { + switch e { + case EnumJpeg, EnumJpegAlt: + return nil + default: + return fmt.Errorf("enumwithconflictingvalue: invalid enum value for enum field: %q", e) + } +} + +// OrderOption defines the ordering options for the EnumWithConflictingValue queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByEnum orders the results by the enum field. +func ByEnum(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEnum, opts...).ToFunc() +} diff --git a/entproto/internal/entprototest/ent/enumwithconflictingvalue/where.go b/entproto/internal/entprototest/ent/enumwithconflictingvalue/where.go new file mode 100644 index 000000000..e1fae68b2 --- /dev/null +++ b/entproto/internal/entprototest/ent/enumwithconflictingvalue/where.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package enumwithconflictingvalue + +import ( + "entgo.io/contrib/entproto/internal/entprototest/ent/predicate" + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldLTE(FieldID, id)) +} + +// EnumEQ applies the EQ predicate on the "enum" field. +func EnumEQ(v Enum) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldEQ(FieldEnum, v)) +} + +// EnumNEQ applies the NEQ predicate on the "enum" field. +func EnumNEQ(v Enum) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldNEQ(FieldEnum, v)) +} + +// EnumIn applies the In predicate on the "enum" field. +func EnumIn(vs ...Enum) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldIn(FieldEnum, vs...)) +} + +// EnumNotIn applies the NotIn predicate on the "enum" field. +func EnumNotIn(vs ...Enum) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.FieldNotIn(FieldEnum, vs...)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EnumWithConflictingValue) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EnumWithConflictingValue) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EnumWithConflictingValue) predicate.EnumWithConflictingValue { + return predicate.EnumWithConflictingValue(sql.NotPredicates(p)) +} diff --git a/entproto/internal/entprototest/ent/enumwithconflictingvalue_create.go b/entproto/internal/entprototest/ent/enumwithconflictingvalue_create.go new file mode 100644 index 000000000..e20e7a841 --- /dev/null +++ b/entproto/internal/entprototest/ent/enumwithconflictingvalue_create.go @@ -0,0 +1,188 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/contrib/entproto/internal/entprototest/ent/enumwithconflictingvalue" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EnumWithConflictingValueCreate is the builder for creating a EnumWithConflictingValue entity. +type EnumWithConflictingValueCreate struct { + config + mutation *EnumWithConflictingValueMutation + hooks []Hook +} + +// SetEnum sets the "enum" field. +func (ewcvc *EnumWithConflictingValueCreate) SetEnum(e enumwithconflictingvalue.Enum) *EnumWithConflictingValueCreate { + ewcvc.mutation.SetEnum(e) + return ewcvc +} + +// Mutation returns the EnumWithConflictingValueMutation object of the builder. +func (ewcvc *EnumWithConflictingValueCreate) Mutation() *EnumWithConflictingValueMutation { + return ewcvc.mutation +} + +// Save creates the EnumWithConflictingValue in the database. +func (ewcvc *EnumWithConflictingValueCreate) Save(ctx context.Context) (*EnumWithConflictingValue, error) { + return withHooks(ctx, ewcvc.sqlSave, ewcvc.mutation, ewcvc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (ewcvc *EnumWithConflictingValueCreate) SaveX(ctx context.Context) *EnumWithConflictingValue { + v, err := ewcvc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ewcvc *EnumWithConflictingValueCreate) Exec(ctx context.Context) error { + _, err := ewcvc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ewcvc *EnumWithConflictingValueCreate) ExecX(ctx context.Context) { + if err := ewcvc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ewcvc *EnumWithConflictingValueCreate) check() error { + if _, ok := ewcvc.mutation.Enum(); !ok { + return &ValidationError{Name: "enum", err: errors.New(`ent: missing required field "EnumWithConflictingValue.enum"`)} + } + if v, ok := ewcvc.mutation.Enum(); ok { + if err := enumwithconflictingvalue.EnumValidator(v); err != nil { + return &ValidationError{Name: "enum", err: fmt.Errorf(`ent: validator failed for field "EnumWithConflictingValue.enum": %w`, err)} + } + } + return nil +} + +func (ewcvc *EnumWithConflictingValueCreate) sqlSave(ctx context.Context) (*EnumWithConflictingValue, error) { + if err := ewcvc.check(); err != nil { + return nil, err + } + _node, _spec := ewcvc.createSpec() + if err := sqlgraph.CreateNode(ctx, ewcvc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + ewcvc.mutation.id = &_node.ID + ewcvc.mutation.done = true + return _node, nil +} + +func (ewcvc *EnumWithConflictingValueCreate) createSpec() (*EnumWithConflictingValue, *sqlgraph.CreateSpec) { + var ( + _node = &EnumWithConflictingValue{config: ewcvc.config} + _spec = sqlgraph.NewCreateSpec(enumwithconflictingvalue.Table, sqlgraph.NewFieldSpec(enumwithconflictingvalue.FieldID, field.TypeInt)) + ) + if value, ok := ewcvc.mutation.Enum(); ok { + _spec.SetField(enumwithconflictingvalue.FieldEnum, field.TypeEnum, value) + _node.Enum = value + } + return _node, _spec +} + +// EnumWithConflictingValueCreateBulk is the builder for creating many EnumWithConflictingValue entities in bulk. +type EnumWithConflictingValueCreateBulk struct { + config + err error + builders []*EnumWithConflictingValueCreate +} + +// Save creates the EnumWithConflictingValue entities in the database. +func (ewcvcb *EnumWithConflictingValueCreateBulk) Save(ctx context.Context) ([]*EnumWithConflictingValue, error) { + if ewcvcb.err != nil { + return nil, ewcvcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(ewcvcb.builders)) + nodes := make([]*EnumWithConflictingValue, len(ewcvcb.builders)) + mutators := make([]Mutator, len(ewcvcb.builders)) + for i := range ewcvcb.builders { + func(i int, root context.Context) { + builder := ewcvcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EnumWithConflictingValueMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, ewcvcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ewcvcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, ewcvcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ewcvcb *EnumWithConflictingValueCreateBulk) SaveX(ctx context.Context) []*EnumWithConflictingValue { + v, err := ewcvcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ewcvcb *EnumWithConflictingValueCreateBulk) Exec(ctx context.Context) error { + _, err := ewcvcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ewcvcb *EnumWithConflictingValueCreateBulk) ExecX(ctx context.Context) { + if err := ewcvcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/entproto/internal/entprototest/ent/enumwithconflictingvalue_delete.go b/entproto/internal/entprototest/ent/enumwithconflictingvalue_delete.go new file mode 100644 index 000000000..1d5f12a7a --- /dev/null +++ b/entproto/internal/entprototest/ent/enumwithconflictingvalue_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/contrib/entproto/internal/entprototest/ent/enumwithconflictingvalue" + "entgo.io/contrib/entproto/internal/entprototest/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EnumWithConflictingValueDelete is the builder for deleting a EnumWithConflictingValue entity. +type EnumWithConflictingValueDelete struct { + config + hooks []Hook + mutation *EnumWithConflictingValueMutation +} + +// Where appends a list predicates to the EnumWithConflictingValueDelete builder. +func (ewcvd *EnumWithConflictingValueDelete) Where(ps ...predicate.EnumWithConflictingValue) *EnumWithConflictingValueDelete { + ewcvd.mutation.Where(ps...) + return ewcvd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ewcvd *EnumWithConflictingValueDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, ewcvd.sqlExec, ewcvd.mutation, ewcvd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (ewcvd *EnumWithConflictingValueDelete) ExecX(ctx context.Context) int { + n, err := ewcvd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ewcvd *EnumWithConflictingValueDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(enumwithconflictingvalue.Table, sqlgraph.NewFieldSpec(enumwithconflictingvalue.FieldID, field.TypeInt)) + if ps := ewcvd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, ewcvd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + ewcvd.mutation.done = true + return affected, err +} + +// EnumWithConflictingValueDeleteOne is the builder for deleting a single EnumWithConflictingValue entity. +type EnumWithConflictingValueDeleteOne struct { + ewcvd *EnumWithConflictingValueDelete +} + +// Where appends a list predicates to the EnumWithConflictingValueDelete builder. +func (ewcvdo *EnumWithConflictingValueDeleteOne) Where(ps ...predicate.EnumWithConflictingValue) *EnumWithConflictingValueDeleteOne { + ewcvdo.ewcvd.mutation.Where(ps...) + return ewcvdo +} + +// Exec executes the deletion query. +func (ewcvdo *EnumWithConflictingValueDeleteOne) Exec(ctx context.Context) error { + n, err := ewcvdo.ewcvd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{enumwithconflictingvalue.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (ewcvdo *EnumWithConflictingValueDeleteOne) ExecX(ctx context.Context) { + if err := ewcvdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/entproto/internal/entprototest/ent/enumwithconflictingvalue_query.go b/entproto/internal/entprototest/ent/enumwithconflictingvalue_query.go new file mode 100644 index 000000000..3ebcc8db8 --- /dev/null +++ b/entproto/internal/entprototest/ent/enumwithconflictingvalue_query.go @@ -0,0 +1,526 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/contrib/entproto/internal/entprototest/ent/enumwithconflictingvalue" + "entgo.io/contrib/entproto/internal/entprototest/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EnumWithConflictingValueQuery is the builder for querying EnumWithConflictingValue entities. +type EnumWithConflictingValueQuery struct { + config + ctx *QueryContext + order []enumwithconflictingvalue.OrderOption + inters []Interceptor + predicates []predicate.EnumWithConflictingValue + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EnumWithConflictingValueQuery builder. +func (ewcvq *EnumWithConflictingValueQuery) Where(ps ...predicate.EnumWithConflictingValue) *EnumWithConflictingValueQuery { + ewcvq.predicates = append(ewcvq.predicates, ps...) + return ewcvq +} + +// Limit the number of records to be returned by this query. +func (ewcvq *EnumWithConflictingValueQuery) Limit(limit int) *EnumWithConflictingValueQuery { + ewcvq.ctx.Limit = &limit + return ewcvq +} + +// Offset to start from. +func (ewcvq *EnumWithConflictingValueQuery) Offset(offset int) *EnumWithConflictingValueQuery { + ewcvq.ctx.Offset = &offset + return ewcvq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (ewcvq *EnumWithConflictingValueQuery) Unique(unique bool) *EnumWithConflictingValueQuery { + ewcvq.ctx.Unique = &unique + return ewcvq +} + +// Order specifies how the records should be ordered. +func (ewcvq *EnumWithConflictingValueQuery) Order(o ...enumwithconflictingvalue.OrderOption) *EnumWithConflictingValueQuery { + ewcvq.order = append(ewcvq.order, o...) + return ewcvq +} + +// First returns the first EnumWithConflictingValue entity from the query. +// Returns a *NotFoundError when no EnumWithConflictingValue was found. +func (ewcvq *EnumWithConflictingValueQuery) First(ctx context.Context) (*EnumWithConflictingValue, error) { + nodes, err := ewcvq.Limit(1).All(setContextOp(ctx, ewcvq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{enumwithconflictingvalue.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (ewcvq *EnumWithConflictingValueQuery) FirstX(ctx context.Context) *EnumWithConflictingValue { + node, err := ewcvq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EnumWithConflictingValue ID from the query. +// Returns a *NotFoundError when no EnumWithConflictingValue ID was found. +func (ewcvq *EnumWithConflictingValueQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = ewcvq.Limit(1).IDs(setContextOp(ctx, ewcvq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{enumwithconflictingvalue.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (ewcvq *EnumWithConflictingValueQuery) FirstIDX(ctx context.Context) int { + id, err := ewcvq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EnumWithConflictingValue entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EnumWithConflictingValue entity is found. +// Returns a *NotFoundError when no EnumWithConflictingValue entities are found. +func (ewcvq *EnumWithConflictingValueQuery) Only(ctx context.Context) (*EnumWithConflictingValue, error) { + nodes, err := ewcvq.Limit(2).All(setContextOp(ctx, ewcvq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{enumwithconflictingvalue.Label} + default: + return nil, &NotSingularError{enumwithconflictingvalue.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (ewcvq *EnumWithConflictingValueQuery) OnlyX(ctx context.Context) *EnumWithConflictingValue { + node, err := ewcvq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EnumWithConflictingValue ID in the query. +// Returns a *NotSingularError when more than one EnumWithConflictingValue ID is found. +// Returns a *NotFoundError when no entities are found. +func (ewcvq *EnumWithConflictingValueQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = ewcvq.Limit(2).IDs(setContextOp(ctx, ewcvq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{enumwithconflictingvalue.Label} + default: + err = &NotSingularError{enumwithconflictingvalue.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (ewcvq *EnumWithConflictingValueQuery) OnlyIDX(ctx context.Context) int { + id, err := ewcvq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EnumWithConflictingValues. +func (ewcvq *EnumWithConflictingValueQuery) All(ctx context.Context) ([]*EnumWithConflictingValue, error) { + ctx = setContextOp(ctx, ewcvq.ctx, "All") + if err := ewcvq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EnumWithConflictingValue, *EnumWithConflictingValueQuery]() + return withInterceptors[[]*EnumWithConflictingValue](ctx, ewcvq, qr, ewcvq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (ewcvq *EnumWithConflictingValueQuery) AllX(ctx context.Context) []*EnumWithConflictingValue { + nodes, err := ewcvq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EnumWithConflictingValue IDs. +func (ewcvq *EnumWithConflictingValueQuery) IDs(ctx context.Context) (ids []int, err error) { + if ewcvq.ctx.Unique == nil && ewcvq.path != nil { + ewcvq.Unique(true) + } + ctx = setContextOp(ctx, ewcvq.ctx, "IDs") + if err = ewcvq.Select(enumwithconflictingvalue.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (ewcvq *EnumWithConflictingValueQuery) IDsX(ctx context.Context) []int { + ids, err := ewcvq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (ewcvq *EnumWithConflictingValueQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, ewcvq.ctx, "Count") + if err := ewcvq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, ewcvq, querierCount[*EnumWithConflictingValueQuery](), ewcvq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (ewcvq *EnumWithConflictingValueQuery) CountX(ctx context.Context) int { + count, err := ewcvq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (ewcvq *EnumWithConflictingValueQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, ewcvq.ctx, "Exist") + switch _, err := ewcvq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (ewcvq *EnumWithConflictingValueQuery) ExistX(ctx context.Context) bool { + exist, err := ewcvq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EnumWithConflictingValueQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (ewcvq *EnumWithConflictingValueQuery) Clone() *EnumWithConflictingValueQuery { + if ewcvq == nil { + return nil + } + return &EnumWithConflictingValueQuery{ + config: ewcvq.config, + ctx: ewcvq.ctx.Clone(), + order: append([]enumwithconflictingvalue.OrderOption{}, ewcvq.order...), + inters: append([]Interceptor{}, ewcvq.inters...), + predicates: append([]predicate.EnumWithConflictingValue{}, ewcvq.predicates...), + // clone intermediate query. + sql: ewcvq.sql.Clone(), + path: ewcvq.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Enum enumwithconflictingvalue.Enum `json:"enum,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EnumWithConflictingValue.Query(). +// GroupBy(enumwithconflictingvalue.FieldEnum). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (ewcvq *EnumWithConflictingValueQuery) GroupBy(field string, fields ...string) *EnumWithConflictingValueGroupBy { + ewcvq.ctx.Fields = append([]string{field}, fields...) + grbuild := &EnumWithConflictingValueGroupBy{build: ewcvq} + grbuild.flds = &ewcvq.ctx.Fields + grbuild.label = enumwithconflictingvalue.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Enum enumwithconflictingvalue.Enum `json:"enum,omitempty"` +// } +// +// client.EnumWithConflictingValue.Query(). +// Select(enumwithconflictingvalue.FieldEnum). +// Scan(ctx, &v) +func (ewcvq *EnumWithConflictingValueQuery) Select(fields ...string) *EnumWithConflictingValueSelect { + ewcvq.ctx.Fields = append(ewcvq.ctx.Fields, fields...) + sbuild := &EnumWithConflictingValueSelect{EnumWithConflictingValueQuery: ewcvq} + sbuild.label = enumwithconflictingvalue.Label + sbuild.flds, sbuild.scan = &ewcvq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EnumWithConflictingValueSelect configured with the given aggregations. +func (ewcvq *EnumWithConflictingValueQuery) Aggregate(fns ...AggregateFunc) *EnumWithConflictingValueSelect { + return ewcvq.Select().Aggregate(fns...) +} + +func (ewcvq *EnumWithConflictingValueQuery) prepareQuery(ctx context.Context) error { + for _, inter := range ewcvq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, ewcvq); err != nil { + return err + } + } + } + for _, f := range ewcvq.ctx.Fields { + if !enumwithconflictingvalue.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if ewcvq.path != nil { + prev, err := ewcvq.path(ctx) + if err != nil { + return err + } + ewcvq.sql = prev + } + return nil +} + +func (ewcvq *EnumWithConflictingValueQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EnumWithConflictingValue, error) { + var ( + nodes = []*EnumWithConflictingValue{} + _spec = ewcvq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EnumWithConflictingValue).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EnumWithConflictingValue{config: ewcvq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, ewcvq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (ewcvq *EnumWithConflictingValueQuery) sqlCount(ctx context.Context) (int, error) { + _spec := ewcvq.querySpec() + _spec.Node.Columns = ewcvq.ctx.Fields + if len(ewcvq.ctx.Fields) > 0 { + _spec.Unique = ewcvq.ctx.Unique != nil && *ewcvq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, ewcvq.driver, _spec) +} + +func (ewcvq *EnumWithConflictingValueQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(enumwithconflictingvalue.Table, enumwithconflictingvalue.Columns, sqlgraph.NewFieldSpec(enumwithconflictingvalue.FieldID, field.TypeInt)) + _spec.From = ewcvq.sql + if unique := ewcvq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if ewcvq.path != nil { + _spec.Unique = true + } + if fields := ewcvq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, enumwithconflictingvalue.FieldID) + for i := range fields { + if fields[i] != enumwithconflictingvalue.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := ewcvq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := ewcvq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := ewcvq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := ewcvq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (ewcvq *EnumWithConflictingValueQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(ewcvq.driver.Dialect()) + t1 := builder.Table(enumwithconflictingvalue.Table) + columns := ewcvq.ctx.Fields + if len(columns) == 0 { + columns = enumwithconflictingvalue.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if ewcvq.sql != nil { + selector = ewcvq.sql + selector.Select(selector.Columns(columns...)...) + } + if ewcvq.ctx.Unique != nil && *ewcvq.ctx.Unique { + selector.Distinct() + } + for _, p := range ewcvq.predicates { + p(selector) + } + for _, p := range ewcvq.order { + p(selector) + } + if offset := ewcvq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := ewcvq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// EnumWithConflictingValueGroupBy is the group-by builder for EnumWithConflictingValue entities. +type EnumWithConflictingValueGroupBy struct { + selector + build *EnumWithConflictingValueQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ewcvgb *EnumWithConflictingValueGroupBy) Aggregate(fns ...AggregateFunc) *EnumWithConflictingValueGroupBy { + ewcvgb.fns = append(ewcvgb.fns, fns...) + return ewcvgb +} + +// Scan applies the selector query and scans the result into the given value. +func (ewcvgb *EnumWithConflictingValueGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ewcvgb.build.ctx, "GroupBy") + if err := ewcvgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EnumWithConflictingValueQuery, *EnumWithConflictingValueGroupBy](ctx, ewcvgb.build, ewcvgb, ewcvgb.build.inters, v) +} + +func (ewcvgb *EnumWithConflictingValueGroupBy) sqlScan(ctx context.Context, root *EnumWithConflictingValueQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ewcvgb.fns)) + for _, fn := range ewcvgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ewcvgb.flds)+len(ewcvgb.fns)) + for _, f := range *ewcvgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ewcvgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ewcvgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EnumWithConflictingValueSelect is the builder for selecting fields of EnumWithConflictingValue entities. +type EnumWithConflictingValueSelect struct { + *EnumWithConflictingValueQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ewcvs *EnumWithConflictingValueSelect) Aggregate(fns ...AggregateFunc) *EnumWithConflictingValueSelect { + ewcvs.fns = append(ewcvs.fns, fns...) + return ewcvs +} + +// Scan applies the selector query and scans the result into the given value. +func (ewcvs *EnumWithConflictingValueSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ewcvs.ctx, "Select") + if err := ewcvs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EnumWithConflictingValueQuery, *EnumWithConflictingValueSelect](ctx, ewcvs.EnumWithConflictingValueQuery, ewcvs, ewcvs.inters, v) +} + +func (ewcvs *EnumWithConflictingValueSelect) sqlScan(ctx context.Context, root *EnumWithConflictingValueQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ewcvs.fns)) + for _, fn := range ewcvs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ewcvs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ewcvs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/entproto/internal/entprototest/ent/enumwithconflictingvalue_update.go b/entproto/internal/entprototest/ent/enumwithconflictingvalue_update.go new file mode 100644 index 000000000..bdd4503f4 --- /dev/null +++ b/entproto/internal/entprototest/ent/enumwithconflictingvalue_update.go @@ -0,0 +1,235 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/contrib/entproto/internal/entprototest/ent/enumwithconflictingvalue" + "entgo.io/contrib/entproto/internal/entprototest/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// EnumWithConflictingValueUpdate is the builder for updating EnumWithConflictingValue entities. +type EnumWithConflictingValueUpdate struct { + config + hooks []Hook + mutation *EnumWithConflictingValueMutation +} + +// Where appends a list predicates to the EnumWithConflictingValueUpdate builder. +func (ewcvu *EnumWithConflictingValueUpdate) Where(ps ...predicate.EnumWithConflictingValue) *EnumWithConflictingValueUpdate { + ewcvu.mutation.Where(ps...) + return ewcvu +} + +// SetEnum sets the "enum" field. +func (ewcvu *EnumWithConflictingValueUpdate) SetEnum(e enumwithconflictingvalue.Enum) *EnumWithConflictingValueUpdate { + ewcvu.mutation.SetEnum(e) + return ewcvu +} + +// SetNillableEnum sets the "enum" field if the given value is not nil. +func (ewcvu *EnumWithConflictingValueUpdate) SetNillableEnum(e *enumwithconflictingvalue.Enum) *EnumWithConflictingValueUpdate { + if e != nil { + ewcvu.SetEnum(*e) + } + return ewcvu +} + +// Mutation returns the EnumWithConflictingValueMutation object of the builder. +func (ewcvu *EnumWithConflictingValueUpdate) Mutation() *EnumWithConflictingValueMutation { + return ewcvu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (ewcvu *EnumWithConflictingValueUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, ewcvu.sqlSave, ewcvu.mutation, ewcvu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ewcvu *EnumWithConflictingValueUpdate) SaveX(ctx context.Context) int { + affected, err := ewcvu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (ewcvu *EnumWithConflictingValueUpdate) Exec(ctx context.Context) error { + _, err := ewcvu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ewcvu *EnumWithConflictingValueUpdate) ExecX(ctx context.Context) { + if err := ewcvu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ewcvu *EnumWithConflictingValueUpdate) check() error { + if v, ok := ewcvu.mutation.Enum(); ok { + if err := enumwithconflictingvalue.EnumValidator(v); err != nil { + return &ValidationError{Name: "enum", err: fmt.Errorf(`ent: validator failed for field "EnumWithConflictingValue.enum": %w`, err)} + } + } + return nil +} + +func (ewcvu *EnumWithConflictingValueUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := ewcvu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(enumwithconflictingvalue.Table, enumwithconflictingvalue.Columns, sqlgraph.NewFieldSpec(enumwithconflictingvalue.FieldID, field.TypeInt)) + if ps := ewcvu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ewcvu.mutation.Enum(); ok { + _spec.SetField(enumwithconflictingvalue.FieldEnum, field.TypeEnum, value) + } + if n, err = sqlgraph.UpdateNodes(ctx, ewcvu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{enumwithconflictingvalue.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + ewcvu.mutation.done = true + return n, nil +} + +// EnumWithConflictingValueUpdateOne is the builder for updating a single EnumWithConflictingValue entity. +type EnumWithConflictingValueUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EnumWithConflictingValueMutation +} + +// SetEnum sets the "enum" field. +func (ewcvuo *EnumWithConflictingValueUpdateOne) SetEnum(e enumwithconflictingvalue.Enum) *EnumWithConflictingValueUpdateOne { + ewcvuo.mutation.SetEnum(e) + return ewcvuo +} + +// SetNillableEnum sets the "enum" field if the given value is not nil. +func (ewcvuo *EnumWithConflictingValueUpdateOne) SetNillableEnum(e *enumwithconflictingvalue.Enum) *EnumWithConflictingValueUpdateOne { + if e != nil { + ewcvuo.SetEnum(*e) + } + return ewcvuo +} + +// Mutation returns the EnumWithConflictingValueMutation object of the builder. +func (ewcvuo *EnumWithConflictingValueUpdateOne) Mutation() *EnumWithConflictingValueMutation { + return ewcvuo.mutation +} + +// Where appends a list predicates to the EnumWithConflictingValueUpdate builder. +func (ewcvuo *EnumWithConflictingValueUpdateOne) Where(ps ...predicate.EnumWithConflictingValue) *EnumWithConflictingValueUpdateOne { + ewcvuo.mutation.Where(ps...) + return ewcvuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (ewcvuo *EnumWithConflictingValueUpdateOne) Select(field string, fields ...string) *EnumWithConflictingValueUpdateOne { + ewcvuo.fields = append([]string{field}, fields...) + return ewcvuo +} + +// Save executes the query and returns the updated EnumWithConflictingValue entity. +func (ewcvuo *EnumWithConflictingValueUpdateOne) Save(ctx context.Context) (*EnumWithConflictingValue, error) { + return withHooks(ctx, ewcvuo.sqlSave, ewcvuo.mutation, ewcvuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ewcvuo *EnumWithConflictingValueUpdateOne) SaveX(ctx context.Context) *EnumWithConflictingValue { + node, err := ewcvuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (ewcvuo *EnumWithConflictingValueUpdateOne) Exec(ctx context.Context) error { + _, err := ewcvuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ewcvuo *EnumWithConflictingValueUpdateOne) ExecX(ctx context.Context) { + if err := ewcvuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ewcvuo *EnumWithConflictingValueUpdateOne) check() error { + if v, ok := ewcvuo.mutation.Enum(); ok { + if err := enumwithconflictingvalue.EnumValidator(v); err != nil { + return &ValidationError{Name: "enum", err: fmt.Errorf(`ent: validator failed for field "EnumWithConflictingValue.enum": %w`, err)} + } + } + return nil +} + +func (ewcvuo *EnumWithConflictingValueUpdateOne) sqlSave(ctx context.Context) (_node *EnumWithConflictingValue, err error) { + if err := ewcvuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(enumwithconflictingvalue.Table, enumwithconflictingvalue.Columns, sqlgraph.NewFieldSpec(enumwithconflictingvalue.FieldID, field.TypeInt)) + id, ok := ewcvuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EnumWithConflictingValue.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := ewcvuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, enumwithconflictingvalue.FieldID) + for _, f := range fields { + if !enumwithconflictingvalue.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != enumwithconflictingvalue.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := ewcvuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ewcvuo.mutation.Enum(); ok { + _spec.SetField(enumwithconflictingvalue.FieldEnum, field.TypeEnum, value) + } + _node = &EnumWithConflictingValue{config: ewcvuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, ewcvuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{enumwithconflictingvalue.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + ewcvuo.mutation.done = true + return _node, nil +} diff --git a/entproto/internal/entprototest/ent/explicitskippedmessage/where.go b/entproto/internal/entprototest/ent/explicitskippedmessage/where.go index 655255de0..4bc40f845 100644 --- a/entproto/internal/entprototest/ent/explicitskippedmessage/where.go +++ b/entproto/internal/entprototest/ent/explicitskippedmessage/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.ExplicitSkippedMessage { // And groups predicates with the AND operator between them. func And(predicates ...predicate.ExplicitSkippedMessage) predicate.ExplicitSkippedMessage { - return predicate.ExplicitSkippedMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.ExplicitSkippedMessage(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.ExplicitSkippedMessage) predicate.ExplicitSkippedMessage { - return predicate.ExplicitSkippedMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.ExplicitSkippedMessage(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.ExplicitSkippedMessage) predicate.ExplicitSkippedMessage { - return predicate.ExplicitSkippedMessage(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.ExplicitSkippedMessage(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/explicitskippedmessage_create.go b/entproto/internal/entprototest/ent/explicitskippedmessage_create.go index e38d9c337..037d7e6a6 100644 --- a/entproto/internal/entprototest/ent/explicitskippedmessage_create.go +++ b/entproto/internal/entprototest/ent/explicitskippedmessage_create.go @@ -25,7 +25,7 @@ func (esmc *ExplicitSkippedMessageCreate) Mutation() *ExplicitSkippedMessageMuta // Save creates the ExplicitSkippedMessage in the database. func (esmc *ExplicitSkippedMessageCreate) Save(ctx context.Context) (*ExplicitSkippedMessage, error) { - return withHooks[*ExplicitSkippedMessage, ExplicitSkippedMessageMutation](ctx, esmc.sqlSave, esmc.mutation, esmc.hooks) + return withHooks(ctx, esmc.sqlSave, esmc.mutation, esmc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (esmc *ExplicitSkippedMessageCreate) createSpec() (*ExplicitSkippedMessage, // ExplicitSkippedMessageCreateBulk is the builder for creating many ExplicitSkippedMessage entities in bulk. type ExplicitSkippedMessageCreateBulk struct { config + err error builders []*ExplicitSkippedMessageCreate } // Save creates the ExplicitSkippedMessage entities in the database. func (esmcb *ExplicitSkippedMessageCreateBulk) Save(ctx context.Context) ([]*ExplicitSkippedMessage, error) { + if esmcb.err != nil { + return nil, esmcb.err + } specs := make([]*sqlgraph.CreateSpec, len(esmcb.builders)) nodes := make([]*ExplicitSkippedMessage, len(esmcb.builders)) mutators := make([]Mutator, len(esmcb.builders)) diff --git a/entproto/internal/entprototest/ent/explicitskippedmessage_delete.go b/entproto/internal/entprototest/ent/explicitskippedmessage_delete.go index 493420ef9..835be07db 100644 --- a/entproto/internal/entprototest/ent/explicitskippedmessage_delete.go +++ b/entproto/internal/entprototest/ent/explicitskippedmessage_delete.go @@ -27,7 +27,7 @@ func (esmd *ExplicitSkippedMessageDelete) Where(ps ...predicate.ExplicitSkippedM // Exec executes the deletion query and returns how many vertices were deleted. func (esmd *ExplicitSkippedMessageDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, ExplicitSkippedMessageMutation](ctx, esmd.sqlExec, esmd.mutation, esmd.hooks) + return withHooks(ctx, esmd.sqlExec, esmd.mutation, esmd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/explicitskippedmessage_update.go b/entproto/internal/entprototest/ent/explicitskippedmessage_update.go index 93c61f1eb..d30055f3b 100644 --- a/entproto/internal/entprototest/ent/explicitskippedmessage_update.go +++ b/entproto/internal/entprototest/ent/explicitskippedmessage_update.go @@ -34,7 +34,7 @@ func (esmu *ExplicitSkippedMessageUpdate) Mutation() *ExplicitSkippedMessageMuta // Save executes the query and returns the number of nodes affected by the update operation. func (esmu *ExplicitSkippedMessageUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, ExplicitSkippedMessageMutation](ctx, esmu.sqlSave, esmu.mutation, esmu.hooks) + return withHooks(ctx, esmu.sqlSave, esmu.mutation, esmu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (esmuo *ExplicitSkippedMessageUpdateOne) Select(field string, fields ...str // Save executes the query and returns the updated ExplicitSkippedMessage entity. func (esmuo *ExplicitSkippedMessageUpdateOne) Save(ctx context.Context) (*ExplicitSkippedMessage, error) { - return withHooks[*ExplicitSkippedMessage, ExplicitSkippedMessageMutation](ctx, esmuo.sqlSave, esmuo.mutation, esmuo.hooks) + return withHooks(ctx, esmuo.sqlSave, esmuo.mutation, esmuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/hook/hook.go b/entproto/internal/entprototest/ent/hook/hook.go index 950daf3b7..4493bcf35 100644 --- a/entproto/internal/entprototest/ent/hook/hook.go +++ b/entproto/internal/entprototest/ent/hook/hook.go @@ -69,6 +69,18 @@ func (f DuplicateNumberMessageFunc) Mutate(ctx context.Context, m ent.Mutation) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DuplicateNumberMessageMutation", m) } +// The EnumWithConflictingValueFunc type is an adapter to allow the use of ordinary +// function as EnumWithConflictingValue mutator. +type EnumWithConflictingValueFunc func(context.Context, *ent.EnumWithConflictingValueMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EnumWithConflictingValueFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EnumWithConflictingValueMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EnumWithConflictingValueMutation", m) +} + // The ExplicitSkippedMessageFunc type is an adapter to allow the use of ordinary // function as ExplicitSkippedMessage mutator. type ExplicitSkippedMessageFunc func(context.Context, *ent.ExplicitSkippedMessageMutation) (ent.Value, error) @@ -153,6 +165,18 @@ func (f MessageWithIDFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Valu return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MessageWithIDMutation", m) } +// The MessageWithIntsFunc type is an adapter to allow the use of ordinary +// function as MessageWithInts mutator. +type MessageWithIntsFunc func(context.Context, *ent.MessageWithIntsMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f MessageWithIntsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.MessageWithIntsMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MessageWithIntsMutation", m) +} + // The MessageWithOptionalsFunc type is an adapter to allow the use of ordinary // function as MessageWithOptionals mutator. type MessageWithOptionalsFunc func(context.Context, *ent.MessageWithOptionalsMutation) (ent.Value, error) diff --git a/entproto/internal/entprototest/ent/image/where.go b/entproto/internal/entprototest/ent/image/where.go index 95b6874ab..c0c2541dc 100644 --- a/entproto/internal/entprototest/ent/image/where.go +++ b/entproto/internal/entprototest/ent/image/where.go @@ -149,32 +149,15 @@ func HasUserProfilePicWith(preds ...predicate.User) predicate.Image { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Image) predicate.Image { - return predicate.Image(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Image(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Image) predicate.Image { - return predicate.Image(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Image(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Image) predicate.Image { - return predicate.Image(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Image(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/image_create.go b/entproto/internal/entprototest/ent/image_create.go index 94c581da9..23d5803e1 100644 --- a/entproto/internal/entprototest/ent/image_create.go +++ b/entproto/internal/entprototest/ent/image_create.go @@ -55,7 +55,7 @@ func (ic *ImageCreate) Mutation() *ImageMutation { // Save creates the Image in the database. func (ic *ImageCreate) Save(ctx context.Context) (*Image, error) { - return withHooks[*Image, ImageMutation](ctx, ic.sqlSave, ic.mutation, ic.hooks) + return withHooks(ctx, ic.sqlSave, ic.mutation, ic.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -146,11 +146,15 @@ func (ic *ImageCreate) createSpec() (*Image, *sqlgraph.CreateSpec) { // ImageCreateBulk is the builder for creating many Image entities in bulk. type ImageCreateBulk struct { config + err error builders []*ImageCreate } // Save creates the Image entities in the database. func (icb *ImageCreateBulk) Save(ctx context.Context) ([]*Image, error) { + if icb.err != nil { + return nil, icb.err + } specs := make([]*sqlgraph.CreateSpec, len(icb.builders)) nodes := make([]*Image, len(icb.builders)) mutators := make([]Mutator, len(icb.builders)) diff --git a/entproto/internal/entprototest/ent/image_delete.go b/entproto/internal/entprototest/ent/image_delete.go index 7d99eda87..105239bf1 100644 --- a/entproto/internal/entprototest/ent/image_delete.go +++ b/entproto/internal/entprototest/ent/image_delete.go @@ -27,7 +27,7 @@ func (id *ImageDelete) Where(ps ...predicate.Image) *ImageDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (id *ImageDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, ImageMutation](ctx, id.sqlExec, id.mutation, id.hooks) + return withHooks(ctx, id.sqlExec, id.mutation, id.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/image_update.go b/entproto/internal/entprototest/ent/image_update.go index b37c9fbec..74835c21c 100644 --- a/entproto/internal/entprototest/ent/image_update.go +++ b/entproto/internal/entprototest/ent/image_update.go @@ -34,6 +34,14 @@ func (iu *ImageUpdate) SetURLPath(s string) *ImageUpdate { return iu } +// SetNillableURLPath sets the "url_path" field if the given value is not nil. +func (iu *ImageUpdate) SetNillableURLPath(s *string) *ImageUpdate { + if s != nil { + iu.SetURLPath(*s) + } + return iu +} + // AddUserProfilePicIDs adds the "user_profile_pic" edge to the User entity by IDs. func (iu *ImageUpdate) AddUserProfilePicIDs(ids ...int) *ImageUpdate { iu.mutation.AddUserProfilePicIDs(ids...) @@ -77,7 +85,7 @@ func (iu *ImageUpdate) RemoveUserProfilePic(u ...*User) *ImageUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (iu *ImageUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, ImageMutation](ctx, iu.sqlSave, iu.mutation, iu.hooks) + return withHooks(ctx, iu.sqlSave, iu.mutation, iu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -185,6 +193,14 @@ func (iuo *ImageUpdateOne) SetURLPath(s string) *ImageUpdateOne { return iuo } +// SetNillableURLPath sets the "url_path" field if the given value is not nil. +func (iuo *ImageUpdateOne) SetNillableURLPath(s *string) *ImageUpdateOne { + if s != nil { + iuo.SetURLPath(*s) + } + return iuo +} + // AddUserProfilePicIDs adds the "user_profile_pic" edge to the User entity by IDs. func (iuo *ImageUpdateOne) AddUserProfilePicIDs(ids ...int) *ImageUpdateOne { iuo.mutation.AddUserProfilePicIDs(ids...) @@ -241,7 +257,7 @@ func (iuo *ImageUpdateOne) Select(field string, fields ...string) *ImageUpdateOn // Save executes the query and returns the updated Image entity. func (iuo *ImageUpdateOne) Save(ctx context.Context) (*Image, error) { - return withHooks[*Image, ImageMutation](ctx, iuo.sqlSave, iuo.mutation, iuo.hooks) + return withHooks(ctx, iuo.sqlSave, iuo.mutation, iuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/implicitskippedmessage/where.go b/entproto/internal/entprototest/ent/implicitskippedmessage/where.go index 349e151d8..f382cc67f 100644 --- a/entproto/internal/entprototest/ent/implicitskippedmessage/where.go +++ b/entproto/internal/entprototest/ent/implicitskippedmessage/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.ImplicitSkippedMessage { // And groups predicates with the AND operator between them. func And(predicates ...predicate.ImplicitSkippedMessage) predicate.ImplicitSkippedMessage { - return predicate.ImplicitSkippedMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.ImplicitSkippedMessage(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.ImplicitSkippedMessage) predicate.ImplicitSkippedMessage { - return predicate.ImplicitSkippedMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.ImplicitSkippedMessage(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.ImplicitSkippedMessage) predicate.ImplicitSkippedMessage { - return predicate.ImplicitSkippedMessage(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.ImplicitSkippedMessage(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/implicitskippedmessage_create.go b/entproto/internal/entprototest/ent/implicitskippedmessage_create.go index da6c0f21e..a1f300df7 100644 --- a/entproto/internal/entprototest/ent/implicitskippedmessage_create.go +++ b/entproto/internal/entprototest/ent/implicitskippedmessage_create.go @@ -25,7 +25,7 @@ func (ismc *ImplicitSkippedMessageCreate) Mutation() *ImplicitSkippedMessageMuta // Save creates the ImplicitSkippedMessage in the database. func (ismc *ImplicitSkippedMessageCreate) Save(ctx context.Context) (*ImplicitSkippedMessage, error) { - return withHooks[*ImplicitSkippedMessage, ImplicitSkippedMessageMutation](ctx, ismc.sqlSave, ismc.mutation, ismc.hooks) + return withHooks(ctx, ismc.sqlSave, ismc.mutation, ismc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (ismc *ImplicitSkippedMessageCreate) createSpec() (*ImplicitSkippedMessage, // ImplicitSkippedMessageCreateBulk is the builder for creating many ImplicitSkippedMessage entities in bulk. type ImplicitSkippedMessageCreateBulk struct { config + err error builders []*ImplicitSkippedMessageCreate } // Save creates the ImplicitSkippedMessage entities in the database. func (ismcb *ImplicitSkippedMessageCreateBulk) Save(ctx context.Context) ([]*ImplicitSkippedMessage, error) { + if ismcb.err != nil { + return nil, ismcb.err + } specs := make([]*sqlgraph.CreateSpec, len(ismcb.builders)) nodes := make([]*ImplicitSkippedMessage, len(ismcb.builders)) mutators := make([]Mutator, len(ismcb.builders)) diff --git a/entproto/internal/entprototest/ent/implicitskippedmessage_delete.go b/entproto/internal/entprototest/ent/implicitskippedmessage_delete.go index 3bd13344f..c87764c95 100644 --- a/entproto/internal/entprototest/ent/implicitskippedmessage_delete.go +++ b/entproto/internal/entprototest/ent/implicitskippedmessage_delete.go @@ -27,7 +27,7 @@ func (ismd *ImplicitSkippedMessageDelete) Where(ps ...predicate.ImplicitSkippedM // Exec executes the deletion query and returns how many vertices were deleted. func (ismd *ImplicitSkippedMessageDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, ImplicitSkippedMessageMutation](ctx, ismd.sqlExec, ismd.mutation, ismd.hooks) + return withHooks(ctx, ismd.sqlExec, ismd.mutation, ismd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/implicitskippedmessage_update.go b/entproto/internal/entprototest/ent/implicitskippedmessage_update.go index 61195ebf3..ddfbf73c7 100644 --- a/entproto/internal/entprototest/ent/implicitskippedmessage_update.go +++ b/entproto/internal/entprototest/ent/implicitskippedmessage_update.go @@ -34,7 +34,7 @@ func (ismu *ImplicitSkippedMessageUpdate) Mutation() *ImplicitSkippedMessageMuta // Save executes the query and returns the number of nodes affected by the update operation. func (ismu *ImplicitSkippedMessageUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, ImplicitSkippedMessageMutation](ctx, ismu.sqlSave, ismu.mutation, ismu.hooks) + return withHooks(ctx, ismu.sqlSave, ismu.mutation, ismu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (ismuo *ImplicitSkippedMessageUpdateOne) Select(field string, fields ...str // Save executes the query and returns the updated ImplicitSkippedMessage entity. func (ismuo *ImplicitSkippedMessageUpdateOne) Save(ctx context.Context) (*ImplicitSkippedMessage, error) { - return withHooks[*ImplicitSkippedMessage, ImplicitSkippedMessageMutation](ctx, ismuo.sqlSave, ismuo.mutation, ismuo.hooks) + return withHooks(ctx, ismuo.sqlSave, ismuo.mutation, ismuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/invalidfieldmessage/where.go b/entproto/internal/entprototest/ent/invalidfieldmessage/where.go index b5d840b73..980fed194 100644 --- a/entproto/internal/entprototest/ent/invalidfieldmessage/where.go +++ b/entproto/internal/entprototest/ent/invalidfieldmessage/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.InvalidFieldMessage { // And groups predicates with the AND operator between them. func And(predicates ...predicate.InvalidFieldMessage) predicate.InvalidFieldMessage { - return predicate.InvalidFieldMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.InvalidFieldMessage(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.InvalidFieldMessage) predicate.InvalidFieldMessage { - return predicate.InvalidFieldMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.InvalidFieldMessage(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.InvalidFieldMessage) predicate.InvalidFieldMessage { - return predicate.InvalidFieldMessage(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.InvalidFieldMessage(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/invalidfieldmessage_create.go b/entproto/internal/entprototest/ent/invalidfieldmessage_create.go index 2413cb51b..cd111e031 100644 --- a/entproto/internal/entprototest/ent/invalidfieldmessage_create.go +++ b/entproto/internal/entprototest/ent/invalidfieldmessage_create.go @@ -33,7 +33,7 @@ func (ifmc *InvalidFieldMessageCreate) Mutation() *InvalidFieldMessageMutation { // Save creates the InvalidFieldMessage in the database. func (ifmc *InvalidFieldMessageCreate) Save(ctx context.Context) (*InvalidFieldMessage, error) { - return withHooks[*InvalidFieldMessage, InvalidFieldMessageMutation](ctx, ifmc.sqlSave, ifmc.mutation, ifmc.hooks) + return withHooks(ctx, ifmc.sqlSave, ifmc.mutation, ifmc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -99,11 +99,15 @@ func (ifmc *InvalidFieldMessageCreate) createSpec() (*InvalidFieldMessage, *sqlg // InvalidFieldMessageCreateBulk is the builder for creating many InvalidFieldMessage entities in bulk. type InvalidFieldMessageCreateBulk struct { config + err error builders []*InvalidFieldMessageCreate } // Save creates the InvalidFieldMessage entities in the database. func (ifmcb *InvalidFieldMessageCreateBulk) Save(ctx context.Context) ([]*InvalidFieldMessage, error) { + if ifmcb.err != nil { + return nil, ifmcb.err + } specs := make([]*sqlgraph.CreateSpec, len(ifmcb.builders)) nodes := make([]*InvalidFieldMessage, len(ifmcb.builders)) mutators := make([]Mutator, len(ifmcb.builders)) diff --git a/entproto/internal/entprototest/ent/invalidfieldmessage_delete.go b/entproto/internal/entprototest/ent/invalidfieldmessage_delete.go index dc2dd483a..60d6e579d 100644 --- a/entproto/internal/entprototest/ent/invalidfieldmessage_delete.go +++ b/entproto/internal/entprototest/ent/invalidfieldmessage_delete.go @@ -27,7 +27,7 @@ func (ifmd *InvalidFieldMessageDelete) Where(ps ...predicate.InvalidFieldMessage // Exec executes the deletion query and returns how many vertices were deleted. func (ifmd *InvalidFieldMessageDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, InvalidFieldMessageMutation](ctx, ifmd.sqlExec, ifmd.mutation, ifmd.hooks) + return withHooks(ctx, ifmd.sqlExec, ifmd.mutation, ifmd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/invalidfieldmessage_update.go b/entproto/internal/entprototest/ent/invalidfieldmessage_update.go index c11c5bf3e..6ed644885 100644 --- a/entproto/internal/entprototest/ent/invalidfieldmessage_update.go +++ b/entproto/internal/entprototest/ent/invalidfieldmessage_update.go @@ -41,7 +41,7 @@ func (ifmu *InvalidFieldMessageUpdate) Mutation() *InvalidFieldMessageMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (ifmu *InvalidFieldMessageUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, InvalidFieldMessageMutation](ctx, ifmu.sqlSave, ifmu.mutation, ifmu.hooks) + return withHooks(ctx, ifmu.sqlSave, ifmu.mutation, ifmu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -124,7 +124,7 @@ func (ifmuo *InvalidFieldMessageUpdateOne) Select(field string, fields ...string // Save executes the query and returns the updated InvalidFieldMessage entity. func (ifmuo *InvalidFieldMessageUpdateOne) Save(ctx context.Context) (*InvalidFieldMessage, error) { - return withHooks[*InvalidFieldMessage, InvalidFieldMessageMutation](ctx, ifmuo.sqlSave, ifmuo.mutation, ifmuo.hooks) + return withHooks(ctx, ifmuo.sqlSave, ifmuo.mutation, ifmuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithenum.go b/entproto/internal/entprototest/ent/messagewithenum.go index 836e94f83..c67b08845 100644 --- a/entproto/internal/entprototest/ent/messagewithenum.go +++ b/entproto/internal/entprototest/ent/messagewithenum.go @@ -20,7 +20,9 @@ type MessageWithEnum struct { EnumType messagewithenum.EnumType `json:"enum_type,omitempty"` // EnumWithoutDefault holds the value of the "enum_without_default" field. EnumWithoutDefault messagewithenum.EnumWithoutDefault `json:"enum_without_default,omitempty"` - selectValues sql.SelectValues + // EnumWithSpecialCharacters holds the value of the "enum_with_special_characters" field. + EnumWithSpecialCharacters messagewithenum.EnumWithSpecialCharacters `json:"enum_with_special_characters,omitempty"` + selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. @@ -30,7 +32,7 @@ func (*MessageWithEnum) scanValues(columns []string) ([]any, error) { switch columns[i] { case messagewithenum.FieldID: values[i] = new(sql.NullInt64) - case messagewithenum.FieldEnumType, messagewithenum.FieldEnumWithoutDefault: + case messagewithenum.FieldEnumType, messagewithenum.FieldEnumWithoutDefault, messagewithenum.FieldEnumWithSpecialCharacters: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) @@ -65,6 +67,12 @@ func (mwe *MessageWithEnum) assignValues(columns []string, values []any) error { } else if value.Valid { mwe.EnumWithoutDefault = messagewithenum.EnumWithoutDefault(value.String) } + case messagewithenum.FieldEnumWithSpecialCharacters: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field enum_with_special_characters", values[i]) + } else if value.Valid { + mwe.EnumWithSpecialCharacters = messagewithenum.EnumWithSpecialCharacters(value.String) + } default: mwe.selectValues.Set(columns[i], values[i]) } @@ -106,6 +114,9 @@ func (mwe *MessageWithEnum) String() string { builder.WriteString(", ") builder.WriteString("enum_without_default=") builder.WriteString(fmt.Sprintf("%v", mwe.EnumWithoutDefault)) + builder.WriteString(", ") + builder.WriteString("enum_with_special_characters=") + builder.WriteString(fmt.Sprintf("%v", mwe.EnumWithSpecialCharacters)) builder.WriteByte(')') return builder.String() } diff --git a/entproto/internal/entprototest/ent/messagewithenum/messagewithenum.go b/entproto/internal/entprototest/ent/messagewithenum/messagewithenum.go index 5e4d81264..350f3dab0 100644 --- a/entproto/internal/entprototest/ent/messagewithenum/messagewithenum.go +++ b/entproto/internal/entprototest/ent/messagewithenum/messagewithenum.go @@ -17,6 +17,8 @@ const ( FieldEnumType = "enum_type" // FieldEnumWithoutDefault holds the string denoting the enum_without_default field in the database. FieldEnumWithoutDefault = "enum_without_default" + // FieldEnumWithSpecialCharacters holds the string denoting the enum_with_special_characters field in the database. + FieldEnumWithSpecialCharacters = "enum_with_special_characters" // Table holds the table name of the messagewithenum in the database. Table = "message_with_enums" ) @@ -26,6 +28,7 @@ var Columns = []string{ FieldID, FieldEnumType, FieldEnumWithoutDefault, + FieldEnumWithSpecialCharacters, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -89,6 +92,29 @@ func EnumWithoutDefaultValidator(ewd EnumWithoutDefault) error { } } +// EnumWithSpecialCharacters defines the type for the "enum_with_special_characters" enum field. +type EnumWithSpecialCharacters string + +// EnumWithSpecialCharacters values. +const ( + EnumWithSpecialCharactersJpeg EnumWithSpecialCharacters = "image/jpeg" + EnumWithSpecialCharactersPng EnumWithSpecialCharacters = "image/png" +) + +func (ewsc EnumWithSpecialCharacters) String() string { + return string(ewsc) +} + +// EnumWithSpecialCharactersValidator is a validator for the "enum_with_special_characters" field enum values. It is called by the builders before save. +func EnumWithSpecialCharactersValidator(ewsc EnumWithSpecialCharacters) error { + switch ewsc { + case EnumWithSpecialCharactersJpeg, EnumWithSpecialCharactersPng: + return nil + default: + return fmt.Errorf("messagewithenum: invalid enum value for enum_with_special_characters field: %q", ewsc) + } +} + // OrderOption defines the ordering options for the MessageWithEnum queries. type OrderOption func(*sql.Selector) @@ -106,3 +132,8 @@ func ByEnumType(opts ...sql.OrderTermOption) OrderOption { func ByEnumWithoutDefault(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldEnumWithoutDefault, opts...).ToFunc() } + +// ByEnumWithSpecialCharacters orders the results by the enum_with_special_characters field. +func ByEnumWithSpecialCharacters(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEnumWithSpecialCharacters, opts...).ToFunc() +} diff --git a/entproto/internal/entprototest/ent/messagewithenum/where.go b/entproto/internal/entprototest/ent/messagewithenum/where.go index f781d8932..ea8f10592 100644 --- a/entproto/internal/entprototest/ent/messagewithenum/where.go +++ b/entproto/internal/entprototest/ent/messagewithenum/where.go @@ -92,34 +92,37 @@ func EnumWithoutDefaultNotIn(vs ...EnumWithoutDefault) predicate.MessageWithEnum return predicate.MessageWithEnum(sql.FieldNotIn(FieldEnumWithoutDefault, vs...)) } +// EnumWithSpecialCharactersEQ applies the EQ predicate on the "enum_with_special_characters" field. +func EnumWithSpecialCharactersEQ(v EnumWithSpecialCharacters) predicate.MessageWithEnum { + return predicate.MessageWithEnum(sql.FieldEQ(FieldEnumWithSpecialCharacters, v)) +} + +// EnumWithSpecialCharactersNEQ applies the NEQ predicate on the "enum_with_special_characters" field. +func EnumWithSpecialCharactersNEQ(v EnumWithSpecialCharacters) predicate.MessageWithEnum { + return predicate.MessageWithEnum(sql.FieldNEQ(FieldEnumWithSpecialCharacters, v)) +} + +// EnumWithSpecialCharactersIn applies the In predicate on the "enum_with_special_characters" field. +func EnumWithSpecialCharactersIn(vs ...EnumWithSpecialCharacters) predicate.MessageWithEnum { + return predicate.MessageWithEnum(sql.FieldIn(FieldEnumWithSpecialCharacters, vs...)) +} + +// EnumWithSpecialCharactersNotIn applies the NotIn predicate on the "enum_with_special_characters" field. +func EnumWithSpecialCharactersNotIn(vs ...EnumWithSpecialCharacters) predicate.MessageWithEnum { + return predicate.MessageWithEnum(sql.FieldNotIn(FieldEnumWithSpecialCharacters, vs...)) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.MessageWithEnum) predicate.MessageWithEnum { - return predicate.MessageWithEnum(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithEnum(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MessageWithEnum) predicate.MessageWithEnum { - return predicate.MessageWithEnum(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithEnum(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MessageWithEnum) predicate.MessageWithEnum { - return predicate.MessageWithEnum(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MessageWithEnum(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/messagewithenum_create.go b/entproto/internal/entprototest/ent/messagewithenum_create.go index 33fa887a6..75a39ab5a 100644 --- a/entproto/internal/entprototest/ent/messagewithenum_create.go +++ b/entproto/internal/entprototest/ent/messagewithenum_create.go @@ -39,6 +39,12 @@ func (mwec *MessageWithEnumCreate) SetEnumWithoutDefault(mwd messagewithenum.Enu return mwec } +// SetEnumWithSpecialCharacters sets the "enum_with_special_characters" field. +func (mwec *MessageWithEnumCreate) SetEnumWithSpecialCharacters(mwsc messagewithenum.EnumWithSpecialCharacters) *MessageWithEnumCreate { + mwec.mutation.SetEnumWithSpecialCharacters(mwsc) + return mwec +} + // Mutation returns the MessageWithEnumMutation object of the builder. func (mwec *MessageWithEnumCreate) Mutation() *MessageWithEnumMutation { return mwec.mutation @@ -47,7 +53,7 @@ func (mwec *MessageWithEnumCreate) Mutation() *MessageWithEnumMutation { // Save creates the MessageWithEnum in the database. func (mwec *MessageWithEnumCreate) Save(ctx context.Context) (*MessageWithEnum, error) { mwec.defaults() - return withHooks[*MessageWithEnum, MessageWithEnumMutation](ctx, mwec.sqlSave, mwec.mutation, mwec.hooks) + return withHooks(ctx, mwec.sqlSave, mwec.mutation, mwec.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -98,6 +104,14 @@ func (mwec *MessageWithEnumCreate) check() error { return &ValidationError{Name: "enum_without_default", err: fmt.Errorf(`ent: validator failed for field "MessageWithEnum.enum_without_default": %w`, err)} } } + if _, ok := mwec.mutation.EnumWithSpecialCharacters(); !ok { + return &ValidationError{Name: "enum_with_special_characters", err: errors.New(`ent: missing required field "MessageWithEnum.enum_with_special_characters"`)} + } + if v, ok := mwec.mutation.EnumWithSpecialCharacters(); ok { + if err := messagewithenum.EnumWithSpecialCharactersValidator(v); err != nil { + return &ValidationError{Name: "enum_with_special_characters", err: fmt.Errorf(`ent: validator failed for field "MessageWithEnum.enum_with_special_characters": %w`, err)} + } + } return nil } @@ -132,17 +146,25 @@ func (mwec *MessageWithEnumCreate) createSpec() (*MessageWithEnum, *sqlgraph.Cre _spec.SetField(messagewithenum.FieldEnumWithoutDefault, field.TypeEnum, value) _node.EnumWithoutDefault = value } + if value, ok := mwec.mutation.EnumWithSpecialCharacters(); ok { + _spec.SetField(messagewithenum.FieldEnumWithSpecialCharacters, field.TypeEnum, value) + _node.EnumWithSpecialCharacters = value + } return _node, _spec } // MessageWithEnumCreateBulk is the builder for creating many MessageWithEnum entities in bulk. type MessageWithEnumCreateBulk struct { config + err error builders []*MessageWithEnumCreate } // Save creates the MessageWithEnum entities in the database. func (mwecb *MessageWithEnumCreateBulk) Save(ctx context.Context) ([]*MessageWithEnum, error) { + if mwecb.err != nil { + return nil, mwecb.err + } specs := make([]*sqlgraph.CreateSpec, len(mwecb.builders)) nodes := make([]*MessageWithEnum, len(mwecb.builders)) mutators := make([]Mutator, len(mwecb.builders)) diff --git a/entproto/internal/entprototest/ent/messagewithenum_delete.go b/entproto/internal/entprototest/ent/messagewithenum_delete.go index 78b9625d3..e05ddda25 100644 --- a/entproto/internal/entprototest/ent/messagewithenum_delete.go +++ b/entproto/internal/entprototest/ent/messagewithenum_delete.go @@ -27,7 +27,7 @@ func (mwed *MessageWithEnumDelete) Where(ps ...predicate.MessageWithEnum) *Messa // Exec executes the deletion query and returns how many vertices were deleted. func (mwed *MessageWithEnumDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MessageWithEnumMutation](ctx, mwed.sqlExec, mwed.mutation, mwed.hooks) + return withHooks(ctx, mwed.sqlExec, mwed.mutation, mwed.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithenum_update.go b/entproto/internal/entprototest/ent/messagewithenum_update.go index b30452eb4..d7dcf7e69 100644 --- a/entproto/internal/entprototest/ent/messagewithenum_update.go +++ b/entproto/internal/entprototest/ent/messagewithenum_update.go @@ -47,6 +47,28 @@ func (mweu *MessageWithEnumUpdate) SetEnumWithoutDefault(mwd messagewithenum.Enu return mweu } +// SetNillableEnumWithoutDefault sets the "enum_without_default" field if the given value is not nil. +func (mweu *MessageWithEnumUpdate) SetNillableEnumWithoutDefault(mwd *messagewithenum.EnumWithoutDefault) *MessageWithEnumUpdate { + if mwd != nil { + mweu.SetEnumWithoutDefault(*mwd) + } + return mweu +} + +// SetEnumWithSpecialCharacters sets the "enum_with_special_characters" field. +func (mweu *MessageWithEnumUpdate) SetEnumWithSpecialCharacters(mwsc messagewithenum.EnumWithSpecialCharacters) *MessageWithEnumUpdate { + mweu.mutation.SetEnumWithSpecialCharacters(mwsc) + return mweu +} + +// SetNillableEnumWithSpecialCharacters sets the "enum_with_special_characters" field if the given value is not nil. +func (mweu *MessageWithEnumUpdate) SetNillableEnumWithSpecialCharacters(mwsc *messagewithenum.EnumWithSpecialCharacters) *MessageWithEnumUpdate { + if mwsc != nil { + mweu.SetEnumWithSpecialCharacters(*mwsc) + } + return mweu +} + // Mutation returns the MessageWithEnumMutation object of the builder. func (mweu *MessageWithEnumUpdate) Mutation() *MessageWithEnumMutation { return mweu.mutation @@ -54,7 +76,7 @@ func (mweu *MessageWithEnumUpdate) Mutation() *MessageWithEnumMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (mweu *MessageWithEnumUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MessageWithEnumMutation](ctx, mweu.sqlSave, mweu.mutation, mweu.hooks) + return withHooks(ctx, mweu.sqlSave, mweu.mutation, mweu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -91,6 +113,11 @@ func (mweu *MessageWithEnumUpdate) check() error { return &ValidationError{Name: "enum_without_default", err: fmt.Errorf(`ent: validator failed for field "MessageWithEnum.enum_without_default": %w`, err)} } } + if v, ok := mweu.mutation.EnumWithSpecialCharacters(); ok { + if err := messagewithenum.EnumWithSpecialCharactersValidator(v); err != nil { + return &ValidationError{Name: "enum_with_special_characters", err: fmt.Errorf(`ent: validator failed for field "MessageWithEnum.enum_with_special_characters": %w`, err)} + } + } return nil } @@ -112,6 +139,9 @@ func (mweu *MessageWithEnumUpdate) sqlSave(ctx context.Context) (n int, err erro if value, ok := mweu.mutation.EnumWithoutDefault(); ok { _spec.SetField(messagewithenum.FieldEnumWithoutDefault, field.TypeEnum, value) } + if value, ok := mweu.mutation.EnumWithSpecialCharacters(); ok { + _spec.SetField(messagewithenum.FieldEnumWithSpecialCharacters, field.TypeEnum, value) + } if n, err = sqlgraph.UpdateNodes(ctx, mweu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{messagewithenum.Label} @@ -152,6 +182,28 @@ func (mweuo *MessageWithEnumUpdateOne) SetEnumWithoutDefault(mwd messagewithenum return mweuo } +// SetNillableEnumWithoutDefault sets the "enum_without_default" field if the given value is not nil. +func (mweuo *MessageWithEnumUpdateOne) SetNillableEnumWithoutDefault(mwd *messagewithenum.EnumWithoutDefault) *MessageWithEnumUpdateOne { + if mwd != nil { + mweuo.SetEnumWithoutDefault(*mwd) + } + return mweuo +} + +// SetEnumWithSpecialCharacters sets the "enum_with_special_characters" field. +func (mweuo *MessageWithEnumUpdateOne) SetEnumWithSpecialCharacters(mwsc messagewithenum.EnumWithSpecialCharacters) *MessageWithEnumUpdateOne { + mweuo.mutation.SetEnumWithSpecialCharacters(mwsc) + return mweuo +} + +// SetNillableEnumWithSpecialCharacters sets the "enum_with_special_characters" field if the given value is not nil. +func (mweuo *MessageWithEnumUpdateOne) SetNillableEnumWithSpecialCharacters(mwsc *messagewithenum.EnumWithSpecialCharacters) *MessageWithEnumUpdateOne { + if mwsc != nil { + mweuo.SetEnumWithSpecialCharacters(*mwsc) + } + return mweuo +} + // Mutation returns the MessageWithEnumMutation object of the builder. func (mweuo *MessageWithEnumUpdateOne) Mutation() *MessageWithEnumMutation { return mweuo.mutation @@ -172,7 +224,7 @@ func (mweuo *MessageWithEnumUpdateOne) Select(field string, fields ...string) *M // Save executes the query and returns the updated MessageWithEnum entity. func (mweuo *MessageWithEnumUpdateOne) Save(ctx context.Context) (*MessageWithEnum, error) { - return withHooks[*MessageWithEnum, MessageWithEnumMutation](ctx, mweuo.sqlSave, mweuo.mutation, mweuo.hooks) + return withHooks(ctx, mweuo.sqlSave, mweuo.mutation, mweuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -209,6 +261,11 @@ func (mweuo *MessageWithEnumUpdateOne) check() error { return &ValidationError{Name: "enum_without_default", err: fmt.Errorf(`ent: validator failed for field "MessageWithEnum.enum_without_default": %w`, err)} } } + if v, ok := mweuo.mutation.EnumWithSpecialCharacters(); ok { + if err := messagewithenum.EnumWithSpecialCharactersValidator(v); err != nil { + return &ValidationError{Name: "enum_with_special_characters", err: fmt.Errorf(`ent: validator failed for field "MessageWithEnum.enum_with_special_characters": %w`, err)} + } + } return nil } @@ -247,6 +304,9 @@ func (mweuo *MessageWithEnumUpdateOne) sqlSave(ctx context.Context) (_node *Mess if value, ok := mweuo.mutation.EnumWithoutDefault(); ok { _spec.SetField(messagewithenum.FieldEnumWithoutDefault, field.TypeEnum, value) } + if value, ok := mweuo.mutation.EnumWithSpecialCharacters(); ok { + _spec.SetField(messagewithenum.FieldEnumWithSpecialCharacters, field.TypeEnum, value) + } _node = &MessageWithEnum{config: mweuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/entproto/internal/entprototest/ent/messagewithfieldone/where.go b/entproto/internal/entprototest/ent/messagewithfieldone/where.go index b0deeccbe..7d09b855b 100644 --- a/entproto/internal/entprototest/ent/messagewithfieldone/where.go +++ b/entproto/internal/entprototest/ent/messagewithfieldone/where.go @@ -99,32 +99,15 @@ func FieldOneLTE(v int32) predicate.MessageWithFieldOne { // And groups predicates with the AND operator between them. func And(predicates ...predicate.MessageWithFieldOne) predicate.MessageWithFieldOne { - return predicate.MessageWithFieldOne(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithFieldOne(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MessageWithFieldOne) predicate.MessageWithFieldOne { - return predicate.MessageWithFieldOne(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithFieldOne(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MessageWithFieldOne) predicate.MessageWithFieldOne { - return predicate.MessageWithFieldOne(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MessageWithFieldOne(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/messagewithfieldone_create.go b/entproto/internal/entprototest/ent/messagewithfieldone_create.go index a117b55e9..d7fa512b2 100644 --- a/entproto/internal/entprototest/ent/messagewithfieldone_create.go +++ b/entproto/internal/entprototest/ent/messagewithfieldone_create.go @@ -32,7 +32,7 @@ func (mwfoc *MessageWithFieldOneCreate) Mutation() *MessageWithFieldOneMutation // Save creates the MessageWithFieldOne in the database. func (mwfoc *MessageWithFieldOneCreate) Save(ctx context.Context) (*MessageWithFieldOne, error) { - return withHooks[*MessageWithFieldOne, MessageWithFieldOneMutation](ctx, mwfoc.sqlSave, mwfoc.mutation, mwfoc.hooks) + return withHooks(ctx, mwfoc.sqlSave, mwfoc.mutation, mwfoc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -98,11 +98,15 @@ func (mwfoc *MessageWithFieldOneCreate) createSpec() (*MessageWithFieldOne, *sql // MessageWithFieldOneCreateBulk is the builder for creating many MessageWithFieldOne entities in bulk. type MessageWithFieldOneCreateBulk struct { config + err error builders []*MessageWithFieldOneCreate } // Save creates the MessageWithFieldOne entities in the database. func (mwfocb *MessageWithFieldOneCreateBulk) Save(ctx context.Context) ([]*MessageWithFieldOne, error) { + if mwfocb.err != nil { + return nil, mwfocb.err + } specs := make([]*sqlgraph.CreateSpec, len(mwfocb.builders)) nodes := make([]*MessageWithFieldOne, len(mwfocb.builders)) mutators := make([]Mutator, len(mwfocb.builders)) diff --git a/entproto/internal/entprototest/ent/messagewithfieldone_delete.go b/entproto/internal/entprototest/ent/messagewithfieldone_delete.go index 423a9b29e..ba9815cc5 100644 --- a/entproto/internal/entprototest/ent/messagewithfieldone_delete.go +++ b/entproto/internal/entprototest/ent/messagewithfieldone_delete.go @@ -27,7 +27,7 @@ func (mwfod *MessageWithFieldOneDelete) Where(ps ...predicate.MessageWithFieldOn // Exec executes the deletion query and returns how many vertices were deleted. func (mwfod *MessageWithFieldOneDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MessageWithFieldOneMutation](ctx, mwfod.sqlExec, mwfod.mutation, mwfod.hooks) + return withHooks(ctx, mwfod.sqlExec, mwfod.mutation, mwfod.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithfieldone_update.go b/entproto/internal/entprototest/ent/messagewithfieldone_update.go index 4c9a84e31..2cd1e0a13 100644 --- a/entproto/internal/entprototest/ent/messagewithfieldone_update.go +++ b/entproto/internal/entprototest/ent/messagewithfieldone_update.go @@ -34,6 +34,14 @@ func (mwfou *MessageWithFieldOneUpdate) SetFieldOne(i int32) *MessageWithFieldOn return mwfou } +// SetNillableFieldOne sets the "field_one" field if the given value is not nil. +func (mwfou *MessageWithFieldOneUpdate) SetNillableFieldOne(i *int32) *MessageWithFieldOneUpdate { + if i != nil { + mwfou.SetFieldOne(*i) + } + return mwfou +} + // AddFieldOne adds i to the "field_one" field. func (mwfou *MessageWithFieldOneUpdate) AddFieldOne(i int32) *MessageWithFieldOneUpdate { mwfou.mutation.AddFieldOne(i) @@ -47,7 +55,7 @@ func (mwfou *MessageWithFieldOneUpdate) Mutation() *MessageWithFieldOneMutation // Save executes the query and returns the number of nodes affected by the update operation. func (mwfou *MessageWithFieldOneUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MessageWithFieldOneMutation](ctx, mwfou.sqlSave, mwfou.mutation, mwfou.hooks) + return withHooks(ctx, mwfou.sqlSave, mwfou.mutation, mwfou.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -114,6 +122,14 @@ func (mwfouo *MessageWithFieldOneUpdateOne) SetFieldOne(i int32) *MessageWithFie return mwfouo } +// SetNillableFieldOne sets the "field_one" field if the given value is not nil. +func (mwfouo *MessageWithFieldOneUpdateOne) SetNillableFieldOne(i *int32) *MessageWithFieldOneUpdateOne { + if i != nil { + mwfouo.SetFieldOne(*i) + } + return mwfouo +} + // AddFieldOne adds i to the "field_one" field. func (mwfouo *MessageWithFieldOneUpdateOne) AddFieldOne(i int32) *MessageWithFieldOneUpdateOne { mwfouo.mutation.AddFieldOne(i) @@ -140,7 +156,7 @@ func (mwfouo *MessageWithFieldOneUpdateOne) Select(field string, fields ...strin // Save executes the query and returns the updated MessageWithFieldOne entity. func (mwfouo *MessageWithFieldOneUpdateOne) Save(ctx context.Context) (*MessageWithFieldOne, error) { - return withHooks[*MessageWithFieldOne, MessageWithFieldOneMutation](ctx, mwfouo.sqlSave, mwfouo.mutation, mwfouo.hooks) + return withHooks(ctx, mwfouo.sqlSave, mwfouo.mutation, mwfouo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithid/where.go b/entproto/internal/entprototest/ent/messagewithid/where.go index 94098d42e..22fd3302b 100644 --- a/entproto/internal/entprototest/ent/messagewithid/where.go +++ b/entproto/internal/entprototest/ent/messagewithid/where.go @@ -54,32 +54,15 @@ func IDLTE(id int32) predicate.MessageWithID { // And groups predicates with the AND operator between them. func And(predicates ...predicate.MessageWithID) predicate.MessageWithID { - return predicate.MessageWithID(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithID(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MessageWithID) predicate.MessageWithID { - return predicate.MessageWithID(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithID(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MessageWithID) predicate.MessageWithID { - return predicate.MessageWithID(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MessageWithID(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/messagewithid_create.go b/entproto/internal/entprototest/ent/messagewithid_create.go index f628c84db..4c172cf9a 100644 --- a/entproto/internal/entprototest/ent/messagewithid_create.go +++ b/entproto/internal/entprototest/ent/messagewithid_create.go @@ -31,7 +31,7 @@ func (mwic *MessageWithIDCreate) Mutation() *MessageWithIDMutation { // Save creates the MessageWithID in the database. func (mwic *MessageWithIDCreate) Save(ctx context.Context) (*MessageWithID, error) { - return withHooks[*MessageWithID, MessageWithIDMutation](ctx, mwic.sqlSave, mwic.mutation, mwic.hooks) + return withHooks(ctx, mwic.sqlSave, mwic.mutation, mwic.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -96,11 +96,15 @@ func (mwic *MessageWithIDCreate) createSpec() (*MessageWithID, *sqlgraph.CreateS // MessageWithIDCreateBulk is the builder for creating many MessageWithID entities in bulk. type MessageWithIDCreateBulk struct { config + err error builders []*MessageWithIDCreate } // Save creates the MessageWithID entities in the database. func (mwicb *MessageWithIDCreateBulk) Save(ctx context.Context) ([]*MessageWithID, error) { + if mwicb.err != nil { + return nil, mwicb.err + } specs := make([]*sqlgraph.CreateSpec, len(mwicb.builders)) nodes := make([]*MessageWithID, len(mwicb.builders)) mutators := make([]Mutator, len(mwicb.builders)) diff --git a/entproto/internal/entprototest/ent/messagewithid_delete.go b/entproto/internal/entprototest/ent/messagewithid_delete.go index c44a482de..1bb3d0503 100644 --- a/entproto/internal/entprototest/ent/messagewithid_delete.go +++ b/entproto/internal/entprototest/ent/messagewithid_delete.go @@ -27,7 +27,7 @@ func (mwid *MessageWithIDDelete) Where(ps ...predicate.MessageWithID) *MessageWi // Exec executes the deletion query and returns how many vertices were deleted. func (mwid *MessageWithIDDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MessageWithIDMutation](ctx, mwid.sqlExec, mwid.mutation, mwid.hooks) + return withHooks(ctx, mwid.sqlExec, mwid.mutation, mwid.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithid_update.go b/entproto/internal/entprototest/ent/messagewithid_update.go index 2bcf60441..cd3076b9b 100644 --- a/entproto/internal/entprototest/ent/messagewithid_update.go +++ b/entproto/internal/entprototest/ent/messagewithid_update.go @@ -34,7 +34,7 @@ func (mwiu *MessageWithIDUpdate) Mutation() *MessageWithIDMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (mwiu *MessageWithIDUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MessageWithIDMutation](ctx, mwiu.sqlSave, mwiu.mutation, mwiu.hooks) + return withHooks(ctx, mwiu.sqlSave, mwiu.mutation, mwiu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (mwiuo *MessageWithIDUpdateOne) Select(field string, fields ...string) *Mes // Save executes the query and returns the updated MessageWithID entity. func (mwiuo *MessageWithIDUpdateOne) Save(ctx context.Context) (*MessageWithID, error) { - return withHooks[*MessageWithID, MessageWithIDMutation](ctx, mwiuo.sqlSave, mwiuo.mutation, mwiuo.hooks) + return withHooks(ctx, mwiuo.sqlSave, mwiuo.mutation, mwiuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithints.go b/entproto/internal/entprototest/ent/messagewithints.go new file mode 100644 index 000000000..c0d234564 --- /dev/null +++ b/entproto/internal/entprototest/ent/messagewithints.go @@ -0,0 +1,145 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "strings" + + "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithints" + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// MessageWithInts is the model entity for the MessageWithInts schema. +type MessageWithInts struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Int32s holds the value of the "int32s" field. + Int32s []int32 `json:"int32s,omitempty"` + // Int64s holds the value of the "int64s" field. + Int64s []int64 `json:"int64s,omitempty"` + // Uint32s holds the value of the "uint32s" field. + Uint32s []uint32 `json:"uint32s,omitempty"` + // Uint64s holds the value of the "uint64s" field. + Uint64s []uint64 `json:"uint64s,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*MessageWithInts) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case messagewithints.FieldInt32s, messagewithints.FieldInt64s, messagewithints.FieldUint32s, messagewithints.FieldUint64s: + values[i] = new([]byte) + case messagewithints.FieldID: + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the MessageWithInts fields. +func (mwi *MessageWithInts) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case messagewithints.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + mwi.ID = int(value.Int64) + case messagewithints.FieldInt32s: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field int32s", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &mwi.Int32s); err != nil { + return fmt.Errorf("unmarshal field int32s: %w", err) + } + } + case messagewithints.FieldInt64s: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field int64s", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &mwi.Int64s); err != nil { + return fmt.Errorf("unmarshal field int64s: %w", err) + } + } + case messagewithints.FieldUint32s: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field uint32s", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &mwi.Uint32s); err != nil { + return fmt.Errorf("unmarshal field uint32s: %w", err) + } + } + case messagewithints.FieldUint64s: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field uint64s", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &mwi.Uint64s); err != nil { + return fmt.Errorf("unmarshal field uint64s: %w", err) + } + } + default: + mwi.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the MessageWithInts. +// This includes values selected through modifiers, order, etc. +func (mwi *MessageWithInts) Value(name string) (ent.Value, error) { + return mwi.selectValues.Get(name) +} + +// Update returns a builder for updating this MessageWithInts. +// Note that you need to call MessageWithInts.Unwrap() before calling this method if this MessageWithInts +// was returned from a transaction, and the transaction was committed or rolled back. +func (mwi *MessageWithInts) Update() *MessageWithIntsUpdateOne { + return NewMessageWithIntsClient(mwi.config).UpdateOne(mwi) +} + +// Unwrap unwraps the MessageWithInts entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (mwi *MessageWithInts) Unwrap() *MessageWithInts { + _tx, ok := mwi.config.driver.(*txDriver) + if !ok { + panic("ent: MessageWithInts is not a transactional entity") + } + mwi.config.driver = _tx.drv + return mwi +} + +// String implements the fmt.Stringer. +func (mwi *MessageWithInts) String() string { + var builder strings.Builder + builder.WriteString("MessageWithInts(") + builder.WriteString(fmt.Sprintf("id=%v, ", mwi.ID)) + builder.WriteString("int32s=") + builder.WriteString(fmt.Sprintf("%v", mwi.Int32s)) + builder.WriteString(", ") + builder.WriteString("int64s=") + builder.WriteString(fmt.Sprintf("%v", mwi.Int64s)) + builder.WriteString(", ") + builder.WriteString("uint32s=") + builder.WriteString(fmt.Sprintf("%v", mwi.Uint32s)) + builder.WriteString(", ") + builder.WriteString("uint64s=") + builder.WriteString(fmt.Sprintf("%v", mwi.Uint64s)) + builder.WriteByte(')') + return builder.String() +} + +// MessageWithIntsSlice is a parsable slice of MessageWithInts. +type MessageWithIntsSlice []*MessageWithInts diff --git a/entproto/internal/entprototest/ent/messagewithints/messagewithints.go b/entproto/internal/entprototest/ent/messagewithints/messagewithints.go new file mode 100644 index 000000000..2b65e6f8f --- /dev/null +++ b/entproto/internal/entprototest/ent/messagewithints/messagewithints.go @@ -0,0 +1,51 @@ +// Code generated by ent, DO NOT EDIT. + +package messagewithints + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the messagewithints type in the database. + Label = "message_with_ints" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldInt32s holds the string denoting the int32s field in the database. + FieldInt32s = "int32s" + // FieldInt64s holds the string denoting the int64s field in the database. + FieldInt64s = "int64s" + // FieldUint32s holds the string denoting the uint32s field in the database. + FieldUint32s = "uint32s" + // FieldUint64s holds the string denoting the uint64s field in the database. + FieldUint64s = "uint64s" + // Table holds the table name of the messagewithints in the database. + Table = "message_with_ints" +) + +// Columns holds all SQL columns for messagewithints fields. +var Columns = []string{ + FieldID, + FieldInt32s, + FieldInt64s, + FieldUint32s, + FieldUint64s, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the MessageWithInts queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} diff --git a/entproto/internal/entprototest/ent/messagewithints/where.go b/entproto/internal/entprototest/ent/messagewithints/where.go new file mode 100644 index 000000000..a1fde57d3 --- /dev/null +++ b/entproto/internal/entprototest/ent/messagewithints/where.go @@ -0,0 +1,68 @@ +// Code generated by ent, DO NOT EDIT. + +package messagewithints + +import ( + "entgo.io/contrib/entproto/internal/entprototest/ent/predicate" + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.FieldLTE(FieldID, id)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.MessageWithInts) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.MessageWithInts) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.MessageWithInts) predicate.MessageWithInts { + return predicate.MessageWithInts(sql.NotPredicates(p)) +} diff --git a/entproto/internal/entprototest/ent/messagewithints_create.go b/entproto/internal/entprototest/ent/messagewithints_create.go new file mode 100644 index 000000000..ca3b56e7e --- /dev/null +++ b/entproto/internal/entprototest/ent/messagewithints_create.go @@ -0,0 +1,222 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithints" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// MessageWithIntsCreate is the builder for creating a MessageWithInts entity. +type MessageWithIntsCreate struct { + config + mutation *MessageWithIntsMutation + hooks []Hook +} + +// SetInt32s sets the "int32s" field. +func (mwic *MessageWithIntsCreate) SetInt32s(i []int32) *MessageWithIntsCreate { + mwic.mutation.SetInt32s(i) + return mwic +} + +// SetInt64s sets the "int64s" field. +func (mwic *MessageWithIntsCreate) SetInt64s(i []int64) *MessageWithIntsCreate { + mwic.mutation.SetInt64s(i) + return mwic +} + +// SetUint32s sets the "uint32s" field. +func (mwic *MessageWithIntsCreate) SetUint32s(u []uint32) *MessageWithIntsCreate { + mwic.mutation.SetUint32s(u) + return mwic +} + +// SetUint64s sets the "uint64s" field. +func (mwic *MessageWithIntsCreate) SetUint64s(u []uint64) *MessageWithIntsCreate { + mwic.mutation.SetUint64s(u) + return mwic +} + +// Mutation returns the MessageWithIntsMutation object of the builder. +func (mwic *MessageWithIntsCreate) Mutation() *MessageWithIntsMutation { + return mwic.mutation +} + +// Save creates the MessageWithInts in the database. +func (mwic *MessageWithIntsCreate) Save(ctx context.Context) (*MessageWithInts, error) { + return withHooks(ctx, mwic.sqlSave, mwic.mutation, mwic.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (mwic *MessageWithIntsCreate) SaveX(ctx context.Context) *MessageWithInts { + v, err := mwic.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mwic *MessageWithIntsCreate) Exec(ctx context.Context) error { + _, err := mwic.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mwic *MessageWithIntsCreate) ExecX(ctx context.Context) { + if err := mwic.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (mwic *MessageWithIntsCreate) check() error { + if _, ok := mwic.mutation.Int32s(); !ok { + return &ValidationError{Name: "int32s", err: errors.New(`ent: missing required field "MessageWithInts.int32s"`)} + } + if _, ok := mwic.mutation.Int64s(); !ok { + return &ValidationError{Name: "int64s", err: errors.New(`ent: missing required field "MessageWithInts.int64s"`)} + } + if _, ok := mwic.mutation.Uint32s(); !ok { + return &ValidationError{Name: "uint32s", err: errors.New(`ent: missing required field "MessageWithInts.uint32s"`)} + } + if _, ok := mwic.mutation.Uint64s(); !ok { + return &ValidationError{Name: "uint64s", err: errors.New(`ent: missing required field "MessageWithInts.uint64s"`)} + } + return nil +} + +func (mwic *MessageWithIntsCreate) sqlSave(ctx context.Context) (*MessageWithInts, error) { + if err := mwic.check(); err != nil { + return nil, err + } + _node, _spec := mwic.createSpec() + if err := sqlgraph.CreateNode(ctx, mwic.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + mwic.mutation.id = &_node.ID + mwic.mutation.done = true + return _node, nil +} + +func (mwic *MessageWithIntsCreate) createSpec() (*MessageWithInts, *sqlgraph.CreateSpec) { + var ( + _node = &MessageWithInts{config: mwic.config} + _spec = sqlgraph.NewCreateSpec(messagewithints.Table, sqlgraph.NewFieldSpec(messagewithints.FieldID, field.TypeInt)) + ) + if value, ok := mwic.mutation.Int32s(); ok { + _spec.SetField(messagewithints.FieldInt32s, field.TypeJSON, value) + _node.Int32s = value + } + if value, ok := mwic.mutation.Int64s(); ok { + _spec.SetField(messagewithints.FieldInt64s, field.TypeJSON, value) + _node.Int64s = value + } + if value, ok := mwic.mutation.Uint32s(); ok { + _spec.SetField(messagewithints.FieldUint32s, field.TypeJSON, value) + _node.Uint32s = value + } + if value, ok := mwic.mutation.Uint64s(); ok { + _spec.SetField(messagewithints.FieldUint64s, field.TypeJSON, value) + _node.Uint64s = value + } + return _node, _spec +} + +// MessageWithIntsCreateBulk is the builder for creating many MessageWithInts entities in bulk. +type MessageWithIntsCreateBulk struct { + config + err error + builders []*MessageWithIntsCreate +} + +// Save creates the MessageWithInts entities in the database. +func (mwicb *MessageWithIntsCreateBulk) Save(ctx context.Context) ([]*MessageWithInts, error) { + if mwicb.err != nil { + return nil, mwicb.err + } + specs := make([]*sqlgraph.CreateSpec, len(mwicb.builders)) + nodes := make([]*MessageWithInts, len(mwicb.builders)) + mutators := make([]Mutator, len(mwicb.builders)) + for i := range mwicb.builders { + func(i int, root context.Context) { + builder := mwicb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*MessageWithIntsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, mwicb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, mwicb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, mwicb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (mwicb *MessageWithIntsCreateBulk) SaveX(ctx context.Context) []*MessageWithInts { + v, err := mwicb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (mwicb *MessageWithIntsCreateBulk) Exec(ctx context.Context) error { + _, err := mwicb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mwicb *MessageWithIntsCreateBulk) ExecX(ctx context.Context) { + if err := mwicb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/entproto/internal/entprototest/ent/messagewithints_delete.go b/entproto/internal/entprototest/ent/messagewithints_delete.go new file mode 100644 index 000000000..f3712eb51 --- /dev/null +++ b/entproto/internal/entprototest/ent/messagewithints_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithints" + "entgo.io/contrib/entproto/internal/entprototest/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// MessageWithIntsDelete is the builder for deleting a MessageWithInts entity. +type MessageWithIntsDelete struct { + config + hooks []Hook + mutation *MessageWithIntsMutation +} + +// Where appends a list predicates to the MessageWithIntsDelete builder. +func (mwid *MessageWithIntsDelete) Where(ps ...predicate.MessageWithInts) *MessageWithIntsDelete { + mwid.mutation.Where(ps...) + return mwid +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (mwid *MessageWithIntsDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, mwid.sqlExec, mwid.mutation, mwid.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (mwid *MessageWithIntsDelete) ExecX(ctx context.Context) int { + n, err := mwid.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (mwid *MessageWithIntsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(messagewithints.Table, sqlgraph.NewFieldSpec(messagewithints.FieldID, field.TypeInt)) + if ps := mwid.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, mwid.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + mwid.mutation.done = true + return affected, err +} + +// MessageWithIntsDeleteOne is the builder for deleting a single MessageWithInts entity. +type MessageWithIntsDeleteOne struct { + mwid *MessageWithIntsDelete +} + +// Where appends a list predicates to the MessageWithIntsDelete builder. +func (mwido *MessageWithIntsDeleteOne) Where(ps ...predicate.MessageWithInts) *MessageWithIntsDeleteOne { + mwido.mwid.mutation.Where(ps...) + return mwido +} + +// Exec executes the deletion query. +func (mwido *MessageWithIntsDeleteOne) Exec(ctx context.Context) error { + n, err := mwido.mwid.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{messagewithints.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (mwido *MessageWithIntsDeleteOne) ExecX(ctx context.Context) { + if err := mwido.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/entproto/internal/entprototest/ent/messagewithints_query.go b/entproto/internal/entprototest/ent/messagewithints_query.go new file mode 100644 index 000000000..74451e999 --- /dev/null +++ b/entproto/internal/entprototest/ent/messagewithints_query.go @@ -0,0 +1,526 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithints" + "entgo.io/contrib/entproto/internal/entprototest/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// MessageWithIntsQuery is the builder for querying MessageWithInts entities. +type MessageWithIntsQuery struct { + config + ctx *QueryContext + order []messagewithints.OrderOption + inters []Interceptor + predicates []predicate.MessageWithInts + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the MessageWithIntsQuery builder. +func (mwiq *MessageWithIntsQuery) Where(ps ...predicate.MessageWithInts) *MessageWithIntsQuery { + mwiq.predicates = append(mwiq.predicates, ps...) + return mwiq +} + +// Limit the number of records to be returned by this query. +func (mwiq *MessageWithIntsQuery) Limit(limit int) *MessageWithIntsQuery { + mwiq.ctx.Limit = &limit + return mwiq +} + +// Offset to start from. +func (mwiq *MessageWithIntsQuery) Offset(offset int) *MessageWithIntsQuery { + mwiq.ctx.Offset = &offset + return mwiq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (mwiq *MessageWithIntsQuery) Unique(unique bool) *MessageWithIntsQuery { + mwiq.ctx.Unique = &unique + return mwiq +} + +// Order specifies how the records should be ordered. +func (mwiq *MessageWithIntsQuery) Order(o ...messagewithints.OrderOption) *MessageWithIntsQuery { + mwiq.order = append(mwiq.order, o...) + return mwiq +} + +// First returns the first MessageWithInts entity from the query. +// Returns a *NotFoundError when no MessageWithInts was found. +func (mwiq *MessageWithIntsQuery) First(ctx context.Context) (*MessageWithInts, error) { + nodes, err := mwiq.Limit(1).All(setContextOp(ctx, mwiq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{messagewithints.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (mwiq *MessageWithIntsQuery) FirstX(ctx context.Context) *MessageWithInts { + node, err := mwiq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first MessageWithInts ID from the query. +// Returns a *NotFoundError when no MessageWithInts ID was found. +func (mwiq *MessageWithIntsQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = mwiq.Limit(1).IDs(setContextOp(ctx, mwiq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{messagewithints.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (mwiq *MessageWithIntsQuery) FirstIDX(ctx context.Context) int { + id, err := mwiq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single MessageWithInts entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one MessageWithInts entity is found. +// Returns a *NotFoundError when no MessageWithInts entities are found. +func (mwiq *MessageWithIntsQuery) Only(ctx context.Context) (*MessageWithInts, error) { + nodes, err := mwiq.Limit(2).All(setContextOp(ctx, mwiq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{messagewithints.Label} + default: + return nil, &NotSingularError{messagewithints.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (mwiq *MessageWithIntsQuery) OnlyX(ctx context.Context) *MessageWithInts { + node, err := mwiq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only MessageWithInts ID in the query. +// Returns a *NotSingularError when more than one MessageWithInts ID is found. +// Returns a *NotFoundError when no entities are found. +func (mwiq *MessageWithIntsQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = mwiq.Limit(2).IDs(setContextOp(ctx, mwiq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{messagewithints.Label} + default: + err = &NotSingularError{messagewithints.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (mwiq *MessageWithIntsQuery) OnlyIDX(ctx context.Context) int { + id, err := mwiq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of MessageWithIntsSlice. +func (mwiq *MessageWithIntsQuery) All(ctx context.Context) ([]*MessageWithInts, error) { + ctx = setContextOp(ctx, mwiq.ctx, "All") + if err := mwiq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*MessageWithInts, *MessageWithIntsQuery]() + return withInterceptors[[]*MessageWithInts](ctx, mwiq, qr, mwiq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (mwiq *MessageWithIntsQuery) AllX(ctx context.Context) []*MessageWithInts { + nodes, err := mwiq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of MessageWithInts IDs. +func (mwiq *MessageWithIntsQuery) IDs(ctx context.Context) (ids []int, err error) { + if mwiq.ctx.Unique == nil && mwiq.path != nil { + mwiq.Unique(true) + } + ctx = setContextOp(ctx, mwiq.ctx, "IDs") + if err = mwiq.Select(messagewithints.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (mwiq *MessageWithIntsQuery) IDsX(ctx context.Context) []int { + ids, err := mwiq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (mwiq *MessageWithIntsQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, mwiq.ctx, "Count") + if err := mwiq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, mwiq, querierCount[*MessageWithIntsQuery](), mwiq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (mwiq *MessageWithIntsQuery) CountX(ctx context.Context) int { + count, err := mwiq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (mwiq *MessageWithIntsQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, mwiq.ctx, "Exist") + switch _, err := mwiq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (mwiq *MessageWithIntsQuery) ExistX(ctx context.Context) bool { + exist, err := mwiq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the MessageWithIntsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (mwiq *MessageWithIntsQuery) Clone() *MessageWithIntsQuery { + if mwiq == nil { + return nil + } + return &MessageWithIntsQuery{ + config: mwiq.config, + ctx: mwiq.ctx.Clone(), + order: append([]messagewithints.OrderOption{}, mwiq.order...), + inters: append([]Interceptor{}, mwiq.inters...), + predicates: append([]predicate.MessageWithInts{}, mwiq.predicates...), + // clone intermediate query. + sql: mwiq.sql.Clone(), + path: mwiq.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Int32s []int32 `json:"int32s,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.MessageWithInts.Query(). +// GroupBy(messagewithints.FieldInt32s). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (mwiq *MessageWithIntsQuery) GroupBy(field string, fields ...string) *MessageWithIntsGroupBy { + mwiq.ctx.Fields = append([]string{field}, fields...) + grbuild := &MessageWithIntsGroupBy{build: mwiq} + grbuild.flds = &mwiq.ctx.Fields + grbuild.label = messagewithints.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Int32s []int32 `json:"int32s,omitempty"` +// } +// +// client.MessageWithInts.Query(). +// Select(messagewithints.FieldInt32s). +// Scan(ctx, &v) +func (mwiq *MessageWithIntsQuery) Select(fields ...string) *MessageWithIntsSelect { + mwiq.ctx.Fields = append(mwiq.ctx.Fields, fields...) + sbuild := &MessageWithIntsSelect{MessageWithIntsQuery: mwiq} + sbuild.label = messagewithints.Label + sbuild.flds, sbuild.scan = &mwiq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a MessageWithIntsSelect configured with the given aggregations. +func (mwiq *MessageWithIntsQuery) Aggregate(fns ...AggregateFunc) *MessageWithIntsSelect { + return mwiq.Select().Aggregate(fns...) +} + +func (mwiq *MessageWithIntsQuery) prepareQuery(ctx context.Context) error { + for _, inter := range mwiq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, mwiq); err != nil { + return err + } + } + } + for _, f := range mwiq.ctx.Fields { + if !messagewithints.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if mwiq.path != nil { + prev, err := mwiq.path(ctx) + if err != nil { + return err + } + mwiq.sql = prev + } + return nil +} + +func (mwiq *MessageWithIntsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*MessageWithInts, error) { + var ( + nodes = []*MessageWithInts{} + _spec = mwiq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*MessageWithInts).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &MessageWithInts{config: mwiq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, mwiq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (mwiq *MessageWithIntsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := mwiq.querySpec() + _spec.Node.Columns = mwiq.ctx.Fields + if len(mwiq.ctx.Fields) > 0 { + _spec.Unique = mwiq.ctx.Unique != nil && *mwiq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, mwiq.driver, _spec) +} + +func (mwiq *MessageWithIntsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(messagewithints.Table, messagewithints.Columns, sqlgraph.NewFieldSpec(messagewithints.FieldID, field.TypeInt)) + _spec.From = mwiq.sql + if unique := mwiq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if mwiq.path != nil { + _spec.Unique = true + } + if fields := mwiq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, messagewithints.FieldID) + for i := range fields { + if fields[i] != messagewithints.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := mwiq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := mwiq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := mwiq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := mwiq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (mwiq *MessageWithIntsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(mwiq.driver.Dialect()) + t1 := builder.Table(messagewithints.Table) + columns := mwiq.ctx.Fields + if len(columns) == 0 { + columns = messagewithints.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if mwiq.sql != nil { + selector = mwiq.sql + selector.Select(selector.Columns(columns...)...) + } + if mwiq.ctx.Unique != nil && *mwiq.ctx.Unique { + selector.Distinct() + } + for _, p := range mwiq.predicates { + p(selector) + } + for _, p := range mwiq.order { + p(selector) + } + if offset := mwiq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := mwiq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// MessageWithIntsGroupBy is the group-by builder for MessageWithInts entities. +type MessageWithIntsGroupBy struct { + selector + build *MessageWithIntsQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (mwigb *MessageWithIntsGroupBy) Aggregate(fns ...AggregateFunc) *MessageWithIntsGroupBy { + mwigb.fns = append(mwigb.fns, fns...) + return mwigb +} + +// Scan applies the selector query and scans the result into the given value. +func (mwigb *MessageWithIntsGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mwigb.build.ctx, "GroupBy") + if err := mwigb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*MessageWithIntsQuery, *MessageWithIntsGroupBy](ctx, mwigb.build, mwigb, mwigb.build.inters, v) +} + +func (mwigb *MessageWithIntsGroupBy) sqlScan(ctx context.Context, root *MessageWithIntsQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(mwigb.fns)) + for _, fn := range mwigb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mwigb.flds)+len(mwigb.fns)) + for _, f := range *mwigb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mwigb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mwigb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// MessageWithIntsSelect is the builder for selecting fields of MessageWithInts entities. +type MessageWithIntsSelect struct { + *MessageWithIntsQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (mwis *MessageWithIntsSelect) Aggregate(fns ...AggregateFunc) *MessageWithIntsSelect { + mwis.fns = append(mwis.fns, fns...) + return mwis +} + +// Scan applies the selector query and scans the result into the given value. +func (mwis *MessageWithIntsSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, mwis.ctx, "Select") + if err := mwis.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*MessageWithIntsQuery, *MessageWithIntsSelect](ctx, mwis.MessageWithIntsQuery, mwis, mwis.inters, v) +} + +func (mwis *MessageWithIntsSelect) sqlScan(ctx context.Context, root *MessageWithIntsQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(mwis.fns)) + for _, fn := range mwis.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*mwis.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := mwis.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/entproto/internal/entprototest/ent/messagewithints_update.go b/entproto/internal/entprototest/ent/messagewithints_update.go new file mode 100644 index 000000000..1342956cd --- /dev/null +++ b/entproto/internal/entprototest/ent/messagewithints_update.go @@ -0,0 +1,336 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithints" + "entgo.io/contrib/entproto/internal/entprototest/ent/predicate" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" + "entgo.io/ent/schema/field" +) + +// MessageWithIntsUpdate is the builder for updating MessageWithInts entities. +type MessageWithIntsUpdate struct { + config + hooks []Hook + mutation *MessageWithIntsMutation +} + +// Where appends a list predicates to the MessageWithIntsUpdate builder. +func (mwiu *MessageWithIntsUpdate) Where(ps ...predicate.MessageWithInts) *MessageWithIntsUpdate { + mwiu.mutation.Where(ps...) + return mwiu +} + +// SetInt32s sets the "int32s" field. +func (mwiu *MessageWithIntsUpdate) SetInt32s(i []int32) *MessageWithIntsUpdate { + mwiu.mutation.SetInt32s(i) + return mwiu +} + +// AppendInt32s appends i to the "int32s" field. +func (mwiu *MessageWithIntsUpdate) AppendInt32s(i []int32) *MessageWithIntsUpdate { + mwiu.mutation.AppendInt32s(i) + return mwiu +} + +// SetInt64s sets the "int64s" field. +func (mwiu *MessageWithIntsUpdate) SetInt64s(i []int64) *MessageWithIntsUpdate { + mwiu.mutation.SetInt64s(i) + return mwiu +} + +// AppendInt64s appends i to the "int64s" field. +func (mwiu *MessageWithIntsUpdate) AppendInt64s(i []int64) *MessageWithIntsUpdate { + mwiu.mutation.AppendInt64s(i) + return mwiu +} + +// SetUint32s sets the "uint32s" field. +func (mwiu *MessageWithIntsUpdate) SetUint32s(u []uint32) *MessageWithIntsUpdate { + mwiu.mutation.SetUint32s(u) + return mwiu +} + +// AppendUint32s appends u to the "uint32s" field. +func (mwiu *MessageWithIntsUpdate) AppendUint32s(u []uint32) *MessageWithIntsUpdate { + mwiu.mutation.AppendUint32s(u) + return mwiu +} + +// SetUint64s sets the "uint64s" field. +func (mwiu *MessageWithIntsUpdate) SetUint64s(u []uint64) *MessageWithIntsUpdate { + mwiu.mutation.SetUint64s(u) + return mwiu +} + +// AppendUint64s appends u to the "uint64s" field. +func (mwiu *MessageWithIntsUpdate) AppendUint64s(u []uint64) *MessageWithIntsUpdate { + mwiu.mutation.AppendUint64s(u) + return mwiu +} + +// Mutation returns the MessageWithIntsMutation object of the builder. +func (mwiu *MessageWithIntsUpdate) Mutation() *MessageWithIntsMutation { + return mwiu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (mwiu *MessageWithIntsUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, mwiu.sqlSave, mwiu.mutation, mwiu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mwiu *MessageWithIntsUpdate) SaveX(ctx context.Context) int { + affected, err := mwiu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (mwiu *MessageWithIntsUpdate) Exec(ctx context.Context) error { + _, err := mwiu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mwiu *MessageWithIntsUpdate) ExecX(ctx context.Context) { + if err := mwiu.Exec(ctx); err != nil { + panic(err) + } +} + +func (mwiu *MessageWithIntsUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(messagewithints.Table, messagewithints.Columns, sqlgraph.NewFieldSpec(messagewithints.FieldID, field.TypeInt)) + if ps := mwiu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mwiu.mutation.Int32s(); ok { + _spec.SetField(messagewithints.FieldInt32s, field.TypeJSON, value) + } + if value, ok := mwiu.mutation.AppendedInt32s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, messagewithints.FieldInt32s, value) + }) + } + if value, ok := mwiu.mutation.Int64s(); ok { + _spec.SetField(messagewithints.FieldInt64s, field.TypeJSON, value) + } + if value, ok := mwiu.mutation.AppendedInt64s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, messagewithints.FieldInt64s, value) + }) + } + if value, ok := mwiu.mutation.Uint32s(); ok { + _spec.SetField(messagewithints.FieldUint32s, field.TypeJSON, value) + } + if value, ok := mwiu.mutation.AppendedUint32s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, messagewithints.FieldUint32s, value) + }) + } + if value, ok := mwiu.mutation.Uint64s(); ok { + _spec.SetField(messagewithints.FieldUint64s, field.TypeJSON, value) + } + if value, ok := mwiu.mutation.AppendedUint64s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, messagewithints.FieldUint64s, value) + }) + } + if n, err = sqlgraph.UpdateNodes(ctx, mwiu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{messagewithints.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + mwiu.mutation.done = true + return n, nil +} + +// MessageWithIntsUpdateOne is the builder for updating a single MessageWithInts entity. +type MessageWithIntsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *MessageWithIntsMutation +} + +// SetInt32s sets the "int32s" field. +func (mwiuo *MessageWithIntsUpdateOne) SetInt32s(i []int32) *MessageWithIntsUpdateOne { + mwiuo.mutation.SetInt32s(i) + return mwiuo +} + +// AppendInt32s appends i to the "int32s" field. +func (mwiuo *MessageWithIntsUpdateOne) AppendInt32s(i []int32) *MessageWithIntsUpdateOne { + mwiuo.mutation.AppendInt32s(i) + return mwiuo +} + +// SetInt64s sets the "int64s" field. +func (mwiuo *MessageWithIntsUpdateOne) SetInt64s(i []int64) *MessageWithIntsUpdateOne { + mwiuo.mutation.SetInt64s(i) + return mwiuo +} + +// AppendInt64s appends i to the "int64s" field. +func (mwiuo *MessageWithIntsUpdateOne) AppendInt64s(i []int64) *MessageWithIntsUpdateOne { + mwiuo.mutation.AppendInt64s(i) + return mwiuo +} + +// SetUint32s sets the "uint32s" field. +func (mwiuo *MessageWithIntsUpdateOne) SetUint32s(u []uint32) *MessageWithIntsUpdateOne { + mwiuo.mutation.SetUint32s(u) + return mwiuo +} + +// AppendUint32s appends u to the "uint32s" field. +func (mwiuo *MessageWithIntsUpdateOne) AppendUint32s(u []uint32) *MessageWithIntsUpdateOne { + mwiuo.mutation.AppendUint32s(u) + return mwiuo +} + +// SetUint64s sets the "uint64s" field. +func (mwiuo *MessageWithIntsUpdateOne) SetUint64s(u []uint64) *MessageWithIntsUpdateOne { + mwiuo.mutation.SetUint64s(u) + return mwiuo +} + +// AppendUint64s appends u to the "uint64s" field. +func (mwiuo *MessageWithIntsUpdateOne) AppendUint64s(u []uint64) *MessageWithIntsUpdateOne { + mwiuo.mutation.AppendUint64s(u) + return mwiuo +} + +// Mutation returns the MessageWithIntsMutation object of the builder. +func (mwiuo *MessageWithIntsUpdateOne) Mutation() *MessageWithIntsMutation { + return mwiuo.mutation +} + +// Where appends a list predicates to the MessageWithIntsUpdate builder. +func (mwiuo *MessageWithIntsUpdateOne) Where(ps ...predicate.MessageWithInts) *MessageWithIntsUpdateOne { + mwiuo.mutation.Where(ps...) + return mwiuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (mwiuo *MessageWithIntsUpdateOne) Select(field string, fields ...string) *MessageWithIntsUpdateOne { + mwiuo.fields = append([]string{field}, fields...) + return mwiuo +} + +// Save executes the query and returns the updated MessageWithInts entity. +func (mwiuo *MessageWithIntsUpdateOne) Save(ctx context.Context) (*MessageWithInts, error) { + return withHooks(ctx, mwiuo.sqlSave, mwiuo.mutation, mwiuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (mwiuo *MessageWithIntsUpdateOne) SaveX(ctx context.Context) *MessageWithInts { + node, err := mwiuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (mwiuo *MessageWithIntsUpdateOne) Exec(ctx context.Context) error { + _, err := mwiuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (mwiuo *MessageWithIntsUpdateOne) ExecX(ctx context.Context) { + if err := mwiuo.Exec(ctx); err != nil { + panic(err) + } +} + +func (mwiuo *MessageWithIntsUpdateOne) sqlSave(ctx context.Context) (_node *MessageWithInts, err error) { + _spec := sqlgraph.NewUpdateSpec(messagewithints.Table, messagewithints.Columns, sqlgraph.NewFieldSpec(messagewithints.FieldID, field.TypeInt)) + id, ok := mwiuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "MessageWithInts.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := mwiuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, messagewithints.FieldID) + for _, f := range fields { + if !messagewithints.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != messagewithints.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := mwiuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := mwiuo.mutation.Int32s(); ok { + _spec.SetField(messagewithints.FieldInt32s, field.TypeJSON, value) + } + if value, ok := mwiuo.mutation.AppendedInt32s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, messagewithints.FieldInt32s, value) + }) + } + if value, ok := mwiuo.mutation.Int64s(); ok { + _spec.SetField(messagewithints.FieldInt64s, field.TypeJSON, value) + } + if value, ok := mwiuo.mutation.AppendedInt64s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, messagewithints.FieldInt64s, value) + }) + } + if value, ok := mwiuo.mutation.Uint32s(); ok { + _spec.SetField(messagewithints.FieldUint32s, field.TypeJSON, value) + } + if value, ok := mwiuo.mutation.AppendedUint32s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, messagewithints.FieldUint32s, value) + }) + } + if value, ok := mwiuo.mutation.Uint64s(); ok { + _spec.SetField(messagewithints.FieldUint64s, field.TypeJSON, value) + } + if value, ok := mwiuo.mutation.AppendedUint64s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, messagewithints.FieldUint64s, value) + }) + } + _node = &MessageWithInts{config: mwiuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, mwiuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{messagewithints.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + mwiuo.mutation.done = true + return _node, nil +} diff --git a/entproto/internal/entprototest/ent/messagewithoptionals/where.go b/entproto/internal/entprototest/ent/messagewithoptionals/where.go index f60bd10ea..06bc6308c 100644 --- a/entproto/internal/entprototest/ent/messagewithoptionals/where.go +++ b/entproto/internal/entprototest/ent/messagewithoptionals/where.go @@ -492,32 +492,15 @@ func TimeOptionalNotNil() predicate.MessageWithOptionals { // And groups predicates with the AND operator between them. func And(predicates ...predicate.MessageWithOptionals) predicate.MessageWithOptionals { - return predicate.MessageWithOptionals(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithOptionals(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MessageWithOptionals) predicate.MessageWithOptionals { - return predicate.MessageWithOptionals(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithOptionals(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MessageWithOptionals) predicate.MessageWithOptionals { - return predicate.MessageWithOptionals(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MessageWithOptionals(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/messagewithoptionals_create.go b/entproto/internal/entprototest/ent/messagewithoptionals_create.go index acb80a74a..95aa60c2b 100644 --- a/entproto/internal/entprototest/ent/messagewithoptionals_create.go +++ b/entproto/internal/entprototest/ent/messagewithoptionals_create.go @@ -131,7 +131,7 @@ func (mwoc *MessageWithOptionalsCreate) Mutation() *MessageWithOptionalsMutation // Save creates the MessageWithOptionals in the database. func (mwoc *MessageWithOptionalsCreate) Save(ctx context.Context) (*MessageWithOptionals, error) { - return withHooks[*MessageWithOptionals, MessageWithOptionalsMutation](ctx, mwoc.sqlSave, mwoc.mutation, mwoc.hooks) + return withHooks(ctx, mwoc.sqlSave, mwoc.mutation, mwoc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -222,11 +222,15 @@ func (mwoc *MessageWithOptionalsCreate) createSpec() (*MessageWithOptionals, *sq // MessageWithOptionalsCreateBulk is the builder for creating many MessageWithOptionals entities in bulk. type MessageWithOptionalsCreateBulk struct { config + err error builders []*MessageWithOptionalsCreate } // Save creates the MessageWithOptionals entities in the database. func (mwocb *MessageWithOptionalsCreateBulk) Save(ctx context.Context) ([]*MessageWithOptionals, error) { + if mwocb.err != nil { + return nil, mwocb.err + } specs := make([]*sqlgraph.CreateSpec, len(mwocb.builders)) nodes := make([]*MessageWithOptionals, len(mwocb.builders)) mutators := make([]Mutator, len(mwocb.builders)) diff --git a/entproto/internal/entprototest/ent/messagewithoptionals_delete.go b/entproto/internal/entprototest/ent/messagewithoptionals_delete.go index 0e1243f96..910032090 100644 --- a/entproto/internal/entprototest/ent/messagewithoptionals_delete.go +++ b/entproto/internal/entprototest/ent/messagewithoptionals_delete.go @@ -27,7 +27,7 @@ func (mwod *MessageWithOptionalsDelete) Where(ps ...predicate.MessageWithOptiona // Exec executes the deletion query and returns how many vertices were deleted. func (mwod *MessageWithOptionalsDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MessageWithOptionalsMutation](ctx, mwod.sqlExec, mwod.mutation, mwod.hooks) + return withHooks(ctx, mwod.sqlExec, mwod.mutation, mwod.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithoptionals_update.go b/entproto/internal/entprototest/ent/messagewithoptionals_update.go index 834acab35..582d06102 100644 --- a/entproto/internal/entprototest/ent/messagewithoptionals_update.go +++ b/entproto/internal/entprototest/ent/messagewithoptionals_update.go @@ -209,7 +209,7 @@ func (mwou *MessageWithOptionalsUpdate) Mutation() *MessageWithOptionalsMutation // Save executes the query and returns the number of nodes affected by the update operation. func (mwou *MessageWithOptionalsUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MessageWithOptionalsMutation](ctx, mwou.sqlSave, mwou.mutation, mwou.hooks) + return withHooks(ctx, mwou.sqlSave, mwou.mutation, mwou.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -513,7 +513,7 @@ func (mwouo *MessageWithOptionalsUpdateOne) Select(field string, fields ...strin // Save executes the query and returns the updated MessageWithOptionals entity. func (mwouo *MessageWithOptionalsUpdateOne) Save(ctx context.Context) (*MessageWithOptionals, error) { - return withHooks[*MessageWithOptionals, MessageWithOptionalsMutation](ctx, mwouo.sqlSave, mwouo.mutation, mwouo.hooks) + return withHooks(ctx, mwouo.sqlSave, mwouo.mutation, mwouo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithpackagename/where.go b/entproto/internal/entprototest/ent/messagewithpackagename/where.go index 57c409aae..bf8a0019a 100644 --- a/entproto/internal/entprototest/ent/messagewithpackagename/where.go +++ b/entproto/internal/entprototest/ent/messagewithpackagename/where.go @@ -124,32 +124,15 @@ func NameContainsFold(v string) predicate.MessageWithPackageName { // And groups predicates with the AND operator between them. func And(predicates ...predicate.MessageWithPackageName) predicate.MessageWithPackageName { - return predicate.MessageWithPackageName(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithPackageName(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MessageWithPackageName) predicate.MessageWithPackageName { - return predicate.MessageWithPackageName(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithPackageName(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MessageWithPackageName) predicate.MessageWithPackageName { - return predicate.MessageWithPackageName(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MessageWithPackageName(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/messagewithpackagename_create.go b/entproto/internal/entprototest/ent/messagewithpackagename_create.go index 2d4242f7e..c6b927882 100644 --- a/entproto/internal/entprototest/ent/messagewithpackagename_create.go +++ b/entproto/internal/entprototest/ent/messagewithpackagename_create.go @@ -32,7 +32,7 @@ func (mwpnc *MessageWithPackageNameCreate) Mutation() *MessageWithPackageNameMut // Save creates the MessageWithPackageName in the database. func (mwpnc *MessageWithPackageNameCreate) Save(ctx context.Context) (*MessageWithPackageName, error) { - return withHooks[*MessageWithPackageName, MessageWithPackageNameMutation](ctx, mwpnc.sqlSave, mwpnc.mutation, mwpnc.hooks) + return withHooks(ctx, mwpnc.sqlSave, mwpnc.mutation, mwpnc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -98,11 +98,15 @@ func (mwpnc *MessageWithPackageNameCreate) createSpec() (*MessageWithPackageName // MessageWithPackageNameCreateBulk is the builder for creating many MessageWithPackageName entities in bulk. type MessageWithPackageNameCreateBulk struct { config + err error builders []*MessageWithPackageNameCreate } // Save creates the MessageWithPackageName entities in the database. func (mwpncb *MessageWithPackageNameCreateBulk) Save(ctx context.Context) ([]*MessageWithPackageName, error) { + if mwpncb.err != nil { + return nil, mwpncb.err + } specs := make([]*sqlgraph.CreateSpec, len(mwpncb.builders)) nodes := make([]*MessageWithPackageName, len(mwpncb.builders)) mutators := make([]Mutator, len(mwpncb.builders)) diff --git a/entproto/internal/entprototest/ent/messagewithpackagename_delete.go b/entproto/internal/entprototest/ent/messagewithpackagename_delete.go index a32d1119c..2a2c2e0d1 100644 --- a/entproto/internal/entprototest/ent/messagewithpackagename_delete.go +++ b/entproto/internal/entprototest/ent/messagewithpackagename_delete.go @@ -27,7 +27,7 @@ func (mwpnd *MessageWithPackageNameDelete) Where(ps ...predicate.MessageWithPack // Exec executes the deletion query and returns how many vertices were deleted. func (mwpnd *MessageWithPackageNameDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MessageWithPackageNameMutation](ctx, mwpnd.sqlExec, mwpnd.mutation, mwpnd.hooks) + return withHooks(ctx, mwpnd.sqlExec, mwpnd.mutation, mwpnd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithpackagename_update.go b/entproto/internal/entprototest/ent/messagewithpackagename_update.go index f2dc00e0c..e9bcd47ed 100644 --- a/entproto/internal/entprototest/ent/messagewithpackagename_update.go +++ b/entproto/internal/entprototest/ent/messagewithpackagename_update.go @@ -33,6 +33,14 @@ func (mwpnu *MessageWithPackageNameUpdate) SetName(s string) *MessageWithPackage return mwpnu } +// SetNillableName sets the "name" field if the given value is not nil. +func (mwpnu *MessageWithPackageNameUpdate) SetNillableName(s *string) *MessageWithPackageNameUpdate { + if s != nil { + mwpnu.SetName(*s) + } + return mwpnu +} + // Mutation returns the MessageWithPackageNameMutation object of the builder. func (mwpnu *MessageWithPackageNameUpdate) Mutation() *MessageWithPackageNameMutation { return mwpnu.mutation @@ -40,7 +48,7 @@ func (mwpnu *MessageWithPackageNameUpdate) Mutation() *MessageWithPackageNameMut // Save executes the query and returns the number of nodes affected by the update operation. func (mwpnu *MessageWithPackageNameUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MessageWithPackageNameMutation](ctx, mwpnu.sqlSave, mwpnu.mutation, mwpnu.hooks) + return withHooks(ctx, mwpnu.sqlSave, mwpnu.mutation, mwpnu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -103,6 +111,14 @@ func (mwpnuo *MessageWithPackageNameUpdateOne) SetName(s string) *MessageWithPac return mwpnuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (mwpnuo *MessageWithPackageNameUpdateOne) SetNillableName(s *string) *MessageWithPackageNameUpdateOne { + if s != nil { + mwpnuo.SetName(*s) + } + return mwpnuo +} + // Mutation returns the MessageWithPackageNameMutation object of the builder. func (mwpnuo *MessageWithPackageNameUpdateOne) Mutation() *MessageWithPackageNameMutation { return mwpnuo.mutation @@ -123,7 +139,7 @@ func (mwpnuo *MessageWithPackageNameUpdateOne) Select(field string, fields ...st // Save executes the query and returns the updated MessageWithPackageName entity. func (mwpnuo *MessageWithPackageNameUpdateOne) Save(ctx context.Context) (*MessageWithPackageName, error) { - return withHooks[*MessageWithPackageName, MessageWithPackageNameMutation](ctx, mwpnuo.sqlSave, mwpnuo.mutation, mwpnuo.hooks) + return withHooks(ctx, mwpnuo.sqlSave, mwpnuo.mutation, mwpnuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithstrings/where.go b/entproto/internal/entprototest/ent/messagewithstrings/where.go index cc9459360..fc4b392b9 100644 --- a/entproto/internal/entprototest/ent/messagewithstrings/where.go +++ b/entproto/internal/entprototest/ent/messagewithstrings/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.MessageWithStrings { // And groups predicates with the AND operator between them. func And(predicates ...predicate.MessageWithStrings) predicate.MessageWithStrings { - return predicate.MessageWithStrings(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithStrings(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MessageWithStrings) predicate.MessageWithStrings { - return predicate.MessageWithStrings(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MessageWithStrings(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MessageWithStrings) predicate.MessageWithStrings { - return predicate.MessageWithStrings(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MessageWithStrings(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/messagewithstrings_create.go b/entproto/internal/entprototest/ent/messagewithstrings_create.go index 55478d063..8610c912b 100644 --- a/entproto/internal/entprototest/ent/messagewithstrings_create.go +++ b/entproto/internal/entprototest/ent/messagewithstrings_create.go @@ -32,7 +32,7 @@ func (mwsc *MessageWithStringsCreate) Mutation() *MessageWithStringsMutation { // Save creates the MessageWithStrings in the database. func (mwsc *MessageWithStringsCreate) Save(ctx context.Context) (*MessageWithStrings, error) { - return withHooks[*MessageWithStrings, MessageWithStringsMutation](ctx, mwsc.sqlSave, mwsc.mutation, mwsc.hooks) + return withHooks(ctx, mwsc.sqlSave, mwsc.mutation, mwsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -98,11 +98,15 @@ func (mwsc *MessageWithStringsCreate) createSpec() (*MessageWithStrings, *sqlgra // MessageWithStringsCreateBulk is the builder for creating many MessageWithStrings entities in bulk. type MessageWithStringsCreateBulk struct { config + err error builders []*MessageWithStringsCreate } // Save creates the MessageWithStrings entities in the database. func (mwscb *MessageWithStringsCreateBulk) Save(ctx context.Context) ([]*MessageWithStrings, error) { + if mwscb.err != nil { + return nil, mwscb.err + } specs := make([]*sqlgraph.CreateSpec, len(mwscb.builders)) nodes := make([]*MessageWithStrings, len(mwscb.builders)) mutators := make([]Mutator, len(mwscb.builders)) diff --git a/entproto/internal/entprototest/ent/messagewithstrings_delete.go b/entproto/internal/entprototest/ent/messagewithstrings_delete.go index 61b86b3d4..d5c037220 100644 --- a/entproto/internal/entprototest/ent/messagewithstrings_delete.go +++ b/entproto/internal/entprototest/ent/messagewithstrings_delete.go @@ -27,7 +27,7 @@ func (mwsd *MessageWithStringsDelete) Where(ps ...predicate.MessageWithStrings) // Exec executes the deletion query and returns how many vertices were deleted. func (mwsd *MessageWithStringsDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MessageWithStringsMutation](ctx, mwsd.sqlExec, mwsd.mutation, mwsd.hooks) + return withHooks(ctx, mwsd.sqlExec, mwsd.mutation, mwsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/messagewithstrings_update.go b/entproto/internal/entprototest/ent/messagewithstrings_update.go index 5f4010599..117e631fc 100644 --- a/entproto/internal/entprototest/ent/messagewithstrings_update.go +++ b/entproto/internal/entprototest/ent/messagewithstrings_update.go @@ -47,7 +47,7 @@ func (mwsu *MessageWithStringsUpdate) Mutation() *MessageWithStringsMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (mwsu *MessageWithStringsUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MessageWithStringsMutation](ctx, mwsu.sqlSave, mwsu.mutation, mwsu.hooks) + return withHooks(ctx, mwsu.sqlSave, mwsu.mutation, mwsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -141,7 +141,7 @@ func (mwsuo *MessageWithStringsUpdateOne) Select(field string, fields ...string) // Save executes the query and returns the updated MessageWithStrings entity. func (mwsuo *MessageWithStringsUpdateOne) Save(ctx context.Context) (*MessageWithStrings, error) { - return withHooks[*MessageWithStrings, MessageWithStringsMutation](ctx, mwsuo.sqlSave, mwsuo.mutation, mwsuo.hooks) + return withHooks(ctx, mwsuo.sqlSave, mwsuo.mutation, mwsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/migrate/schema.go b/entproto/internal/entprototest/ent/migrate/schema.go index 0db4ec2b1..a63ede3c4 100644 --- a/entproto/internal/entprototest/ent/migrate/schema.go +++ b/entproto/internal/entprototest/ent/migrate/schema.go @@ -75,6 +75,17 @@ var ( Columns: DuplicateNumberMessagesColumns, PrimaryKey: []*schema.Column{DuplicateNumberMessagesColumns[0]}, } + // EnumWithConflictingValuesColumns holds the columns for the "enum_with_conflicting_values" table. + EnumWithConflictingValuesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "enum", Type: field.TypeEnum, Enums: []string{"image/jpeg", "IMAGE_JPEG"}}, + } + // EnumWithConflictingValuesTable holds the schema information for the "enum_with_conflicting_values" table. + EnumWithConflictingValuesTable = &schema.Table{ + Name: "enum_with_conflicting_values", + Columns: EnumWithConflictingValuesColumns, + PrimaryKey: []*schema.Column{EnumWithConflictingValuesColumns[0]}, + } // ExplicitSkippedMessagesColumns holds the columns for the "explicit_skipped_messages" table. ExplicitSkippedMessagesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -140,6 +151,7 @@ var ( {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "enum_type", Type: field.TypeEnum, Enums: []string{"pending", "active", "suspended", "deleted"}, Default: "pending"}, {Name: "enum_without_default", Type: field.TypeEnum, Enums: []string{"first", "second"}}, + {Name: "enum_with_special_characters", Type: field.TypeEnum, Enums: []string{"image/jpeg", "image/png"}}, } // MessageWithEnumsTable holds the schema information for the "message_with_enums" table. MessageWithEnumsTable = &schema.Table{ @@ -168,6 +180,20 @@ var ( Columns: MessageWithIdsColumns, PrimaryKey: []*schema.Column{MessageWithIdsColumns[0]}, } + // MessageWithIntsColumns holds the columns for the "message_with_ints" table. + MessageWithIntsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "int32s", Type: field.TypeJSON}, + {Name: "int64s", Type: field.TypeJSON}, + {Name: "uint32s", Type: field.TypeJSON}, + {Name: "uint64s", Type: field.TypeJSON}, + } + // MessageWithIntsTable holds the schema information for the "message_with_ints" table. + MessageWithIntsTable = &schema.Table{ + Name: "message_with_ints", + Columns: MessageWithIntsColumns, + PrimaryKey: []*schema.Column{MessageWithIntsColumns[0]}, + } // MessageWithOptionalsColumns holds the columns for the "message_with_optionals" table. MessageWithOptionalsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -347,6 +373,7 @@ var ( CategoriesTable, DependsOnSkippedsTable, DuplicateNumberMessagesTable, + EnumWithConflictingValuesTable, ExplicitSkippedMessagesTable, ImagesTable, ImplicitSkippedMessagesTable, @@ -354,6 +381,7 @@ var ( MessageWithEnumsTable, MessageWithFieldOnesTable, MessageWithIdsTable, + MessageWithIntsTable, MessageWithOptionalsTable, MessageWithPackageNamesTable, MessageWithStringsTable, diff --git a/entproto/internal/entprototest/ent/mutation.go b/entproto/internal/entprototest/ent/mutation.go index 55475468a..1d5a89ff0 100644 --- a/entproto/internal/entprototest/ent/mutation.go +++ b/entproto/internal/entprototest/ent/mutation.go @@ -13,10 +13,12 @@ import ( "entgo.io/contrib/entproto/internal/entprototest/ent/category" "entgo.io/contrib/entproto/internal/entprototest/ent/dependsonskipped" "entgo.io/contrib/entproto/internal/entprototest/ent/duplicatenumbermessage" + "entgo.io/contrib/entproto/internal/entprototest/ent/enumwithconflictingvalue" "entgo.io/contrib/entproto/internal/entprototest/ent/image" "entgo.io/contrib/entproto/internal/entprototest/ent/invalidfieldmessage" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithenum" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithfieldone" + "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithints" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithoptionals" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithpackagename" "entgo.io/contrib/entproto/internal/entprototest/ent/messagewithstrings" @@ -41,28 +43,30 @@ const ( OpUpdateOne = ent.OpUpdateOne // Node types. - TypeAllMethodsService = "AllMethodsService" - TypeBlogPost = "BlogPost" - TypeCategory = "Category" - TypeDependsOnSkipped = "DependsOnSkipped" - TypeDuplicateNumberMessage = "DuplicateNumberMessage" - TypeExplicitSkippedMessage = "ExplicitSkippedMessage" - TypeImage = "Image" - TypeImplicitSkippedMessage = "ImplicitSkippedMessage" - TypeInvalidFieldMessage = "InvalidFieldMessage" - TypeMessageWithEnum = "MessageWithEnum" - TypeMessageWithFieldOne = "MessageWithFieldOne" - TypeMessageWithID = "MessageWithID" - TypeMessageWithOptionals = "MessageWithOptionals" - TypeMessageWithPackageName = "MessageWithPackageName" - TypeMessageWithStrings = "MessageWithStrings" - TypeNoBackref = "NoBackref" - TypeOneMethodService = "OneMethodService" - TypePortal = "Portal" - TypeSkipEdgeExample = "SkipEdgeExample" - TypeTwoMethodService = "TwoMethodService" - TypeUser = "User" - TypeValidMessage = "ValidMessage" + TypeAllMethodsService = "AllMethodsService" + TypeBlogPost = "BlogPost" + TypeCategory = "Category" + TypeDependsOnSkipped = "DependsOnSkipped" + TypeDuplicateNumberMessage = "DuplicateNumberMessage" + TypeEnumWithConflictingValue = "EnumWithConflictingValue" + TypeExplicitSkippedMessage = "ExplicitSkippedMessage" + TypeImage = "Image" + TypeImplicitSkippedMessage = "ImplicitSkippedMessage" + TypeInvalidFieldMessage = "InvalidFieldMessage" + TypeMessageWithEnum = "MessageWithEnum" + TypeMessageWithFieldOne = "MessageWithFieldOne" + TypeMessageWithID = "MessageWithID" + TypeMessageWithInts = "MessageWithInts" + TypeMessageWithOptionals = "MessageWithOptionals" + TypeMessageWithPackageName = "MessageWithPackageName" + TypeMessageWithStrings = "MessageWithStrings" + TypeNoBackref = "NoBackref" + TypeOneMethodService = "OneMethodService" + TypePortal = "Portal" + TypeSkipEdgeExample = "SkipEdgeExample" + TypeTwoMethodService = "TwoMethodService" + TypeUser = "User" + TypeValidMessage = "ValidMessage" ) // AllMethodsServiceMutation represents an operation that mutates the AllMethodsService nodes in the graph. @@ -2223,6 +2227,332 @@ func (m *DuplicateNumberMessageMutation) ResetEdge(name string) error { return fmt.Errorf("unknown DuplicateNumberMessage edge %s", name) } +// EnumWithConflictingValueMutation represents an operation that mutates the EnumWithConflictingValue nodes in the graph. +type EnumWithConflictingValueMutation struct { + config + op Op + typ string + id *int + enum *enumwithconflictingvalue.Enum + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*EnumWithConflictingValue, error) + predicates []predicate.EnumWithConflictingValue +} + +var _ ent.Mutation = (*EnumWithConflictingValueMutation)(nil) + +// enumwithconflictingvalueOption allows management of the mutation configuration using functional options. +type enumwithconflictingvalueOption func(*EnumWithConflictingValueMutation) + +// newEnumWithConflictingValueMutation creates new mutation for the EnumWithConflictingValue entity. +func newEnumWithConflictingValueMutation(c config, op Op, opts ...enumwithconflictingvalueOption) *EnumWithConflictingValueMutation { + m := &EnumWithConflictingValueMutation{ + config: c, + op: op, + typ: TypeEnumWithConflictingValue, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withEnumWithConflictingValueID sets the ID field of the mutation. +func withEnumWithConflictingValueID(id int) enumwithconflictingvalueOption { + return func(m *EnumWithConflictingValueMutation) { + var ( + err error + once sync.Once + value *EnumWithConflictingValue + ) + m.oldValue = func(ctx context.Context) (*EnumWithConflictingValue, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().EnumWithConflictingValue.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withEnumWithConflictingValue sets the old EnumWithConflictingValue of the mutation. +func withEnumWithConflictingValue(node *EnumWithConflictingValue) enumwithconflictingvalueOption { + return func(m *EnumWithConflictingValueMutation) { + m.oldValue = func(context.Context) (*EnumWithConflictingValue, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m EnumWithConflictingValueMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m EnumWithConflictingValueMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *EnumWithConflictingValueMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *EnumWithConflictingValueMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().EnumWithConflictingValue.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetEnum sets the "enum" field. +func (m *EnumWithConflictingValueMutation) SetEnum(e enumwithconflictingvalue.Enum) { + m.enum = &e +} + +// Enum returns the value of the "enum" field in the mutation. +func (m *EnumWithConflictingValueMutation) Enum() (r enumwithconflictingvalue.Enum, exists bool) { + v := m.enum + if v == nil { + return + } + return *v, true +} + +// OldEnum returns the old "enum" field's value of the EnumWithConflictingValue entity. +// If the EnumWithConflictingValue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EnumWithConflictingValueMutation) OldEnum(ctx context.Context) (v enumwithconflictingvalue.Enum, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnum is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnum requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnum: %w", err) + } + return oldValue.Enum, nil +} + +// ResetEnum resets all changes to the "enum" field. +func (m *EnumWithConflictingValueMutation) ResetEnum() { + m.enum = nil +} + +// Where appends a list predicates to the EnumWithConflictingValueMutation builder. +func (m *EnumWithConflictingValueMutation) Where(ps ...predicate.EnumWithConflictingValue) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the EnumWithConflictingValueMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *EnumWithConflictingValueMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EnumWithConflictingValue, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *EnumWithConflictingValueMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *EnumWithConflictingValueMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (EnumWithConflictingValue). +func (m *EnumWithConflictingValueMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *EnumWithConflictingValueMutation) Fields() []string { + fields := make([]string, 0, 1) + if m.enum != nil { + fields = append(fields, enumwithconflictingvalue.FieldEnum) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *EnumWithConflictingValueMutation) Field(name string) (ent.Value, bool) { + switch name { + case enumwithconflictingvalue.FieldEnum: + return m.Enum() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *EnumWithConflictingValueMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case enumwithconflictingvalue.FieldEnum: + return m.OldEnum(ctx) + } + return nil, fmt.Errorf("unknown EnumWithConflictingValue field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EnumWithConflictingValueMutation) SetField(name string, value ent.Value) error { + switch name { + case enumwithconflictingvalue.FieldEnum: + v, ok := value.(enumwithconflictingvalue.Enum) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnum(v) + return nil + } + return fmt.Errorf("unknown EnumWithConflictingValue field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *EnumWithConflictingValueMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *EnumWithConflictingValueMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *EnumWithConflictingValueMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown EnumWithConflictingValue numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *EnumWithConflictingValueMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *EnumWithConflictingValueMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *EnumWithConflictingValueMutation) ClearField(name string) error { + return fmt.Errorf("unknown EnumWithConflictingValue nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *EnumWithConflictingValueMutation) ResetField(name string) error { + switch name { + case enumwithconflictingvalue.FieldEnum: + m.ResetEnum() + return nil + } + return fmt.Errorf("unknown EnumWithConflictingValue field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *EnumWithConflictingValueMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *EnumWithConflictingValueMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *EnumWithConflictingValueMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *EnumWithConflictingValueMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *EnumWithConflictingValueMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *EnumWithConflictingValueMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *EnumWithConflictingValueMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown EnumWithConflictingValue unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *EnumWithConflictingValueMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown EnumWithConflictingValue edge %s", name) +} + // ExplicitSkippedMessageMutation represents an operation that mutates the ExplicitSkippedMessage nodes in the graph. type ExplicitSkippedMessageMutation struct { config @@ -3505,15 +3835,16 @@ func (m *InvalidFieldMessageMutation) ResetEdge(name string) error { // MessageWithEnumMutation represents an operation that mutates the MessageWithEnum nodes in the graph. type MessageWithEnumMutation struct { config - op Op - typ string - id *int - enum_type *messagewithenum.EnumType - enum_without_default *messagewithenum.EnumWithoutDefault - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*MessageWithEnum, error) - predicates []predicate.MessageWithEnum + op Op + typ string + id *int + enum_type *messagewithenum.EnumType + enum_without_default *messagewithenum.EnumWithoutDefault + enum_with_special_characters *messagewithenum.EnumWithSpecialCharacters + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*MessageWithEnum, error) + predicates []predicate.MessageWithEnum } var _ ent.Mutation = (*MessageWithEnumMutation)(nil) @@ -3686,27 +4017,63 @@ func (m *MessageWithEnumMutation) ResetEnumWithoutDefault() { m.enum_without_default = nil } -// Where appends a list predicates to the MessageWithEnumMutation builder. -func (m *MessageWithEnumMutation) Where(ps ...predicate.MessageWithEnum) { - m.predicates = append(m.predicates, ps...) +// SetEnumWithSpecialCharacters sets the "enum_with_special_characters" field. +func (m *MessageWithEnumMutation) SetEnumWithSpecialCharacters(mwsc messagewithenum.EnumWithSpecialCharacters) { + m.enum_with_special_characters = &mwsc } -// WhereP appends storage-level predicates to the MessageWithEnumMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *MessageWithEnumMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.MessageWithEnum, len(ps)) - for i := range ps { - p[i] = ps[i] +// EnumWithSpecialCharacters returns the value of the "enum_with_special_characters" field in the mutation. +func (m *MessageWithEnumMutation) EnumWithSpecialCharacters() (r messagewithenum.EnumWithSpecialCharacters, exists bool) { + v := m.enum_with_special_characters + if v == nil { + return } - m.Where(p...) -} - -// Op returns the operation name. -func (m *MessageWithEnumMutation) Op() Op { - return m.op + return *v, true } -// SetOp allows setting the mutation operation. +// OldEnumWithSpecialCharacters returns the old "enum_with_special_characters" field's value of the MessageWithEnum entity. +// If the MessageWithEnum object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MessageWithEnumMutation) OldEnumWithSpecialCharacters(ctx context.Context) (v messagewithenum.EnumWithSpecialCharacters, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnumWithSpecialCharacters is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnumWithSpecialCharacters requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnumWithSpecialCharacters: %w", err) + } + return oldValue.EnumWithSpecialCharacters, nil +} + +// ResetEnumWithSpecialCharacters resets all changes to the "enum_with_special_characters" field. +func (m *MessageWithEnumMutation) ResetEnumWithSpecialCharacters() { + m.enum_with_special_characters = nil +} + +// Where appends a list predicates to the MessageWithEnumMutation builder. +func (m *MessageWithEnumMutation) Where(ps ...predicate.MessageWithEnum) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the MessageWithEnumMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MessageWithEnumMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.MessageWithEnum, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *MessageWithEnumMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. func (m *MessageWithEnumMutation) SetOp(op Op) { m.op = op } @@ -3720,13 +4087,16 @@ func (m *MessageWithEnumMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *MessageWithEnumMutation) Fields() []string { - fields := make([]string, 0, 2) + fields := make([]string, 0, 3) if m.enum_type != nil { fields = append(fields, messagewithenum.FieldEnumType) } if m.enum_without_default != nil { fields = append(fields, messagewithenum.FieldEnumWithoutDefault) } + if m.enum_with_special_characters != nil { + fields = append(fields, messagewithenum.FieldEnumWithSpecialCharacters) + } return fields } @@ -3739,6 +4109,8 @@ func (m *MessageWithEnumMutation) Field(name string) (ent.Value, bool) { return m.EnumType() case messagewithenum.FieldEnumWithoutDefault: return m.EnumWithoutDefault() + case messagewithenum.FieldEnumWithSpecialCharacters: + return m.EnumWithSpecialCharacters() } return nil, false } @@ -3752,6 +4124,8 @@ func (m *MessageWithEnumMutation) OldField(ctx context.Context, name string) (en return m.OldEnumType(ctx) case messagewithenum.FieldEnumWithoutDefault: return m.OldEnumWithoutDefault(ctx) + case messagewithenum.FieldEnumWithSpecialCharacters: + return m.OldEnumWithSpecialCharacters(ctx) } return nil, fmt.Errorf("unknown MessageWithEnum field %s", name) } @@ -3775,6 +4149,13 @@ func (m *MessageWithEnumMutation) SetField(name string, value ent.Value) error { } m.SetEnumWithoutDefault(v) return nil + case messagewithenum.FieldEnumWithSpecialCharacters: + v, ok := value.(messagewithenum.EnumWithSpecialCharacters) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnumWithSpecialCharacters(v) + return nil } return fmt.Errorf("unknown MessageWithEnum field %s", name) } @@ -3830,6 +4211,9 @@ func (m *MessageWithEnumMutation) ResetField(name string) error { case messagewithenum.FieldEnumWithoutDefault: m.ResetEnumWithoutDefault() return nil + case messagewithenum.FieldEnumWithSpecialCharacters: + m.ResetEnumWithSpecialCharacters() + return nil } return fmt.Errorf("unknown MessageWithEnum field %s", name) } @@ -4514,6 +4898,558 @@ func (m *MessageWithIDMutation) ResetEdge(name string) error { return fmt.Errorf("unknown MessageWithID edge %s", name) } +// MessageWithIntsMutation represents an operation that mutates the MessageWithInts nodes in the graph. +type MessageWithIntsMutation struct { + config + op Op + typ string + id *int + int32s *[]int32 + appendint32s []int32 + int64s *[]int64 + appendint64s []int64 + uint32s *[]uint32 + appenduint32s []uint32 + uint64s *[]uint64 + appenduint64s []uint64 + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*MessageWithInts, error) + predicates []predicate.MessageWithInts +} + +var _ ent.Mutation = (*MessageWithIntsMutation)(nil) + +// messagewithintsOption allows management of the mutation configuration using functional options. +type messagewithintsOption func(*MessageWithIntsMutation) + +// newMessageWithIntsMutation creates new mutation for the MessageWithInts entity. +func newMessageWithIntsMutation(c config, op Op, opts ...messagewithintsOption) *MessageWithIntsMutation { + m := &MessageWithIntsMutation{ + config: c, + op: op, + typ: TypeMessageWithInts, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withMessageWithIntsID sets the ID field of the mutation. +func withMessageWithIntsID(id int) messagewithintsOption { + return func(m *MessageWithIntsMutation) { + var ( + err error + once sync.Once + value *MessageWithInts + ) + m.oldValue = func(ctx context.Context) (*MessageWithInts, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().MessageWithInts.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withMessageWithInts sets the old MessageWithInts of the mutation. +func withMessageWithInts(node *MessageWithInts) messagewithintsOption { + return func(m *MessageWithIntsMutation) { + m.oldValue = func(context.Context) (*MessageWithInts, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m MessageWithIntsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m MessageWithIntsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *MessageWithIntsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *MessageWithIntsMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().MessageWithInts.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetInt32s sets the "int32s" field. +func (m *MessageWithIntsMutation) SetInt32s(i []int32) { + m.int32s = &i + m.appendint32s = nil +} + +// Int32s returns the value of the "int32s" field in the mutation. +func (m *MessageWithIntsMutation) Int32s() (r []int32, exists bool) { + v := m.int32s + if v == nil { + return + } + return *v, true +} + +// OldInt32s returns the old "int32s" field's value of the MessageWithInts entity. +// If the MessageWithInts object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MessageWithIntsMutation) OldInt32s(ctx context.Context) (v []int32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInt32s is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInt32s requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInt32s: %w", err) + } + return oldValue.Int32s, nil +} + +// AppendInt32s adds i to the "int32s" field. +func (m *MessageWithIntsMutation) AppendInt32s(i []int32) { + m.appendint32s = append(m.appendint32s, i...) +} + +// AppendedInt32s returns the list of values that were appended to the "int32s" field in this mutation. +func (m *MessageWithIntsMutation) AppendedInt32s() ([]int32, bool) { + if len(m.appendint32s) == 0 { + return nil, false + } + return m.appendint32s, true +} + +// ResetInt32s resets all changes to the "int32s" field. +func (m *MessageWithIntsMutation) ResetInt32s() { + m.int32s = nil + m.appendint32s = nil +} + +// SetInt64s sets the "int64s" field. +func (m *MessageWithIntsMutation) SetInt64s(i []int64) { + m.int64s = &i + m.appendint64s = nil +} + +// Int64s returns the value of the "int64s" field in the mutation. +func (m *MessageWithIntsMutation) Int64s() (r []int64, exists bool) { + v := m.int64s + if v == nil { + return + } + return *v, true +} + +// OldInt64s returns the old "int64s" field's value of the MessageWithInts entity. +// If the MessageWithInts object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MessageWithIntsMutation) OldInt64s(ctx context.Context) (v []int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInt64s is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInt64s requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInt64s: %w", err) + } + return oldValue.Int64s, nil +} + +// AppendInt64s adds i to the "int64s" field. +func (m *MessageWithIntsMutation) AppendInt64s(i []int64) { + m.appendint64s = append(m.appendint64s, i...) +} + +// AppendedInt64s returns the list of values that were appended to the "int64s" field in this mutation. +func (m *MessageWithIntsMutation) AppendedInt64s() ([]int64, bool) { + if len(m.appendint64s) == 0 { + return nil, false + } + return m.appendint64s, true +} + +// ResetInt64s resets all changes to the "int64s" field. +func (m *MessageWithIntsMutation) ResetInt64s() { + m.int64s = nil + m.appendint64s = nil +} + +// SetUint32s sets the "uint32s" field. +func (m *MessageWithIntsMutation) SetUint32s(u []uint32) { + m.uint32s = &u + m.appenduint32s = nil +} + +// Uint32s returns the value of the "uint32s" field in the mutation. +func (m *MessageWithIntsMutation) Uint32s() (r []uint32, exists bool) { + v := m.uint32s + if v == nil { + return + } + return *v, true +} + +// OldUint32s returns the old "uint32s" field's value of the MessageWithInts entity. +// If the MessageWithInts object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MessageWithIntsMutation) OldUint32s(ctx context.Context) (v []uint32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUint32s is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUint32s requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUint32s: %w", err) + } + return oldValue.Uint32s, nil +} + +// AppendUint32s adds u to the "uint32s" field. +func (m *MessageWithIntsMutation) AppendUint32s(u []uint32) { + m.appenduint32s = append(m.appenduint32s, u...) +} + +// AppendedUint32s returns the list of values that were appended to the "uint32s" field in this mutation. +func (m *MessageWithIntsMutation) AppendedUint32s() ([]uint32, bool) { + if len(m.appenduint32s) == 0 { + return nil, false + } + return m.appenduint32s, true +} + +// ResetUint32s resets all changes to the "uint32s" field. +func (m *MessageWithIntsMutation) ResetUint32s() { + m.uint32s = nil + m.appenduint32s = nil +} + +// SetUint64s sets the "uint64s" field. +func (m *MessageWithIntsMutation) SetUint64s(u []uint64) { + m.uint64s = &u + m.appenduint64s = nil +} + +// Uint64s returns the value of the "uint64s" field in the mutation. +func (m *MessageWithIntsMutation) Uint64s() (r []uint64, exists bool) { + v := m.uint64s + if v == nil { + return + } + return *v, true +} + +// OldUint64s returns the old "uint64s" field's value of the MessageWithInts entity. +// If the MessageWithInts object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MessageWithIntsMutation) OldUint64s(ctx context.Context) (v []uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUint64s is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUint64s requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUint64s: %w", err) + } + return oldValue.Uint64s, nil +} + +// AppendUint64s adds u to the "uint64s" field. +func (m *MessageWithIntsMutation) AppendUint64s(u []uint64) { + m.appenduint64s = append(m.appenduint64s, u...) +} + +// AppendedUint64s returns the list of values that were appended to the "uint64s" field in this mutation. +func (m *MessageWithIntsMutation) AppendedUint64s() ([]uint64, bool) { + if len(m.appenduint64s) == 0 { + return nil, false + } + return m.appenduint64s, true +} + +// ResetUint64s resets all changes to the "uint64s" field. +func (m *MessageWithIntsMutation) ResetUint64s() { + m.uint64s = nil + m.appenduint64s = nil +} + +// Where appends a list predicates to the MessageWithIntsMutation builder. +func (m *MessageWithIntsMutation) Where(ps ...predicate.MessageWithInts) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the MessageWithIntsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MessageWithIntsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.MessageWithInts, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *MessageWithIntsMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *MessageWithIntsMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (MessageWithInts). +func (m *MessageWithIntsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *MessageWithIntsMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.int32s != nil { + fields = append(fields, messagewithints.FieldInt32s) + } + if m.int64s != nil { + fields = append(fields, messagewithints.FieldInt64s) + } + if m.uint32s != nil { + fields = append(fields, messagewithints.FieldUint32s) + } + if m.uint64s != nil { + fields = append(fields, messagewithints.FieldUint64s) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *MessageWithIntsMutation) Field(name string) (ent.Value, bool) { + switch name { + case messagewithints.FieldInt32s: + return m.Int32s() + case messagewithints.FieldInt64s: + return m.Int64s() + case messagewithints.FieldUint32s: + return m.Uint32s() + case messagewithints.FieldUint64s: + return m.Uint64s() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *MessageWithIntsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case messagewithints.FieldInt32s: + return m.OldInt32s(ctx) + case messagewithints.FieldInt64s: + return m.OldInt64s(ctx) + case messagewithints.FieldUint32s: + return m.OldUint32s(ctx) + case messagewithints.FieldUint64s: + return m.OldUint64s(ctx) + } + return nil, fmt.Errorf("unknown MessageWithInts field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MessageWithIntsMutation) SetField(name string, value ent.Value) error { + switch name { + case messagewithints.FieldInt32s: + v, ok := value.([]int32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInt32s(v) + return nil + case messagewithints.FieldInt64s: + v, ok := value.([]int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInt64s(v) + return nil + case messagewithints.FieldUint32s: + v, ok := value.([]uint32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUint32s(v) + return nil + case messagewithints.FieldUint64s: + v, ok := value.([]uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUint64s(v) + return nil + } + return fmt.Errorf("unknown MessageWithInts field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *MessageWithIntsMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *MessageWithIntsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MessageWithIntsMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown MessageWithInts numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *MessageWithIntsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *MessageWithIntsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *MessageWithIntsMutation) ClearField(name string) error { + return fmt.Errorf("unknown MessageWithInts nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *MessageWithIntsMutation) ResetField(name string) error { + switch name { + case messagewithints.FieldInt32s: + m.ResetInt32s() + return nil + case messagewithints.FieldInt64s: + m.ResetInt64s() + return nil + case messagewithints.FieldUint32s: + m.ResetUint32s() + return nil + case messagewithints.FieldUint64s: + m.ResetUint64s() + return nil + } + return fmt.Errorf("unknown MessageWithInts field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *MessageWithIntsMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *MessageWithIntsMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *MessageWithIntsMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *MessageWithIntsMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *MessageWithIntsMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *MessageWithIntsMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *MessageWithIntsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown MessageWithInts unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *MessageWithIntsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown MessageWithInts edge %s", name) +} + // MessageWithOptionalsMutation represents an operation that mutates the MessageWithOptionals nodes in the graph. type MessageWithOptionalsMutation struct { config diff --git a/entproto/internal/entprototest/ent/nobackref/where.go b/entproto/internal/entprototest/ent/nobackref/where.go index 8b6d64d5b..ad160b959 100644 --- a/entproto/internal/entprototest/ent/nobackref/where.go +++ b/entproto/internal/entprototest/ent/nobackref/where.go @@ -78,32 +78,15 @@ func HasImagesWith(preds ...predicate.Image) predicate.NoBackref { // And groups predicates with the AND operator between them. func And(predicates ...predicate.NoBackref) predicate.NoBackref { - return predicate.NoBackref(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.NoBackref(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.NoBackref) predicate.NoBackref { - return predicate.NoBackref(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.NoBackref(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.NoBackref) predicate.NoBackref { - return predicate.NoBackref(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.NoBackref(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/nobackref_create.go b/entproto/internal/entprototest/ent/nobackref_create.go index 3a3e1665d..8357275f6 100644 --- a/entproto/internal/entprototest/ent/nobackref_create.go +++ b/entproto/internal/entprototest/ent/nobackref_create.go @@ -42,7 +42,7 @@ func (nbc *NoBackrefCreate) Mutation() *NoBackrefMutation { // Save creates the NoBackref in the database. func (nbc *NoBackrefCreate) Save(ctx context.Context) (*NoBackref, error) { - return withHooks[*NoBackref, NoBackrefMutation](ctx, nbc.sqlSave, nbc.mutation, nbc.hooks) + return withHooks(ctx, nbc.sqlSave, nbc.mutation, nbc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -117,11 +117,15 @@ func (nbc *NoBackrefCreate) createSpec() (*NoBackref, *sqlgraph.CreateSpec) { // NoBackrefCreateBulk is the builder for creating many NoBackref entities in bulk. type NoBackrefCreateBulk struct { config + err error builders []*NoBackrefCreate } // Save creates the NoBackref entities in the database. func (nbcb *NoBackrefCreateBulk) Save(ctx context.Context) ([]*NoBackref, error) { + if nbcb.err != nil { + return nil, nbcb.err + } specs := make([]*sqlgraph.CreateSpec, len(nbcb.builders)) nodes := make([]*NoBackref, len(nbcb.builders)) mutators := make([]Mutator, len(nbcb.builders)) diff --git a/entproto/internal/entprototest/ent/nobackref_delete.go b/entproto/internal/entprototest/ent/nobackref_delete.go index 11701e7a2..da3019afe 100644 --- a/entproto/internal/entprototest/ent/nobackref_delete.go +++ b/entproto/internal/entprototest/ent/nobackref_delete.go @@ -27,7 +27,7 @@ func (nbd *NoBackrefDelete) Where(ps ...predicate.NoBackref) *NoBackrefDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (nbd *NoBackrefDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, NoBackrefMutation](ctx, nbd.sqlExec, nbd.mutation, nbd.hooks) + return withHooks(ctx, nbd.sqlExec, nbd.mutation, nbd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/nobackref_update.go b/entproto/internal/entprototest/ent/nobackref_update.go index 154fc0a78..b335bd533 100644 --- a/entproto/internal/entprototest/ent/nobackref_update.go +++ b/entproto/internal/entprototest/ent/nobackref_update.go @@ -72,7 +72,7 @@ func (nbu *NoBackrefUpdate) RemoveImages(i ...*Image) *NoBackrefUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (nbu *NoBackrefUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, NoBackrefMutation](ctx, nbu.sqlSave, nbu.mutation, nbu.hooks) + return withHooks(ctx, nbu.sqlSave, nbu.mutation, nbu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -227,7 +227,7 @@ func (nbuo *NoBackrefUpdateOne) Select(field string, fields ...string) *NoBackre // Save executes the query and returns the updated NoBackref entity. func (nbuo *NoBackrefUpdateOne) Save(ctx context.Context) (*NoBackref, error) { - return withHooks[*NoBackref, NoBackrefMutation](ctx, nbuo.sqlSave, nbuo.mutation, nbuo.hooks) + return withHooks(ctx, nbuo.sqlSave, nbuo.mutation, nbuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/onemethodservice/where.go b/entproto/internal/entprototest/ent/onemethodservice/where.go index be5415ff5..e034e972b 100644 --- a/entproto/internal/entprototest/ent/onemethodservice/where.go +++ b/entproto/internal/entprototest/ent/onemethodservice/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.OneMethodService { // And groups predicates with the AND operator between them. func And(predicates ...predicate.OneMethodService) predicate.OneMethodService { - return predicate.OneMethodService(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.OneMethodService(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.OneMethodService) predicate.OneMethodService { - return predicate.OneMethodService(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.OneMethodService(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.OneMethodService) predicate.OneMethodService { - return predicate.OneMethodService(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.OneMethodService(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/onemethodservice_create.go b/entproto/internal/entprototest/ent/onemethodservice_create.go index a2e9889b8..cd31d23b1 100644 --- a/entproto/internal/entprototest/ent/onemethodservice_create.go +++ b/entproto/internal/entprototest/ent/onemethodservice_create.go @@ -25,7 +25,7 @@ func (omsc *OneMethodServiceCreate) Mutation() *OneMethodServiceMutation { // Save creates the OneMethodService in the database. func (omsc *OneMethodServiceCreate) Save(ctx context.Context) (*OneMethodService, error) { - return withHooks[*OneMethodService, OneMethodServiceMutation](ctx, omsc.sqlSave, omsc.mutation, omsc.hooks) + return withHooks(ctx, omsc.sqlSave, omsc.mutation, omsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (omsc *OneMethodServiceCreate) createSpec() (*OneMethodService, *sqlgraph.C // OneMethodServiceCreateBulk is the builder for creating many OneMethodService entities in bulk. type OneMethodServiceCreateBulk struct { config + err error builders []*OneMethodServiceCreate } // Save creates the OneMethodService entities in the database. func (omscb *OneMethodServiceCreateBulk) Save(ctx context.Context) ([]*OneMethodService, error) { + if omscb.err != nil { + return nil, omscb.err + } specs := make([]*sqlgraph.CreateSpec, len(omscb.builders)) nodes := make([]*OneMethodService, len(omscb.builders)) mutators := make([]Mutator, len(omscb.builders)) diff --git a/entproto/internal/entprototest/ent/onemethodservice_delete.go b/entproto/internal/entprototest/ent/onemethodservice_delete.go index 83e6677fd..af09d4ea4 100644 --- a/entproto/internal/entprototest/ent/onemethodservice_delete.go +++ b/entproto/internal/entprototest/ent/onemethodservice_delete.go @@ -27,7 +27,7 @@ func (omsd *OneMethodServiceDelete) Where(ps ...predicate.OneMethodService) *One // Exec executes the deletion query and returns how many vertices were deleted. func (omsd *OneMethodServiceDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, OneMethodServiceMutation](ctx, omsd.sqlExec, omsd.mutation, omsd.hooks) + return withHooks(ctx, omsd.sqlExec, omsd.mutation, omsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/onemethodservice_update.go b/entproto/internal/entprototest/ent/onemethodservice_update.go index 09deeede2..42e109e1b 100644 --- a/entproto/internal/entprototest/ent/onemethodservice_update.go +++ b/entproto/internal/entprototest/ent/onemethodservice_update.go @@ -34,7 +34,7 @@ func (omsu *OneMethodServiceUpdate) Mutation() *OneMethodServiceMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (omsu *OneMethodServiceUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, OneMethodServiceMutation](ctx, omsu.sqlSave, omsu.mutation, omsu.hooks) + return withHooks(ctx, omsu.sqlSave, omsu.mutation, omsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (omsuo *OneMethodServiceUpdateOne) Select(field string, fields ...string) * // Save executes the query and returns the updated OneMethodService entity. func (omsuo *OneMethodServiceUpdateOne) Save(ctx context.Context) (*OneMethodService, error) { - return withHooks[*OneMethodService, OneMethodServiceMutation](ctx, omsuo.sqlSave, omsuo.mutation, omsuo.hooks) + return withHooks(ctx, omsuo.sqlSave, omsuo.mutation, omsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/portal/where.go b/entproto/internal/entprototest/ent/portal/where.go index 9dd498e90..c7e77e112 100644 --- a/entproto/internal/entprototest/ent/portal/where.go +++ b/entproto/internal/entprototest/ent/portal/where.go @@ -218,32 +218,15 @@ func HasCategoryWith(preds ...predicate.Category) predicate.Portal { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Portal) predicate.Portal { - return predicate.Portal(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Portal(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Portal) predicate.Portal { - return predicate.Portal(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Portal(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Portal) predicate.Portal { - return predicate.Portal(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Portal(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/portal_create.go b/entproto/internal/entprototest/ent/portal_create.go index 8c0d75472..c60a697df 100644 --- a/entproto/internal/entprototest/ent/portal_create.go +++ b/entproto/internal/entprototest/ent/portal_create.go @@ -58,7 +58,7 @@ func (pc *PortalCreate) Mutation() *PortalMutation { // Save creates the Portal in the database. func (pc *PortalCreate) Save(ctx context.Context) (*Portal, error) { - return withHooks[*Portal, PortalMutation](ctx, pc.sqlSave, pc.mutation, pc.hooks) + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -148,11 +148,15 @@ func (pc *PortalCreate) createSpec() (*Portal, *sqlgraph.CreateSpec) { // PortalCreateBulk is the builder for creating many Portal entities in bulk. type PortalCreateBulk struct { config + err error builders []*PortalCreate } // Save creates the Portal entities in the database. func (pcb *PortalCreateBulk) Save(ctx context.Context) ([]*Portal, error) { + if pcb.err != nil { + return nil, pcb.err + } specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) nodes := make([]*Portal, len(pcb.builders)) mutators := make([]Mutator, len(pcb.builders)) diff --git a/entproto/internal/entprototest/ent/portal_delete.go b/entproto/internal/entprototest/ent/portal_delete.go index e7746711c..000efe10a 100644 --- a/entproto/internal/entprototest/ent/portal_delete.go +++ b/entproto/internal/entprototest/ent/portal_delete.go @@ -27,7 +27,7 @@ func (pd *PortalDelete) Where(ps ...predicate.Portal) *PortalDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (pd *PortalDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, PortalMutation](ctx, pd.sqlExec, pd.mutation, pd.hooks) + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/portal_update.go b/entproto/internal/entprototest/ent/portal_update.go index 9b592aad7..80c51686c 100644 --- a/entproto/internal/entprototest/ent/portal_update.go +++ b/entproto/internal/entprototest/ent/portal_update.go @@ -34,12 +34,28 @@ func (pu *PortalUpdate) SetName(s string) *PortalUpdate { return pu } +// SetNillableName sets the "name" field if the given value is not nil. +func (pu *PortalUpdate) SetNillableName(s *string) *PortalUpdate { + if s != nil { + pu.SetName(*s) + } + return pu +} + // SetDescription sets the "description" field. func (pu *PortalUpdate) SetDescription(s string) *PortalUpdate { pu.mutation.SetDescription(s) return pu } +// SetNillableDescription sets the "description" field if the given value is not nil. +func (pu *PortalUpdate) SetNillableDescription(s *string) *PortalUpdate { + if s != nil { + pu.SetDescription(*s) + } + return pu +} + // SetCategoryID sets the "category" edge to the Category entity by ID. func (pu *PortalUpdate) SetCategoryID(id int) *PortalUpdate { pu.mutation.SetCategoryID(id) @@ -72,7 +88,7 @@ func (pu *PortalUpdate) ClearCategory() *PortalUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *PortalUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, PortalMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks) + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -167,12 +183,28 @@ func (puo *PortalUpdateOne) SetName(s string) *PortalUpdateOne { return puo } +// SetNillableName sets the "name" field if the given value is not nil. +func (puo *PortalUpdateOne) SetNillableName(s *string) *PortalUpdateOne { + if s != nil { + puo.SetName(*s) + } + return puo +} + // SetDescription sets the "description" field. func (puo *PortalUpdateOne) SetDescription(s string) *PortalUpdateOne { puo.mutation.SetDescription(s) return puo } +// SetNillableDescription sets the "description" field if the given value is not nil. +func (puo *PortalUpdateOne) SetNillableDescription(s *string) *PortalUpdateOne { + if s != nil { + puo.SetDescription(*s) + } + return puo +} + // SetCategoryID sets the "category" edge to the Category entity by ID. func (puo *PortalUpdateOne) SetCategoryID(id int) *PortalUpdateOne { puo.mutation.SetCategoryID(id) @@ -218,7 +250,7 @@ func (puo *PortalUpdateOne) Select(field string, fields ...string) *PortalUpdate // Save executes the query and returns the updated Portal entity. func (puo *PortalUpdateOne) Save(ctx context.Context) (*Portal, error) { - return withHooks[*Portal, PortalMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks) + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/predicate/predicate.go b/entproto/internal/entprototest/ent/predicate/predicate.go index c6fc195ee..db302b771 100644 --- a/entproto/internal/entprototest/ent/predicate/predicate.go +++ b/entproto/internal/entprototest/ent/predicate/predicate.go @@ -21,6 +21,9 @@ type DependsOnSkipped func(*sql.Selector) // DuplicateNumberMessage is the predicate function for duplicatenumbermessage builders. type DuplicateNumberMessage func(*sql.Selector) +// EnumWithConflictingValue is the predicate function for enumwithconflictingvalue builders. +type EnumWithConflictingValue func(*sql.Selector) + // ExplicitSkippedMessage is the predicate function for explicitskippedmessage builders. type ExplicitSkippedMessage func(*sql.Selector) @@ -42,6 +45,9 @@ type MessageWithFieldOne func(*sql.Selector) // MessageWithID is the predicate function for messagewithid builders. type MessageWithID func(*sql.Selector) +// MessageWithInts is the predicate function for messagewithints builders. +type MessageWithInts func(*sql.Selector) + // MessageWithOptionals is the predicate function for messagewithoptionals builders. type MessageWithOptionals func(*sql.Selector) diff --git a/entproto/internal/entprototest/ent/runtime/runtime.go b/entproto/internal/entprototest/ent/runtime/runtime.go index feefa3843..e621bba2c 100644 --- a/entproto/internal/entprototest/ent/runtime/runtime.go +++ b/entproto/internal/entprototest/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entproto/internal/entprototest/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entproto/internal/entprototest/ent/schema/enum_with_conflicting_value.go b/entproto/internal/entprototest/ent/schema/enum_with_conflicting_value.go new file mode 100644 index 000000000..7c509479c --- /dev/null +++ b/entproto/internal/entprototest/ent/schema/enum_with_conflicting_value.go @@ -0,0 +1,48 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "entgo.io/contrib/entproto" + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" +) + +// EnumWithConflictingValue holds the schema definition for the EnumWithConflictingValue entity. +type EnumWithConflictingValue struct { + ent.Schema +} + +// Fields of the EnumWithConflictingValue. +func (EnumWithConflictingValue) Fields() []ent.Field { + return []ent.Field{ + field.Enum("enum"). + NamedValues( + "jpeg", "image/jpeg", + "jpegAlt", "IMAGE_JPEG"). + Annotations( + entproto.Field(4), + entproto.Enum(map[string]int32{ + "image/jpeg": 1, + "IMAGE_JPEG": 2, + }), + ), + } +} + +func (EnumWithConflictingValue) Annotations() []schema.Annotation { + return []schema.Annotation{entproto.Message()} +} diff --git a/entproto/internal/entprototest/ent/schema/message_with_enum.go b/entproto/internal/entprototest/ent/schema/message_with_enum.go index 1b0d6219d..231b88f41 100644 --- a/entproto/internal/entprototest/ent/schema/message_with_enum.go +++ b/entproto/internal/entprototest/ent/schema/message_with_enum.go @@ -50,6 +50,17 @@ func (MessageWithEnum) Fields() []ent.Field { "second": 2, }), ), + field.Enum("enum_with_special_characters"). + NamedValues( + "jpeg", "image/jpeg", + "png", "image/png"). + Annotations( + entproto.Field(4), + entproto.Enum(map[string]int32{ + "image/jpeg": 1, + "image/png": 2, + }), + ), } } diff --git a/entproto/internal/entprototest/ent/schema/message_with_ints.go b/entproto/internal/entprototest/ent/schema/message_with_ints.go new file mode 100644 index 000000000..9e73d4e48 --- /dev/null +++ b/entproto/internal/entprototest/ent/schema/message_with_ints.go @@ -0,0 +1,39 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "entgo.io/contrib/entproto" + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" +) + +type MessageWithInts struct { + ent.Schema +} + +func (MessageWithInts) Fields() []ent.Field { + return []ent.Field{ + field.JSON("int32s", []int32{}).Annotations(entproto.Field(2)), + field.JSON("int64s", []int64{}).Annotations(entproto.Field(3)), + field.JSON("uint32s", []uint32{}).Annotations(entproto.Field(4)), + field.JSON("uint64s", []uint64{}).Annotations(entproto.Field(5)), + } +} + +func (MessageWithInts) Annotations() []schema.Annotation { + return []schema.Annotation{entproto.Message()} +} diff --git a/entproto/internal/entprototest/ent/skipedgeexample/where.go b/entproto/internal/entprototest/ent/skipedgeexample/where.go index ed1877f7c..1e6c4aa79 100644 --- a/entproto/internal/entprototest/ent/skipedgeexample/where.go +++ b/entproto/internal/entprototest/ent/skipedgeexample/where.go @@ -78,32 +78,15 @@ func HasUserWith(preds ...predicate.User) predicate.SkipEdgeExample { // And groups predicates with the AND operator between them. func And(predicates ...predicate.SkipEdgeExample) predicate.SkipEdgeExample { - return predicate.SkipEdgeExample(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.SkipEdgeExample(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.SkipEdgeExample) predicate.SkipEdgeExample { - return predicate.SkipEdgeExample(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.SkipEdgeExample(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.SkipEdgeExample) predicate.SkipEdgeExample { - return predicate.SkipEdgeExample(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.SkipEdgeExample(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/skipedgeexample_create.go b/entproto/internal/entprototest/ent/skipedgeexample_create.go index 0bdb2113b..0518ae6d3 100644 --- a/entproto/internal/entprototest/ent/skipedgeexample_create.go +++ b/entproto/internal/entprototest/ent/skipedgeexample_create.go @@ -45,7 +45,7 @@ func (seec *SkipEdgeExampleCreate) Mutation() *SkipEdgeExampleMutation { // Save creates the SkipEdgeExample in the database. func (seec *SkipEdgeExampleCreate) Save(ctx context.Context) (*SkipEdgeExample, error) { - return withHooks[*SkipEdgeExample, SkipEdgeExampleMutation](ctx, seec.sqlSave, seec.mutation, seec.hooks) + return withHooks(ctx, seec.sqlSave, seec.mutation, seec.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -121,11 +121,15 @@ func (seec *SkipEdgeExampleCreate) createSpec() (*SkipEdgeExample, *sqlgraph.Cre // SkipEdgeExampleCreateBulk is the builder for creating many SkipEdgeExample entities in bulk. type SkipEdgeExampleCreateBulk struct { config + err error builders []*SkipEdgeExampleCreate } // Save creates the SkipEdgeExample entities in the database. func (seecb *SkipEdgeExampleCreateBulk) Save(ctx context.Context) ([]*SkipEdgeExample, error) { + if seecb.err != nil { + return nil, seecb.err + } specs := make([]*sqlgraph.CreateSpec, len(seecb.builders)) nodes := make([]*SkipEdgeExample, len(seecb.builders)) mutators := make([]Mutator, len(seecb.builders)) diff --git a/entproto/internal/entprototest/ent/skipedgeexample_delete.go b/entproto/internal/entprototest/ent/skipedgeexample_delete.go index 8baaf49a0..b8b785eb8 100644 --- a/entproto/internal/entprototest/ent/skipedgeexample_delete.go +++ b/entproto/internal/entprototest/ent/skipedgeexample_delete.go @@ -27,7 +27,7 @@ func (seed *SkipEdgeExampleDelete) Where(ps ...predicate.SkipEdgeExample) *SkipE // Exec executes the deletion query and returns how many vertices were deleted. func (seed *SkipEdgeExampleDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, SkipEdgeExampleMutation](ctx, seed.sqlExec, seed.mutation, seed.hooks) + return withHooks(ctx, seed.sqlExec, seed.mutation, seed.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/skipedgeexample_update.go b/entproto/internal/entprototest/ent/skipedgeexample_update.go index d0f9c3c86..b57bafa7b 100644 --- a/entproto/internal/entprototest/ent/skipedgeexample_update.go +++ b/entproto/internal/entprototest/ent/skipedgeexample_update.go @@ -60,7 +60,7 @@ func (seeu *SkipEdgeExampleUpdate) ClearUser() *SkipEdgeExampleUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (seeu *SkipEdgeExampleUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, SkipEdgeExampleMutation](ctx, seeu.sqlSave, seeu.mutation, seeu.hooks) + return withHooks(ctx, seeu.sqlSave, seeu.mutation, seeu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -188,7 +188,7 @@ func (seeuo *SkipEdgeExampleUpdateOne) Select(field string, fields ...string) *S // Save executes the query and returns the updated SkipEdgeExample entity. func (seeuo *SkipEdgeExampleUpdateOne) Save(ctx context.Context) (*SkipEdgeExample, error) { - return withHooks[*SkipEdgeExample, SkipEdgeExampleMutation](ctx, seeuo.sqlSave, seeuo.mutation, seeuo.hooks) + return withHooks(ctx, seeuo.sqlSave, seeuo.mutation, seeuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/twomethodservice/where.go b/entproto/internal/entprototest/ent/twomethodservice/where.go index 0adac928f..7093b86cb 100644 --- a/entproto/internal/entprototest/ent/twomethodservice/where.go +++ b/entproto/internal/entprototest/ent/twomethodservice/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.TwoMethodService { // And groups predicates with the AND operator between them. func And(predicates ...predicate.TwoMethodService) predicate.TwoMethodService { - return predicate.TwoMethodService(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.TwoMethodService(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.TwoMethodService) predicate.TwoMethodService { - return predicate.TwoMethodService(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.TwoMethodService(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.TwoMethodService) predicate.TwoMethodService { - return predicate.TwoMethodService(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.TwoMethodService(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/twomethodservice_create.go b/entproto/internal/entprototest/ent/twomethodservice_create.go index 381200b68..d42b42060 100644 --- a/entproto/internal/entprototest/ent/twomethodservice_create.go +++ b/entproto/internal/entprototest/ent/twomethodservice_create.go @@ -25,7 +25,7 @@ func (tmsc *TwoMethodServiceCreate) Mutation() *TwoMethodServiceMutation { // Save creates the TwoMethodService in the database. func (tmsc *TwoMethodServiceCreate) Save(ctx context.Context) (*TwoMethodService, error) { - return withHooks[*TwoMethodService, TwoMethodServiceMutation](ctx, tmsc.sqlSave, tmsc.mutation, tmsc.hooks) + return withHooks(ctx, tmsc.sqlSave, tmsc.mutation, tmsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (tmsc *TwoMethodServiceCreate) createSpec() (*TwoMethodService, *sqlgraph.C // TwoMethodServiceCreateBulk is the builder for creating many TwoMethodService entities in bulk. type TwoMethodServiceCreateBulk struct { config + err error builders []*TwoMethodServiceCreate } // Save creates the TwoMethodService entities in the database. func (tmscb *TwoMethodServiceCreateBulk) Save(ctx context.Context) ([]*TwoMethodService, error) { + if tmscb.err != nil { + return nil, tmscb.err + } specs := make([]*sqlgraph.CreateSpec, len(tmscb.builders)) nodes := make([]*TwoMethodService, len(tmscb.builders)) mutators := make([]Mutator, len(tmscb.builders)) diff --git a/entproto/internal/entprototest/ent/twomethodservice_delete.go b/entproto/internal/entprototest/ent/twomethodservice_delete.go index 5ae2b736a..54d98dd9b 100644 --- a/entproto/internal/entprototest/ent/twomethodservice_delete.go +++ b/entproto/internal/entprototest/ent/twomethodservice_delete.go @@ -27,7 +27,7 @@ func (tmsd *TwoMethodServiceDelete) Where(ps ...predicate.TwoMethodService) *Two // Exec executes the deletion query and returns how many vertices were deleted. func (tmsd *TwoMethodServiceDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, TwoMethodServiceMutation](ctx, tmsd.sqlExec, tmsd.mutation, tmsd.hooks) + return withHooks(ctx, tmsd.sqlExec, tmsd.mutation, tmsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/twomethodservice_update.go b/entproto/internal/entprototest/ent/twomethodservice_update.go index 319d815f9..f5fec2003 100644 --- a/entproto/internal/entprototest/ent/twomethodservice_update.go +++ b/entproto/internal/entprototest/ent/twomethodservice_update.go @@ -34,7 +34,7 @@ func (tmsu *TwoMethodServiceUpdate) Mutation() *TwoMethodServiceMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (tmsu *TwoMethodServiceUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, TwoMethodServiceMutation](ctx, tmsu.sqlSave, tmsu.mutation, tmsu.hooks) + return withHooks(ctx, tmsu.sqlSave, tmsu.mutation, tmsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (tmsuo *TwoMethodServiceUpdateOne) Select(field string, fields ...string) * // Save executes the query and returns the updated TwoMethodService entity. func (tmsuo *TwoMethodServiceUpdateOne) Save(ctx context.Context) (*TwoMethodService, error) { - return withHooks[*TwoMethodService, TwoMethodServiceMutation](ctx, tmsuo.sqlSave, tmsuo.mutation, tmsuo.hooks) + return withHooks(ctx, tmsuo.sqlSave, tmsuo.mutation, tmsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/tx.go b/entproto/internal/entprototest/ent/tx.go index 116d1637d..212efa85f 100644 --- a/entproto/internal/entprototest/ent/tx.go +++ b/entproto/internal/entprototest/ent/tx.go @@ -22,6 +22,8 @@ type Tx struct { DependsOnSkipped *DependsOnSkippedClient // DuplicateNumberMessage is the client for interacting with the DuplicateNumberMessage builders. DuplicateNumberMessage *DuplicateNumberMessageClient + // EnumWithConflictingValue is the client for interacting with the EnumWithConflictingValue builders. + EnumWithConflictingValue *EnumWithConflictingValueClient // ExplicitSkippedMessage is the client for interacting with the ExplicitSkippedMessage builders. ExplicitSkippedMessage *ExplicitSkippedMessageClient // Image is the client for interacting with the Image builders. @@ -36,6 +38,8 @@ type Tx struct { MessageWithFieldOne *MessageWithFieldOneClient // MessageWithID is the client for interacting with the MessageWithID builders. MessageWithID *MessageWithIDClient + // MessageWithInts is the client for interacting with the MessageWithInts builders. + MessageWithInts *MessageWithIntsClient // MessageWithOptionals is the client for interacting with the MessageWithOptionals builders. MessageWithOptionals *MessageWithOptionalsClient // MessageWithPackageName is the client for interacting with the MessageWithPackageName builders. @@ -192,6 +196,7 @@ func (tx *Tx) init() { tx.Category = NewCategoryClient(tx.config) tx.DependsOnSkipped = NewDependsOnSkippedClient(tx.config) tx.DuplicateNumberMessage = NewDuplicateNumberMessageClient(tx.config) + tx.EnumWithConflictingValue = NewEnumWithConflictingValueClient(tx.config) tx.ExplicitSkippedMessage = NewExplicitSkippedMessageClient(tx.config) tx.Image = NewImageClient(tx.config) tx.ImplicitSkippedMessage = NewImplicitSkippedMessageClient(tx.config) @@ -199,6 +204,7 @@ func (tx *Tx) init() { tx.MessageWithEnum = NewMessageWithEnumClient(tx.config) tx.MessageWithFieldOne = NewMessageWithFieldOneClient(tx.config) tx.MessageWithID = NewMessageWithIDClient(tx.config) + tx.MessageWithInts = NewMessageWithIntsClient(tx.config) tx.MessageWithOptionals = NewMessageWithOptionalsClient(tx.config) tx.MessageWithPackageName = NewMessageWithPackageNameClient(tx.config) tx.MessageWithStrings = NewMessageWithStringsClient(tx.config) diff --git a/entproto/internal/entprototest/ent/user/where.go b/entproto/internal/entprototest/ent/user/where.go index cc0e09141..dcb17a740 100644 --- a/entproto/internal/entprototest/ent/user/where.go +++ b/entproto/internal/entprototest/ent/user/where.go @@ -294,32 +294,15 @@ func HasSkipEdgeWith(preds ...predicate.SkipEdgeExample) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/user_create.go b/entproto/internal/entprototest/ent/user_create.go index a39b33e02..db1b592fe 100644 --- a/entproto/internal/entprototest/ent/user_create.go +++ b/entproto/internal/entprototest/ent/user_create.go @@ -109,7 +109,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -240,11 +240,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entproto/internal/entprototest/ent/user_delete.go b/entproto/internal/entprototest/ent/user_delete.go index 683bb6464..95408a2ae 100644 --- a/entproto/internal/entprototest/ent/user_delete.go +++ b/entproto/internal/entprototest/ent/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/user_update.go b/entproto/internal/entprototest/ent/user_update.go index a458d7806..85395ebfb 100644 --- a/entproto/internal/entprototest/ent/user_update.go +++ b/entproto/internal/entprototest/ent/user_update.go @@ -37,12 +37,28 @@ func (uu *UserUpdate) SetUserName(s string) *UserUpdate { return uu } +// SetNillableUserName sets the "user_name" field if the given value is not nil. +func (uu *UserUpdate) SetNillableUserName(s *string) *UserUpdate { + if s != nil { + uu.SetUserName(*s) + } + return uu +} + // SetStatus sets the "status" field. func (uu *UserUpdate) SetStatus(u user.Status) *UserUpdate { uu.mutation.SetStatus(u) return uu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (uu *UserUpdate) SetNillableStatus(u *user.Status) *UserUpdate { + if u != nil { + uu.SetStatus(*u) + } + return uu +} + // SetUnnecessary sets the "unnecessary" field. func (uu *UserUpdate) SetUnnecessary(s string) *UserUpdate { uu.mutation.SetUnnecessary(s) @@ -156,7 +172,7 @@ func (uu *UserUpdate) ClearSkipEdge() *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -344,12 +360,28 @@ func (uuo *UserUpdateOne) SetUserName(s string) *UserUpdateOne { return uuo } +// SetNillableUserName sets the "user_name" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableUserName(s *string) *UserUpdateOne { + if s != nil { + uuo.SetUserName(*s) + } + return uuo +} + // SetStatus sets the "status" field. func (uuo *UserUpdateOne) SetStatus(u user.Status) *UserUpdateOne { uuo.mutation.SetStatus(u) return uuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableStatus(u *user.Status) *UserUpdateOne { + if u != nil { + uuo.SetStatus(*u) + } + return uuo +} + // SetUnnecessary sets the "unnecessary" field. func (uuo *UserUpdateOne) SetUnnecessary(s string) *UserUpdateOne { uuo.mutation.SetUnnecessary(s) @@ -476,7 +508,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/validmessage/where.go b/entproto/internal/entprototest/ent/validmessage/where.go index 6f56172e7..564ac3be3 100644 --- a/entproto/internal/entprototest/ent/validmessage/where.go +++ b/entproto/internal/entprototest/ent/validmessage/where.go @@ -317,32 +317,15 @@ func Opti8NotNil() predicate.ValidMessage { // And groups predicates with the AND operator between them. func And(predicates ...predicate.ValidMessage) predicate.ValidMessage { - return predicate.ValidMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.ValidMessage(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.ValidMessage) predicate.ValidMessage { - return predicate.ValidMessage(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.ValidMessage(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.ValidMessage) predicate.ValidMessage { - return predicate.ValidMessage(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.ValidMessage(sql.NotPredicates(p)) } diff --git a/entproto/internal/entprototest/ent/validmessage_create.go b/entproto/internal/entprototest/ent/validmessage_create.go index a92665150..9f408e464 100644 --- a/entproto/internal/entprototest/ent/validmessage_create.go +++ b/entproto/internal/entprototest/ent/validmessage_create.go @@ -66,7 +66,7 @@ func (vmc *ValidMessageCreate) Mutation() *ValidMessageMutation { // Save creates the ValidMessage in the database. func (vmc *ValidMessageCreate) Save(ctx context.Context) (*ValidMessage, error) { - return withHooks[*ValidMessage, ValidMessageMutation](ctx, vmc.sqlSave, vmc.mutation, vmc.hooks) + return withHooks(ctx, vmc.sqlSave, vmc.mutation, vmc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -157,11 +157,15 @@ func (vmc *ValidMessageCreate) createSpec() (*ValidMessage, *sqlgraph.CreateSpec // ValidMessageCreateBulk is the builder for creating many ValidMessage entities in bulk. type ValidMessageCreateBulk struct { config + err error builders []*ValidMessageCreate } // Save creates the ValidMessage entities in the database. func (vmcb *ValidMessageCreateBulk) Save(ctx context.Context) ([]*ValidMessage, error) { + if vmcb.err != nil { + return nil, vmcb.err + } specs := make([]*sqlgraph.CreateSpec, len(vmcb.builders)) nodes := make([]*ValidMessage, len(vmcb.builders)) mutators := make([]Mutator, len(vmcb.builders)) diff --git a/entproto/internal/entprototest/ent/validmessage_delete.go b/entproto/internal/entprototest/ent/validmessage_delete.go index ae32e5cb4..46c2cf739 100644 --- a/entproto/internal/entprototest/ent/validmessage_delete.go +++ b/entproto/internal/entprototest/ent/validmessage_delete.go @@ -27,7 +27,7 @@ func (vmd *ValidMessageDelete) Where(ps ...predicate.ValidMessage) *ValidMessage // Exec executes the deletion query and returns how many vertices were deleted. func (vmd *ValidMessageDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, ValidMessageMutation](ctx, vmd.sqlExec, vmd.mutation, vmd.hooks) + return withHooks(ctx, vmd.sqlExec, vmd.mutation, vmd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/entprototest/ent/validmessage_update.go b/entproto/internal/entprototest/ent/validmessage_update.go index 2b9e82b59..98709d24d 100644 --- a/entproto/internal/entprototest/ent/validmessage_update.go +++ b/entproto/internal/entprototest/ent/validmessage_update.go @@ -35,18 +35,42 @@ func (vmu *ValidMessageUpdate) SetName(s string) *ValidMessageUpdate { return vmu } +// SetNillableName sets the "name" field if the given value is not nil. +func (vmu *ValidMessageUpdate) SetNillableName(s *string) *ValidMessageUpdate { + if s != nil { + vmu.SetName(*s) + } + return vmu +} + // SetTs sets the "ts" field. func (vmu *ValidMessageUpdate) SetTs(t time.Time) *ValidMessageUpdate { vmu.mutation.SetTs(t) return vmu } +// SetNillableTs sets the "ts" field if the given value is not nil. +func (vmu *ValidMessageUpdate) SetNillableTs(t *time.Time) *ValidMessageUpdate { + if t != nil { + vmu.SetTs(*t) + } + return vmu +} + // SetUUID sets the "uuid" field. func (vmu *ValidMessageUpdate) SetUUID(u uuid.UUID) *ValidMessageUpdate { vmu.mutation.SetUUID(u) return vmu } +// SetNillableUUID sets the "uuid" field if the given value is not nil. +func (vmu *ValidMessageUpdate) SetNillableUUID(u *uuid.UUID) *ValidMessageUpdate { + if u != nil { + vmu.SetUUID(*u) + } + return vmu +} + // SetU8 sets the "u8" field. func (vmu *ValidMessageUpdate) SetU8(u uint8) *ValidMessageUpdate { vmu.mutation.ResetU8() @@ -54,6 +78,14 @@ func (vmu *ValidMessageUpdate) SetU8(u uint8) *ValidMessageUpdate { return vmu } +// SetNillableU8 sets the "u8" field if the given value is not nil. +func (vmu *ValidMessageUpdate) SetNillableU8(u *uint8) *ValidMessageUpdate { + if u != nil { + vmu.SetU8(*u) + } + return vmu +} + // AddU8 adds u to the "u8" field. func (vmu *ValidMessageUpdate) AddU8(u int8) *ValidMessageUpdate { vmu.mutation.AddU8(u) @@ -94,7 +126,7 @@ func (vmu *ValidMessageUpdate) Mutation() *ValidMessageMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (vmu *ValidMessageUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, ValidMessageMutation](ctx, vmu.sqlSave, vmu.mutation, vmu.hooks) + return withHooks(ctx, vmu.sqlSave, vmu.mutation, vmu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -178,18 +210,42 @@ func (vmuo *ValidMessageUpdateOne) SetName(s string) *ValidMessageUpdateOne { return vmuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (vmuo *ValidMessageUpdateOne) SetNillableName(s *string) *ValidMessageUpdateOne { + if s != nil { + vmuo.SetName(*s) + } + return vmuo +} + // SetTs sets the "ts" field. func (vmuo *ValidMessageUpdateOne) SetTs(t time.Time) *ValidMessageUpdateOne { vmuo.mutation.SetTs(t) return vmuo } +// SetNillableTs sets the "ts" field if the given value is not nil. +func (vmuo *ValidMessageUpdateOne) SetNillableTs(t *time.Time) *ValidMessageUpdateOne { + if t != nil { + vmuo.SetTs(*t) + } + return vmuo +} + // SetUUID sets the "uuid" field. func (vmuo *ValidMessageUpdateOne) SetUUID(u uuid.UUID) *ValidMessageUpdateOne { vmuo.mutation.SetUUID(u) return vmuo } +// SetNillableUUID sets the "uuid" field if the given value is not nil. +func (vmuo *ValidMessageUpdateOne) SetNillableUUID(u *uuid.UUID) *ValidMessageUpdateOne { + if u != nil { + vmuo.SetUUID(*u) + } + return vmuo +} + // SetU8 sets the "u8" field. func (vmuo *ValidMessageUpdateOne) SetU8(u uint8) *ValidMessageUpdateOne { vmuo.mutation.ResetU8() @@ -197,6 +253,14 @@ func (vmuo *ValidMessageUpdateOne) SetU8(u uint8) *ValidMessageUpdateOne { return vmuo } +// SetNillableU8 sets the "u8" field if the given value is not nil. +func (vmuo *ValidMessageUpdateOne) SetNillableU8(u *uint8) *ValidMessageUpdateOne { + if u != nil { + vmuo.SetU8(*u) + } + return vmuo +} + // AddU8 adds u to the "u8" field. func (vmuo *ValidMessageUpdateOne) AddU8(u int8) *ValidMessageUpdateOne { vmuo.mutation.AddU8(u) @@ -250,7 +314,7 @@ func (vmuo *ValidMessageUpdateOne) Select(field string, fields ...string) *Valid // Save executes the query and returns the updated ValidMessage entity. func (vmuo *ValidMessageUpdateOne) Save(ctx context.Context) (*ValidMessage, error) { - return withHooks[*ValidMessage, ValidMessageMutation](ctx, vmuo.sqlSave, vmuo.mutation, vmuo.hooks) + return withHooks(ctx, vmuo.sqlSave, vmuo.mutation, vmuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/attachment/where.go b/entproto/internal/todo/ent/attachment/where.go index 213d959b6..d0f3191ef 100644 --- a/entproto/internal/todo/ent/attachment/where.go +++ b/entproto/internal/todo/ent/attachment/where.go @@ -102,32 +102,15 @@ func HasRecipientsWith(preds ...predicate.User) predicate.Attachment { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Attachment(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Attachment(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Attachment(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/attachment_create.go b/entproto/internal/todo/ent/attachment_create.go index 624b4811a..3778c39b5 100644 --- a/entproto/internal/todo/ent/attachment_create.go +++ b/entproto/internal/todo/ent/attachment_create.go @@ -76,7 +76,7 @@ func (ac *AttachmentCreate) Mutation() *AttachmentMutation { // Save creates the Attachment in the database. func (ac *AttachmentCreate) Save(ctx context.Context) (*Attachment, error) { ac.defaults() - return withHooks[*Attachment, AttachmentMutation](ctx, ac.sqlSave, ac.mutation, ac.hooks) + return withHooks(ctx, ac.sqlSave, ac.mutation, ac.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -185,11 +185,15 @@ func (ac *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { // AttachmentCreateBulk is the builder for creating many Attachment entities in bulk. type AttachmentCreateBulk struct { config + err error builders []*AttachmentCreate } // Save creates the Attachment entities in the database. func (acb *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error) { + if acb.err != nil { + return nil, acb.err + } specs := make([]*sqlgraph.CreateSpec, len(acb.builders)) nodes := make([]*Attachment, len(acb.builders)) mutators := make([]Mutator, len(acb.builders)) diff --git a/entproto/internal/todo/ent/attachment_delete.go b/entproto/internal/todo/ent/attachment_delete.go index b30dba4e2..70dd94a2a 100644 --- a/entproto/internal/todo/ent/attachment_delete.go +++ b/entproto/internal/todo/ent/attachment_delete.go @@ -27,7 +27,7 @@ func (ad *AttachmentDelete) Where(ps ...predicate.Attachment) *AttachmentDelete // Exec executes the deletion query and returns how many vertices were deleted. func (ad *AttachmentDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, AttachmentMutation](ctx, ad.sqlExec, ad.mutation, ad.hooks) + return withHooks(ctx, ad.sqlExec, ad.mutation, ad.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/attachment_update.go b/entproto/internal/todo/ent/attachment_update.go index 61be42beb..b520993c2 100644 --- a/entproto/internal/todo/ent/attachment_update.go +++ b/entproto/internal/todo/ent/attachment_update.go @@ -96,7 +96,7 @@ func (au *AttachmentUpdate) RemoveRecipients(u ...*User) *AttachmentUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (au *AttachmentUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, AttachmentMutation](ctx, au.sqlSave, au.mutation, au.hooks) + return withHooks(ctx, au.sqlSave, au.mutation, au.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -305,7 +305,7 @@ func (auo *AttachmentUpdateOne) Select(field string, fields ...string) *Attachme // Save executes the query and returns the updated Attachment entity. func (auo *AttachmentUpdateOne) Save(ctx context.Context) (*Attachment, error) { - return withHooks[*Attachment, AttachmentMutation](ctx, auo.sqlSave, auo.mutation, auo.hooks) + return withHooks(ctx, auo.sqlSave, auo.mutation, auo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/client.go b/entproto/internal/todo/ent/client.go index de3456ccb..c1f78de0a 100644 --- a/entproto/internal/todo/ent/client.go +++ b/entproto/internal/todo/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/entproto/internal/todo/ent/migrate" "entgo.io/ent" @@ -53,9 +54,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -91,6 +90,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -138,11 +144,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -296,6 +305,21 @@ func (c *AttachmentClient) CreateBulk(builders ...*AttachmentCreate) *Attachment return &AttachmentCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AttachmentClient) MapCreateBulk(slice any, setFunc func(*AttachmentCreate, int)) *AttachmentCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AttachmentCreateBulk{err: fmt.Errorf("calling to AttachmentClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AttachmentCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AttachmentCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Attachment. func (c *AttachmentClient) Update() *AttachmentUpdate { mutation := newAttachmentMutation(c.config, OpUpdate) @@ -446,6 +470,21 @@ func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk { return &GroupCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GroupCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GroupCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Group. func (c *GroupClient) Update() *GroupUpdate { mutation := newGroupMutation(c.config, OpUpdate) @@ -580,6 +619,21 @@ func (c *MultiWordSchemaClient) CreateBulk(builders ...*MultiWordSchemaCreate) * return &MultiWordSchemaCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MultiWordSchemaClient) MapCreateBulk(slice any, setFunc func(*MultiWordSchemaCreate, int)) *MultiWordSchemaCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MultiWordSchemaCreateBulk{err: fmt.Errorf("calling to MultiWordSchemaClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MultiWordSchemaCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MultiWordSchemaCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MultiWordSchema. func (c *MultiWordSchemaClient) Update() *MultiWordSchemaUpdate { mutation := newMultiWordSchemaMutation(c.config, OpUpdate) @@ -698,6 +752,21 @@ func (c *NilExampleClient) CreateBulk(builders ...*NilExampleCreate) *NilExample return &NilExampleCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *NilExampleClient) MapCreateBulk(slice any, setFunc func(*NilExampleCreate, int)) *NilExampleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &NilExampleCreateBulk{err: fmt.Errorf("calling to NilExampleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*NilExampleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &NilExampleCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for NilExample. func (c *NilExampleClient) Update() *NilExampleUpdate { mutation := newNilExampleMutation(c.config, OpUpdate) @@ -816,6 +885,21 @@ func (c *PetClient) CreateBulk(builders ...*PetCreate) *PetCreateBulk { return &PetCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PetClient) MapCreateBulk(slice any, setFunc func(*PetCreate, int)) *PetCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PetCreateBulk{err: fmt.Errorf("calling to PetClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PetCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PetCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Pet. func (c *PetClient) Update() *PetUpdate { mutation := newPetMutation(c.config, OpUpdate) @@ -966,6 +1050,21 @@ func (c *PonyClient) CreateBulk(builders ...*PonyCreate) *PonyCreateBulk { return &PonyCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PonyClient) MapCreateBulk(slice any, setFunc func(*PonyCreate, int)) *PonyCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PonyCreateBulk{err: fmt.Errorf("calling to PonyClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PonyCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PonyCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Pony. func (c *PonyClient) Update() *PonyUpdate { mutation := newPonyMutation(c.config, OpUpdate) @@ -1084,6 +1183,21 @@ func (c *SkipEdgeExampleClient) CreateBulk(builders ...*SkipEdgeExampleCreate) * return &SkipEdgeExampleCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *SkipEdgeExampleClient) MapCreateBulk(slice any, setFunc func(*SkipEdgeExampleCreate, int)) *SkipEdgeExampleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &SkipEdgeExampleCreateBulk{err: fmt.Errorf("calling to SkipEdgeExampleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*SkipEdgeExampleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &SkipEdgeExampleCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for SkipEdgeExample. func (c *SkipEdgeExampleClient) Update() *SkipEdgeExampleUpdate { mutation := newSkipEdgeExampleMutation(c.config, OpUpdate) @@ -1218,6 +1332,21 @@ func (c *TodoClient) CreateBulk(builders ...*TodoCreate) *TodoCreateBulk { return &TodoCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TodoClient) MapCreateBulk(slice any, setFunc func(*TodoCreate, int)) *TodoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TodoCreateBulk{err: fmt.Errorf("calling to TodoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TodoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TodoCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Todo. func (c *TodoClient) Update() *TodoUpdate { mutation := newTodoMutation(c.config, OpUpdate) @@ -1352,6 +1481,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) diff --git a/entproto/internal/todo/ent/group/where.go b/entproto/internal/todo/ent/group/where.go index d3493f1d6..9eb652e5a 100644 --- a/entproto/internal/todo/ent/group/where.go +++ b/entproto/internal/todo/ent/group/where.go @@ -148,32 +148,15 @@ func HasUsersWith(preds ...predicate.User) predicate.Group { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Group(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/group_create.go b/entproto/internal/todo/ent/group_create.go index 24c023d8d..56bb43cf0 100644 --- a/entproto/internal/todo/ent/group_create.go +++ b/entproto/internal/todo/ent/group_create.go @@ -48,7 +48,7 @@ func (gc *GroupCreate) Mutation() *GroupMutation { // Save creates the Group in the database. func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) { - return withHooks[*Group, GroupMutation](ctx, gc.sqlSave, gc.mutation, gc.hooks) + return withHooks(ctx, gc.sqlSave, gc.mutation, gc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -130,11 +130,15 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { // GroupCreateBulk is the builder for creating many Group entities in bulk. type GroupCreateBulk struct { config + err error builders []*GroupCreate } // Save creates the Group entities in the database. func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { + if gcb.err != nil { + return nil, gcb.err + } specs := make([]*sqlgraph.CreateSpec, len(gcb.builders)) nodes := make([]*Group, len(gcb.builders)) mutators := make([]Mutator, len(gcb.builders)) diff --git a/entproto/internal/todo/ent/group_delete.go b/entproto/internal/todo/ent/group_delete.go index 030872eb7..e926f2bda 100644 --- a/entproto/internal/todo/ent/group_delete.go +++ b/entproto/internal/todo/ent/group_delete.go @@ -27,7 +27,7 @@ func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (gd *GroupDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gd.sqlExec, gd.mutation, gd.hooks) + return withHooks(ctx, gd.sqlExec, gd.mutation, gd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/group_update.go b/entproto/internal/todo/ent/group_update.go index a3e3ddd95..114961bdc 100644 --- a/entproto/internal/todo/ent/group_update.go +++ b/entproto/internal/todo/ent/group_update.go @@ -34,6 +34,14 @@ func (gu *GroupUpdate) SetName(s string) *GroupUpdate { return gu } +// SetNillableName sets the "name" field if the given value is not nil. +func (gu *GroupUpdate) SetNillableName(s *string) *GroupUpdate { + if s != nil { + gu.SetName(*s) + } + return gu +} + // AddUserIDs adds the "users" edge to the User entity by IDs. func (gu *GroupUpdate) AddUserIDs(ids ...uint32) *GroupUpdate { gu.mutation.AddUserIDs(ids...) @@ -77,7 +85,7 @@ func (gu *GroupUpdate) RemoveUsers(u ...*User) *GroupUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (gu *GroupUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, GroupMutation](ctx, gu.sqlSave, gu.mutation, gu.hooks) + return withHooks(ctx, gu.sqlSave, gu.mutation, gu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -185,6 +193,14 @@ func (guo *GroupUpdateOne) SetName(s string) *GroupUpdateOne { return guo } +// SetNillableName sets the "name" field if the given value is not nil. +func (guo *GroupUpdateOne) SetNillableName(s *string) *GroupUpdateOne { + if s != nil { + guo.SetName(*s) + } + return guo +} + // AddUserIDs adds the "users" edge to the User entity by IDs. func (guo *GroupUpdateOne) AddUserIDs(ids ...uint32) *GroupUpdateOne { guo.mutation.AddUserIDs(ids...) @@ -241,7 +257,7 @@ func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOn // Save executes the query and returns the updated Group entity. func (guo *GroupUpdateOne) Save(ctx context.Context) (*Group, error) { - return withHooks[*Group, GroupMutation](ctx, guo.sqlSave, guo.mutation, guo.hooks) + return withHooks(ctx, guo.sqlSave, guo.mutation, guo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/migrate/schema.go b/entproto/internal/todo/ent/migrate/schema.go index faa9a7de2..7e232ab9f 100644 --- a/entproto/internal/todo/ent/migrate/schema.go +++ b/entproto/internal/todo/ent/migrate/schema.go @@ -160,8 +160,13 @@ var ( {Name: "unnecessary", Type: field.TypeString, Nullable: true}, {Name: "type", Type: field.TypeString, Nullable: true}, {Name: "labels", Type: field.TypeJSON, Nullable: true}, + {Name: "int32s", Type: field.TypeJSON, Nullable: true}, + {Name: "int64s", Type: field.TypeJSON, Nullable: true}, + {Name: "uint32s", Type: field.TypeJSON, Nullable: true}, + {Name: "uint64s", Type: field.TypeJSON, Nullable: true}, {Name: "device_type", Type: field.TypeEnum, Enums: []string{"GLOWY9000", "SPEEDY300"}, Default: "GLOWY9000"}, {Name: "omit_prefix", Type: field.TypeEnum, Enums: []string{"foo", "bar"}}, + {Name: "mime_type", Type: field.TypeEnum, Enums: []string{"image/png", "image/xml+svg"}}, {Name: "user_group", Type: field.TypeInt, Nullable: true}, } // UsersTable holds the schema information for the "users" table. @@ -172,7 +177,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "users_groups_group", - Columns: []*schema.Column{UsersColumns[22]}, + Columns: []*schema.Column{UsersColumns[27]}, RefColumns: []*schema.Column{GroupsColumns[0]}, OnDelete: schema.SetNull, }, diff --git a/entproto/internal/todo/ent/multiwordschema/where.go b/entproto/internal/todo/ent/multiwordschema/where.go index 3358036eb..89af9dd12 100644 --- a/entproto/internal/todo/ent/multiwordschema/where.go +++ b/entproto/internal/todo/ent/multiwordschema/where.go @@ -74,32 +74,15 @@ func UnitNotIn(vs ...Unit) predicate.MultiWordSchema { // And groups predicates with the AND operator between them. func And(predicates ...predicate.MultiWordSchema) predicate.MultiWordSchema { - return predicate.MultiWordSchema(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MultiWordSchema(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MultiWordSchema) predicate.MultiWordSchema { - return predicate.MultiWordSchema(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MultiWordSchema(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MultiWordSchema) predicate.MultiWordSchema { - return predicate.MultiWordSchema(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MultiWordSchema(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/multiwordschema_create.go b/entproto/internal/todo/ent/multiwordschema_create.go index 57c540482..acbcf3a2b 100644 --- a/entproto/internal/todo/ent/multiwordschema_create.go +++ b/entproto/internal/todo/ent/multiwordschema_create.go @@ -41,7 +41,7 @@ func (mwsc *MultiWordSchemaCreate) Mutation() *MultiWordSchemaMutation { // Save creates the MultiWordSchema in the database. func (mwsc *MultiWordSchemaCreate) Save(ctx context.Context) (*MultiWordSchema, error) { mwsc.defaults() - return withHooks[*MultiWordSchema, MultiWordSchemaMutation](ctx, mwsc.sqlSave, mwsc.mutation, mwsc.hooks) + return withHooks(ctx, mwsc.sqlSave, mwsc.mutation, mwsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -120,11 +120,15 @@ func (mwsc *MultiWordSchemaCreate) createSpec() (*MultiWordSchema, *sqlgraph.Cre // MultiWordSchemaCreateBulk is the builder for creating many MultiWordSchema entities in bulk. type MultiWordSchemaCreateBulk struct { config + err error builders []*MultiWordSchemaCreate } // Save creates the MultiWordSchema entities in the database. func (mwscb *MultiWordSchemaCreateBulk) Save(ctx context.Context) ([]*MultiWordSchema, error) { + if mwscb.err != nil { + return nil, mwscb.err + } specs := make([]*sqlgraph.CreateSpec, len(mwscb.builders)) nodes := make([]*MultiWordSchema, len(mwscb.builders)) mutators := make([]Mutator, len(mwscb.builders)) diff --git a/entproto/internal/todo/ent/multiwordschema_delete.go b/entproto/internal/todo/ent/multiwordschema_delete.go index e3f3d41db..da4a5f12d 100644 --- a/entproto/internal/todo/ent/multiwordschema_delete.go +++ b/entproto/internal/todo/ent/multiwordschema_delete.go @@ -27,7 +27,7 @@ func (mwsd *MultiWordSchemaDelete) Where(ps ...predicate.MultiWordSchema) *Multi // Exec executes the deletion query and returns how many vertices were deleted. func (mwsd *MultiWordSchemaDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MultiWordSchemaMutation](ctx, mwsd.sqlExec, mwsd.mutation, mwsd.hooks) + return withHooks(ctx, mwsd.sqlExec, mwsd.mutation, mwsd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/multiwordschema_update.go b/entproto/internal/todo/ent/multiwordschema_update.go index 579d98260..b4523907c 100644 --- a/entproto/internal/todo/ent/multiwordschema_update.go +++ b/entproto/internal/todo/ent/multiwordschema_update.go @@ -48,7 +48,7 @@ func (mwsu *MultiWordSchemaUpdate) Mutation() *MultiWordSchemaMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (mwsu *MultiWordSchemaUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MultiWordSchemaMutation](ctx, mwsu.sqlSave, mwsu.mutation, mwsu.hooks) + return withHooks(ctx, mwsu.sqlSave, mwsu.mutation, mwsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -152,7 +152,7 @@ func (mwsuo *MultiWordSchemaUpdateOne) Select(field string, fields ...string) *M // Save executes the query and returns the updated MultiWordSchema entity. func (mwsuo *MultiWordSchemaUpdateOne) Save(ctx context.Context) (*MultiWordSchema, error) { - return withHooks[*MultiWordSchema, MultiWordSchemaMutation](ctx, mwsuo.sqlSave, mwsuo.mutation, mwsuo.hooks) + return withHooks(ctx, mwsuo.sqlSave, mwsuo.mutation, mwsuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/mutation.go b/entproto/internal/todo/ent/mutation.go index 214d3a785..d2288b0b6 100644 --- a/entproto/internal/todo/ent/mutation.go +++ b/entproto/internal/todo/ent/mutation.go @@ -3187,8 +3187,17 @@ type UserMutation struct { _type *string labels *[]string appendlabels []string + int32s *[]int32 + appendint32s []int32 + int64s *[]int64 + appendint64s []int64 + uint32s *[]uint32 + appenduint32s []uint32 + uint64s *[]uint64 + appenduint64s []uint64 device_type *user.DeviceType omit_prefix *user.OmitPrefix + mime_type *user.MimeType clearedFields map[string]struct{} group *int clearedgroup bool @@ -4276,6 +4285,266 @@ func (m *UserMutation) ResetLabels() { delete(m.clearedFields, user.FieldLabels) } +// SetInt32s sets the "int32s" field. +func (m *UserMutation) SetInt32s(i []int32) { + m.int32s = &i + m.appendint32s = nil +} + +// Int32s returns the value of the "int32s" field in the mutation. +func (m *UserMutation) Int32s() (r []int32, exists bool) { + v := m.int32s + if v == nil { + return + } + return *v, true +} + +// OldInt32s returns the old "int32s" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldInt32s(ctx context.Context) (v []int32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInt32s is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInt32s requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInt32s: %w", err) + } + return oldValue.Int32s, nil +} + +// AppendInt32s adds i to the "int32s" field. +func (m *UserMutation) AppendInt32s(i []int32) { + m.appendint32s = append(m.appendint32s, i...) +} + +// AppendedInt32s returns the list of values that were appended to the "int32s" field in this mutation. +func (m *UserMutation) AppendedInt32s() ([]int32, bool) { + if len(m.appendint32s) == 0 { + return nil, false + } + return m.appendint32s, true +} + +// ClearInt32s clears the value of the "int32s" field. +func (m *UserMutation) ClearInt32s() { + m.int32s = nil + m.appendint32s = nil + m.clearedFields[user.FieldInt32s] = struct{}{} +} + +// Int32sCleared returns if the "int32s" field was cleared in this mutation. +func (m *UserMutation) Int32sCleared() bool { + _, ok := m.clearedFields[user.FieldInt32s] + return ok +} + +// ResetInt32s resets all changes to the "int32s" field. +func (m *UserMutation) ResetInt32s() { + m.int32s = nil + m.appendint32s = nil + delete(m.clearedFields, user.FieldInt32s) +} + +// SetInt64s sets the "int64s" field. +func (m *UserMutation) SetInt64s(i []int64) { + m.int64s = &i + m.appendint64s = nil +} + +// Int64s returns the value of the "int64s" field in the mutation. +func (m *UserMutation) Int64s() (r []int64, exists bool) { + v := m.int64s + if v == nil { + return + } + return *v, true +} + +// OldInt64s returns the old "int64s" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldInt64s(ctx context.Context) (v []int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInt64s is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInt64s requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInt64s: %w", err) + } + return oldValue.Int64s, nil +} + +// AppendInt64s adds i to the "int64s" field. +func (m *UserMutation) AppendInt64s(i []int64) { + m.appendint64s = append(m.appendint64s, i...) +} + +// AppendedInt64s returns the list of values that were appended to the "int64s" field in this mutation. +func (m *UserMutation) AppendedInt64s() ([]int64, bool) { + if len(m.appendint64s) == 0 { + return nil, false + } + return m.appendint64s, true +} + +// ClearInt64s clears the value of the "int64s" field. +func (m *UserMutation) ClearInt64s() { + m.int64s = nil + m.appendint64s = nil + m.clearedFields[user.FieldInt64s] = struct{}{} +} + +// Int64sCleared returns if the "int64s" field was cleared in this mutation. +func (m *UserMutation) Int64sCleared() bool { + _, ok := m.clearedFields[user.FieldInt64s] + return ok +} + +// ResetInt64s resets all changes to the "int64s" field. +func (m *UserMutation) ResetInt64s() { + m.int64s = nil + m.appendint64s = nil + delete(m.clearedFields, user.FieldInt64s) +} + +// SetUint32s sets the "uint32s" field. +func (m *UserMutation) SetUint32s(u []uint32) { + m.uint32s = &u + m.appenduint32s = nil +} + +// Uint32s returns the value of the "uint32s" field in the mutation. +func (m *UserMutation) Uint32s() (r []uint32, exists bool) { + v := m.uint32s + if v == nil { + return + } + return *v, true +} + +// OldUint32s returns the old "uint32s" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUint32s(ctx context.Context) (v []uint32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUint32s is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUint32s requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUint32s: %w", err) + } + return oldValue.Uint32s, nil +} + +// AppendUint32s adds u to the "uint32s" field. +func (m *UserMutation) AppendUint32s(u []uint32) { + m.appenduint32s = append(m.appenduint32s, u...) +} + +// AppendedUint32s returns the list of values that were appended to the "uint32s" field in this mutation. +func (m *UserMutation) AppendedUint32s() ([]uint32, bool) { + if len(m.appenduint32s) == 0 { + return nil, false + } + return m.appenduint32s, true +} + +// ClearUint32s clears the value of the "uint32s" field. +func (m *UserMutation) ClearUint32s() { + m.uint32s = nil + m.appenduint32s = nil + m.clearedFields[user.FieldUint32s] = struct{}{} +} + +// Uint32sCleared returns if the "uint32s" field was cleared in this mutation. +func (m *UserMutation) Uint32sCleared() bool { + _, ok := m.clearedFields[user.FieldUint32s] + return ok +} + +// ResetUint32s resets all changes to the "uint32s" field. +func (m *UserMutation) ResetUint32s() { + m.uint32s = nil + m.appenduint32s = nil + delete(m.clearedFields, user.FieldUint32s) +} + +// SetUint64s sets the "uint64s" field. +func (m *UserMutation) SetUint64s(u []uint64) { + m.uint64s = &u + m.appenduint64s = nil +} + +// Uint64s returns the value of the "uint64s" field in the mutation. +func (m *UserMutation) Uint64s() (r []uint64, exists bool) { + v := m.uint64s + if v == nil { + return + } + return *v, true +} + +// OldUint64s returns the old "uint64s" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUint64s(ctx context.Context) (v []uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUint64s is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUint64s requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUint64s: %w", err) + } + return oldValue.Uint64s, nil +} + +// AppendUint64s adds u to the "uint64s" field. +func (m *UserMutation) AppendUint64s(u []uint64) { + m.appenduint64s = append(m.appenduint64s, u...) +} + +// AppendedUint64s returns the list of values that were appended to the "uint64s" field in this mutation. +func (m *UserMutation) AppendedUint64s() ([]uint64, bool) { + if len(m.appenduint64s) == 0 { + return nil, false + } + return m.appenduint64s, true +} + +// ClearUint64s clears the value of the "uint64s" field. +func (m *UserMutation) ClearUint64s() { + m.uint64s = nil + m.appenduint64s = nil + m.clearedFields[user.FieldUint64s] = struct{}{} +} + +// Uint64sCleared returns if the "uint64s" field was cleared in this mutation. +func (m *UserMutation) Uint64sCleared() bool { + _, ok := m.clearedFields[user.FieldUint64s] + return ok +} + +// ResetUint64s resets all changes to the "uint64s" field. +func (m *UserMutation) ResetUint64s() { + m.uint64s = nil + m.appenduint64s = nil + delete(m.clearedFields, user.FieldUint64s) +} + // SetDeviceType sets the "device_type" field. func (m *UserMutation) SetDeviceType(ut user.DeviceType) { m.device_type = &ut @@ -4348,6 +4617,42 @@ func (m *UserMutation) ResetOmitPrefix() { m.omit_prefix = nil } +// SetMimeType sets the "mime_type" field. +func (m *UserMutation) SetMimeType(ut user.MimeType) { + m.mime_type = &ut +} + +// MimeType returns the value of the "mime_type" field in the mutation. +func (m *UserMutation) MimeType() (r user.MimeType, exists bool) { + v := m.mime_type + if v == nil { + return + } + return *v, true +} + +// OldMimeType returns the old "mime_type" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldMimeType(ctx context.Context) (v user.MimeType, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMimeType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMimeType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMimeType: %w", err) + } + return oldValue.MimeType, nil +} + +// ResetMimeType resets all changes to the "mime_type" field. +func (m *UserMutation) ResetMimeType() { + m.mime_type = nil +} + // SetGroupID sets the "group" edge to the Group entity by id. func (m *UserMutation) SetGroupID(id int) { m.group = &id @@ -4592,7 +4897,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 21) + fields := make([]string, 0, 26) if m.user_name != nil { fields = append(fields, user.FieldUserName) } @@ -4650,12 +4955,27 @@ func (m *UserMutation) Fields() []string { if m.labels != nil { fields = append(fields, user.FieldLabels) } + if m.int32s != nil { + fields = append(fields, user.FieldInt32s) + } + if m.int64s != nil { + fields = append(fields, user.FieldInt64s) + } + if m.uint32s != nil { + fields = append(fields, user.FieldUint32s) + } + if m.uint64s != nil { + fields = append(fields, user.FieldUint64s) + } if m.device_type != nil { fields = append(fields, user.FieldDeviceType) } if m.omit_prefix != nil { fields = append(fields, user.FieldOmitPrefix) } + if m.mime_type != nil { + fields = append(fields, user.FieldMimeType) + } return fields } @@ -4702,10 +5022,20 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.GetType() case user.FieldLabels: return m.Labels() + case user.FieldInt32s: + return m.Int32s() + case user.FieldInt64s: + return m.Int64s() + case user.FieldUint32s: + return m.Uint32s() + case user.FieldUint64s: + return m.Uint64s() case user.FieldDeviceType: return m.DeviceType() case user.FieldOmitPrefix: return m.OmitPrefix() + case user.FieldMimeType: + return m.MimeType() } return nil, false } @@ -4753,10 +5083,20 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldType(ctx) case user.FieldLabels: return m.OldLabels(ctx) + case user.FieldInt32s: + return m.OldInt32s(ctx) + case user.FieldInt64s: + return m.OldInt64s(ctx) + case user.FieldUint32s: + return m.OldUint32s(ctx) + case user.FieldUint64s: + return m.OldUint64s(ctx) case user.FieldDeviceType: return m.OldDeviceType(ctx) case user.FieldOmitPrefix: return m.OldOmitPrefix(ctx) + case user.FieldMimeType: + return m.OldMimeType(ctx) } return nil, fmt.Errorf("unknown User field %s", name) } @@ -4899,6 +5239,34 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetLabels(v) return nil + case user.FieldInt32s: + v, ok := value.([]int32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInt32s(v) + return nil + case user.FieldInt64s: + v, ok := value.([]int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInt64s(v) + return nil + case user.FieldUint32s: + v, ok := value.([]uint32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUint32s(v) + return nil + case user.FieldUint64s: + v, ok := value.([]uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUint64s(v) + return nil case user.FieldDeviceType: v, ok := value.(user.DeviceType) if !ok { @@ -4913,6 +5281,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetOmitPrefix(v) return nil + case user.FieldMimeType: + v, ok := value.(user.MimeType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMimeType(v) + return nil } return fmt.Errorf("unknown User field %s", name) } @@ -5066,6 +5441,18 @@ func (m *UserMutation) ClearedFields() []string { if m.FieldCleared(user.FieldLabels) { fields = append(fields, user.FieldLabels) } + if m.FieldCleared(user.FieldInt32s) { + fields = append(fields, user.FieldInt32s) + } + if m.FieldCleared(user.FieldInt64s) { + fields = append(fields, user.FieldInt64s) + } + if m.FieldCleared(user.FieldUint32s) { + fields = append(fields, user.FieldUint32s) + } + if m.FieldCleared(user.FieldUint64s) { + fields = append(fields, user.FieldUint64s) + } return fields } @@ -5104,6 +5491,18 @@ func (m *UserMutation) ClearField(name string) error { case user.FieldLabels: m.ClearLabels() return nil + case user.FieldInt32s: + m.ClearInt32s() + return nil + case user.FieldInt64s: + m.ClearInt64s() + return nil + case user.FieldUint32s: + m.ClearUint32s() + return nil + case user.FieldUint64s: + m.ClearUint64s() + return nil } return fmt.Errorf("unknown User nullable field %s", name) } @@ -5169,12 +5568,27 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldLabels: m.ResetLabels() return nil + case user.FieldInt32s: + m.ResetInt32s() + return nil + case user.FieldInt64s: + m.ResetInt64s() + return nil + case user.FieldUint32s: + m.ResetUint32s() + return nil + case user.FieldUint64s: + m.ResetUint64s() + return nil case user.FieldDeviceType: m.ResetDeviceType() return nil case user.FieldOmitPrefix: m.ResetOmitPrefix() return nil + case user.FieldMimeType: + m.ResetMimeType() + return nil } return fmt.Errorf("unknown User field %s", name) } diff --git a/entproto/internal/todo/ent/nilexample/where.go b/entproto/internal/todo/ent/nilexample/where.go index 41b69cc00..746891ee5 100644 --- a/entproto/internal/todo/ent/nilexample/where.go +++ b/entproto/internal/todo/ent/nilexample/where.go @@ -191,32 +191,15 @@ func TimeNilNotNil() predicate.NilExample { // And groups predicates with the AND operator between them. func And(predicates ...predicate.NilExample) predicate.NilExample { - return predicate.NilExample(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.NilExample(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.NilExample) predicate.NilExample { - return predicate.NilExample(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.NilExample(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.NilExample) predicate.NilExample { - return predicate.NilExample(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.NilExample(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/nilexample_create.go b/entproto/internal/todo/ent/nilexample_create.go index e8798bd84..5cb001641 100644 --- a/entproto/internal/todo/ent/nilexample_create.go +++ b/entproto/internal/todo/ent/nilexample_create.go @@ -54,7 +54,7 @@ func (nec *NilExampleCreate) Mutation() *NilExampleMutation { // Save creates the NilExample in the database. func (nec *NilExampleCreate) Save(ctx context.Context) (*NilExample, error) { - return withHooks[*NilExample, NilExampleMutation](ctx, nec.sqlSave, nec.mutation, nec.hooks) + return withHooks(ctx, nec.sqlSave, nec.mutation, nec.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -121,11 +121,15 @@ func (nec *NilExampleCreate) createSpec() (*NilExample, *sqlgraph.CreateSpec) { // NilExampleCreateBulk is the builder for creating many NilExample entities in bulk. type NilExampleCreateBulk struct { config + err error builders []*NilExampleCreate } // Save creates the NilExample entities in the database. func (necb *NilExampleCreateBulk) Save(ctx context.Context) ([]*NilExample, error) { + if necb.err != nil { + return nil, necb.err + } specs := make([]*sqlgraph.CreateSpec, len(necb.builders)) nodes := make([]*NilExample, len(necb.builders)) mutators := make([]Mutator, len(necb.builders)) diff --git a/entproto/internal/todo/ent/nilexample_delete.go b/entproto/internal/todo/ent/nilexample_delete.go index 755b4b3b7..2f7ed6e0b 100644 --- a/entproto/internal/todo/ent/nilexample_delete.go +++ b/entproto/internal/todo/ent/nilexample_delete.go @@ -27,7 +27,7 @@ func (ned *NilExampleDelete) Where(ps ...predicate.NilExample) *NilExampleDelete // Exec executes the deletion query and returns how many vertices were deleted. func (ned *NilExampleDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, NilExampleMutation](ctx, ned.sqlExec, ned.mutation, ned.hooks) + return withHooks(ctx, ned.sqlExec, ned.mutation, ned.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/nilexample_update.go b/entproto/internal/todo/ent/nilexample_update.go index 65f7d3339..a76679801 100644 --- a/entproto/internal/todo/ent/nilexample_update.go +++ b/entproto/internal/todo/ent/nilexample_update.go @@ -75,7 +75,7 @@ func (neu *NilExampleUpdate) Mutation() *NilExampleMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (neu *NilExampleUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, NilExampleMutation](ctx, neu.sqlSave, neu.mutation, neu.hooks) + return withHooks(ctx, neu.sqlSave, neu.mutation, neu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -201,7 +201,7 @@ func (neuo *NilExampleUpdateOne) Select(field string, fields ...string) *NilExam // Save executes the query and returns the updated NilExample entity. func (neuo *NilExampleUpdateOne) Save(ctx context.Context) (*NilExample, error) { - return withHooks[*NilExample, NilExampleMutation](ctx, neuo.sqlSave, neuo.mutation, neuo.hooks) + return withHooks(ctx, neuo.sqlSave, neuo.mutation, neuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/pet/where.go b/entproto/internal/todo/ent/pet/where.go index 5d35c8db7..c2c52d1f4 100644 --- a/entproto/internal/todo/ent/pet/where.go +++ b/entproto/internal/todo/ent/pet/where.go @@ -101,32 +101,15 @@ func HasAttachmentWith(preds ...predicate.Attachment) predicate.Pet { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pet(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pet(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Pet) predicate.Pet { - return predicate.Pet(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Pet(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/pet_create.go b/entproto/internal/todo/ent/pet_create.go index 61c28a39b..e63fbcc87 100644 --- a/entproto/internal/todo/ent/pet_create.go +++ b/entproto/internal/todo/ent/pet_create.go @@ -62,7 +62,7 @@ func (pc *PetCreate) Mutation() *PetMutation { // Save creates the Pet in the database. func (pc *PetCreate) Save(ctx context.Context) (*Pet, error) { - return withHooks[*Pet, PetMutation](ctx, pc.sqlSave, pc.mutation, pc.hooks) + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -154,11 +154,15 @@ func (pc *PetCreate) createSpec() (*Pet, *sqlgraph.CreateSpec) { // PetCreateBulk is the builder for creating many Pet entities in bulk. type PetCreateBulk struct { config + err error builders []*PetCreate } // Save creates the Pet entities in the database. func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { + if pcb.err != nil { + return nil, pcb.err + } specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) nodes := make([]*Pet, len(pcb.builders)) mutators := make([]Mutator, len(pcb.builders)) diff --git a/entproto/internal/todo/ent/pet_delete.go b/entproto/internal/todo/ent/pet_delete.go index aeac61183..34c87ae8c 100644 --- a/entproto/internal/todo/ent/pet_delete.go +++ b/entproto/internal/todo/ent/pet_delete.go @@ -27,7 +27,7 @@ func (pd *PetDelete) Where(ps ...predicate.Pet) *PetDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (pd *PetDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, PetMutation](ctx, pd.sqlExec, pd.mutation, pd.hooks) + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/pet_update.go b/entproto/internal/todo/ent/pet_update.go index 134282849..a41b1cd0f 100644 --- a/entproto/internal/todo/ent/pet_update.go +++ b/entproto/internal/todo/ent/pet_update.go @@ -98,7 +98,7 @@ func (pu *PetUpdate) RemoveAttachment(a ...*Attachment) *PetUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *PetUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, PetMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks) + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -307,7 +307,7 @@ func (puo *PetUpdateOne) Select(field string, fields ...string) *PetUpdateOne { // Save executes the query and returns the updated Pet entity. func (puo *PetUpdateOne) Save(ctx context.Context) (*Pet, error) { - return withHooks[*Pet, PetMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks) + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/pony/where.go b/entproto/internal/todo/ent/pony/where.go index 4e8c08df6..dc6da6b33 100644 --- a/entproto/internal/todo/ent/pony/where.go +++ b/entproto/internal/todo/ent/pony/where.go @@ -124,32 +124,15 @@ func NameContainsFold(v string) predicate.Pony { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Pony) predicate.Pony { - return predicate.Pony(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pony(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Pony) predicate.Pony { - return predicate.Pony(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Pony(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Pony) predicate.Pony { - return predicate.Pony(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Pony(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/pony_create.go b/entproto/internal/todo/ent/pony_create.go index 541b0f508..226d0dda6 100644 --- a/entproto/internal/todo/ent/pony_create.go +++ b/entproto/internal/todo/ent/pony_create.go @@ -32,7 +32,7 @@ func (pc *PonyCreate) Mutation() *PonyMutation { // Save creates the Pony in the database. func (pc *PonyCreate) Save(ctx context.Context) (*Pony, error) { - return withHooks[*Pony, PonyMutation](ctx, pc.sqlSave, pc.mutation, pc.hooks) + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -98,11 +98,15 @@ func (pc *PonyCreate) createSpec() (*Pony, *sqlgraph.CreateSpec) { // PonyCreateBulk is the builder for creating many Pony entities in bulk. type PonyCreateBulk struct { config + err error builders []*PonyCreate } // Save creates the Pony entities in the database. func (pcb *PonyCreateBulk) Save(ctx context.Context) ([]*Pony, error) { + if pcb.err != nil { + return nil, pcb.err + } specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) nodes := make([]*Pony, len(pcb.builders)) mutators := make([]Mutator, len(pcb.builders)) diff --git a/entproto/internal/todo/ent/pony_delete.go b/entproto/internal/todo/ent/pony_delete.go index 86f3a192d..c348b6b7f 100644 --- a/entproto/internal/todo/ent/pony_delete.go +++ b/entproto/internal/todo/ent/pony_delete.go @@ -27,7 +27,7 @@ func (pd *PonyDelete) Where(ps ...predicate.Pony) *PonyDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (pd *PonyDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, PonyMutation](ctx, pd.sqlExec, pd.mutation, pd.hooks) + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/pony_update.go b/entproto/internal/todo/ent/pony_update.go index 2621c4d64..42dbedd3d 100644 --- a/entproto/internal/todo/ent/pony_update.go +++ b/entproto/internal/todo/ent/pony_update.go @@ -33,6 +33,14 @@ func (pu *PonyUpdate) SetName(s string) *PonyUpdate { return pu } +// SetNillableName sets the "name" field if the given value is not nil. +func (pu *PonyUpdate) SetNillableName(s *string) *PonyUpdate { + if s != nil { + pu.SetName(*s) + } + return pu +} + // Mutation returns the PonyMutation object of the builder. func (pu *PonyUpdate) Mutation() *PonyMutation { return pu.mutation @@ -40,7 +48,7 @@ func (pu *PonyUpdate) Mutation() *PonyMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *PonyUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, PonyMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks) + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -103,6 +111,14 @@ func (puo *PonyUpdateOne) SetName(s string) *PonyUpdateOne { return puo } +// SetNillableName sets the "name" field if the given value is not nil. +func (puo *PonyUpdateOne) SetNillableName(s *string) *PonyUpdateOne { + if s != nil { + puo.SetName(*s) + } + return puo +} + // Mutation returns the PonyMutation object of the builder. func (puo *PonyUpdateOne) Mutation() *PonyMutation { return puo.mutation @@ -123,7 +139,7 @@ func (puo *PonyUpdateOne) Select(field string, fields ...string) *PonyUpdateOne // Save executes the query and returns the updated Pony entity. func (puo *PonyUpdateOne) Save(ctx context.Context) (*Pony, error) { - return withHooks[*Pony, PonyMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks) + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/proto/entpb/attachment_service_test.go b/entproto/internal/todo/ent/proto/entpb/attachment_service_test.go index 976d06779..e67599cb9 100644 --- a/entproto/internal/todo/ent/proto/entpb/attachment_service_test.go +++ b/entproto/internal/todo/ent/proto/entpb/attachment_service_test.go @@ -71,6 +71,7 @@ func TestAttachmentService_MultiEdge(t *testing.T) { SetCustomPb(1). SetLabels(nil). SetOmitPrefix(user.OmitPrefixFoo). + SetMimeType(user.MimeTypeSvg). SaveX(ctx)) } att, err := svc.Create(ctx, &CreateAttachmentRequest{Attachment: &Attachment{ diff --git a/entproto/internal/todo/ent/proto/entpb/entpb.pb.go b/entproto/internal/todo/ent/proto/entpb/entpb.pb.go index 18fca8b71..e1207ad6b 100644 --- a/entproto/internal/todo/ent/proto/entpb/entpb.pb.go +++ b/entproto/internal/todo/ent/proto/entpb/entpb.pb.go @@ -656,6 +656,55 @@ func (User_OmitPrefix) EnumDescriptor() ([]byte, []int) { return file_entpb_entpb_proto_rawDescGZIP(), []int{42, 2} } +type User_MimeType int32 + +const ( + User_MIME_TYPE_UNSPECIFIED User_MimeType = 0 + User_MIME_TYPE_IMAGE_PNG User_MimeType = 1 + User_MIME_TYPE_IMAGE_XML_SVG User_MimeType = 2 +) + +// Enum value maps for User_MimeType. +var ( + User_MimeType_name = map[int32]string{ + 0: "MIME_TYPE_UNSPECIFIED", + 1: "MIME_TYPE_IMAGE_PNG", + 2: "MIME_TYPE_IMAGE_XML_SVG", + } + User_MimeType_value = map[string]int32{ + "MIME_TYPE_UNSPECIFIED": 0, + "MIME_TYPE_IMAGE_PNG": 1, + "MIME_TYPE_IMAGE_XML_SVG": 2, + } +) + +func (x User_MimeType) Enum() *User_MimeType { + p := new(User_MimeType) + *p = x + return p +} + +func (x User_MimeType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (User_MimeType) Descriptor() protoreflect.EnumDescriptor { + return file_entpb_entpb_proto_enumTypes[13].Descriptor() +} + +func (User_MimeType) Type() protoreflect.EnumType { + return &file_entpb_entpb_proto_enumTypes[13] +} + +func (x User_MimeType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use User_MimeType.Descriptor instead. +func (User_MimeType) EnumDescriptor() ([]byte, []int) { + return file_entpb_entpb_proto_rawDescGZIP(), []int{42, 3} +} + type GetUserRequest_View int32 const ( @@ -689,11 +738,11 @@ func (x GetUserRequest_View) String() string { } func (GetUserRequest_View) Descriptor() protoreflect.EnumDescriptor { - return file_entpb_entpb_proto_enumTypes[13].Descriptor() + return file_entpb_entpb_proto_enumTypes[14].Descriptor() } func (GetUserRequest_View) Type() protoreflect.EnumType { - return &file_entpb_entpb_proto_enumTypes[13] + return &file_entpb_entpb_proto_enumTypes[14] } func (x GetUserRequest_View) Number() protoreflect.EnumNumber { @@ -738,11 +787,11 @@ func (x ListUserRequest_View) String() string { } func (ListUserRequest_View) Descriptor() protoreflect.EnumDescriptor { - return file_entpb_entpb_proto_enumTypes[14].Descriptor() + return file_entpb_entpb_proto_enumTypes[15].Descriptor() } func (ListUserRequest_View) Type() protoreflect.EnumType { - return &file_entpb_entpb_proto_enumTypes[14] + return &file_entpb_entpb_proto_enumTypes[15] } func (x ListUserRequest_View) Number() protoreflect.EnumNumber { @@ -2984,8 +3033,13 @@ type User struct { AccountBalance float64 `protobuf:"fixed64,20,opt,name=account_balance,json=accountBalance,proto3" json:"account_balance,omitempty"` Type *wrapperspb.StringValue `protobuf:"bytes,23,opt,name=type,proto3" json:"type,omitempty"` Labels []string `protobuf:"bytes,24,rep,name=labels,proto3" json:"labels,omitempty"` + Int32S []int32 `protobuf:"varint,25,rep,packed,name=int32s,proto3" json:"int32s,omitempty"` + Int64S []int64 `protobuf:"varint,26,rep,packed,name=int64s,proto3" json:"int64s,omitempty"` + Uint32S []uint32 `protobuf:"varint,27,rep,packed,name=uint32s,proto3" json:"uint32s,omitempty"` + Uint64S []uint64 `protobuf:"varint,28,rep,packed,name=uint64s,proto3" json:"uint64s,omitempty"` DeviceType User_DeviceType `protobuf:"varint,100,opt,name=device_type,json=deviceType,proto3,enum=entpb.User_DeviceType" json:"device_type,omitempty"` OmitPrefix User_OmitPrefix `protobuf:"varint,103,opt,name=omit_prefix,json=omitPrefix,proto3,enum=entpb.User_OmitPrefix" json:"omit_prefix,omitempty"` + MimeType User_MimeType `protobuf:"varint,104,opt,name=mime_type,json=mimeType,proto3,enum=entpb.User_MimeType" json:"mime_type,omitempty"` Group *Group `protobuf:"bytes,7,opt,name=group,proto3" json:"group,omitempty"` Attachment *Attachment `protobuf:"bytes,11,opt,name=attachment,proto3" json:"attachment,omitempty"` Received_1 []*Attachment `protobuf:"bytes,16,rep,name=received_1,json=received1,proto3" json:"received_1,omitempty"` @@ -3157,6 +3211,34 @@ func (x *User) GetLabels() []string { return nil } +func (x *User) GetInt32S() []int32 { + if x != nil { + return x.Int32S + } + return nil +} + +func (x *User) GetInt64S() []int64 { + if x != nil { + return x.Int64S + } + return nil +} + +func (x *User) GetUint32S() []uint32 { + if x != nil { + return x.Uint32S + } + return nil +} + +func (x *User) GetUint64S() []uint64 { + if x != nil { + return x.Uint64S + } + return nil +} + func (x *User) GetDeviceType() User_DeviceType { if x != nil { return x.DeviceType @@ -3171,6 +3253,13 @@ func (x *User) GetOmitPrefix() User_OmitPrefix { return User_OMIT_PREFIX_UNSPECIFIED } +func (x *User) GetMimeType() User_MimeType { + if x != nil { + return x.MimeType + } + return User_MIME_TYPE_UNSPECIFIED +} + func (x *User) GetGroup() *Group { if x != nil { return x.Group @@ -3892,7 +3981,7 @@ var file_entpb_entpb_proto_rawDesc = []byte{ 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x47, 0x52, 0x45, 0x53, 0x53, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, - 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x44, 0x4f, 0x4e, 0x45, 0x10, 0x02, 0x22, 0xb4, 0x09, + 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x44, 0x4f, 0x4e, 0x45, 0x10, 0x02, 0x22, 0xa8, 0x0b, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4e, @@ -3938,219 +4027,235 @@ var file_entpb_entpb_proto_rawDesc = []byte{ 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x18, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, - 0x73, 0x12, 0x37, 0x0a, 0x0b, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x64, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, - 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x37, 0x0a, 0x0b, 0x6f, 0x6d, - 0x69, 0x74, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x67, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x2e, 0x4f, 0x6d, 0x69, - 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x52, 0x0a, 0x6f, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x65, - 0x66, 0x69, 0x78, 0x12, 0x22, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, - 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x31, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, - 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, - 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x0a, 0x72, 0x65, - 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x31, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, - 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x09, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x31, 0x12, 0x1c, 0x0a, 0x03, - 0x70, 0x65, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x65, 0x6e, 0x74, 0x70, - 0x62, 0x2e, 0x50, 0x65, 0x74, 0x52, 0x03, 0x70, 0x65, 0x74, 0x22, 0x47, 0x0a, 0x06, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, - 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, - 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x01, - 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, - 0x45, 0x10, 0x02, 0x22, 0x42, 0x0a, 0x0a, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x19, 0x0a, 0x15, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, - 0x5f, 0x47, 0x4c, 0x4f, 0x57, 0x59, 0x39, 0x30, 0x30, 0x30, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, - 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x50, 0x45, 0x45, - 0x44, 0x59, 0x33, 0x30, 0x30, 0x10, 0x01, 0x22, 0x3b, 0x0a, 0x0a, 0x4f, 0x6d, 0x69, 0x74, 0x50, - 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x1b, 0x0a, 0x17, 0x4f, 0x4d, 0x49, 0x54, 0x5f, 0x50, 0x52, - 0x45, 0x46, 0x49, 0x58, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, - 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x46, 0x4f, 0x4f, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x42, - 0x41, 0x52, 0x10, 0x02, 0x22, 0x34, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, - 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x8c, 0x01, 0x0a, 0x0e, 0x47, - 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2e, 0x0a, - 0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x52, 0x04, 0x76, 0x69, 0x65, 0x77, 0x22, 0x3a, 0x0a, - 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x14, 0x0a, 0x10, 0x56, 0x49, 0x45, 0x57, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x42, - 0x41, 0x53, 0x49, 0x43, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x45, - 0x44, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x53, 0x10, 0x02, 0x22, 0x34, 0x0a, 0x11, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, - 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x65, - 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, - 0x23, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x02, 0x69, 0x64, 0x22, 0xba, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, - 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, - 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x52, - 0x04, 0x76, 0x69, 0x65, 0x77, 0x22, 0x3a, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x14, 0x0a, - 0x10, 0x56, 0x49, 0x45, 0x57, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x42, 0x41, 0x53, 0x49, 0x43, 0x10, 0x01, 0x12, 0x11, - 0x0a, 0x0d, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x45, 0x44, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x53, 0x10, - 0x02, 0x22, 0x64, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, - 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, - 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, - 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x4f, 0x0a, 0x17, 0x42, 0x61, 0x74, 0x63, 0x68, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x22, 0x3d, 0x0a, 0x18, 0x42, 0x61, 0x74, 0x63, - 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x32, 0xa7, 0x03, 0x0a, 0x11, 0x41, 0x74, 0x74, 0x61, - 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, - 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, - 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x35, 0x0a, 0x03, 0x47, 0x65, - 0x74, 0x12, 0x1b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x74, 0x74, - 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, - 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, - 0x74, 0x12, 0x3b, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, + 0x73, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x73, 0x18, 0x19, 0x20, 0x03, 0x28, + 0x05, 0x52, 0x06, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x6e, 0x74, + 0x36, 0x34, 0x73, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x69, 0x6e, 0x74, 0x36, 0x34, + 0x73, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x73, 0x18, 0x1b, 0x20, 0x03, + 0x28, 0x0d, 0x52, 0x07, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x75, + 0x69, 0x6e, 0x74, 0x36, 0x34, 0x73, 0x18, 0x1c, 0x20, 0x03, 0x28, 0x04, 0x52, 0x07, 0x75, 0x69, + 0x6e, 0x74, 0x36, 0x34, 0x73, 0x12, 0x37, 0x0a, 0x0b, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x65, 0x6e, 0x74, + 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x37, + 0x0a, 0x0b, 0x6f, 0x6d, 0x69, 0x74, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x67, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, + 0x2e, 0x4f, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x52, 0x0a, 0x6f, 0x6d, 0x69, + 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x31, 0x0a, 0x09, 0x6d, 0x69, 0x6d, 0x65, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x68, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x65, 0x6e, 0x74, + 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x2e, 0x4d, 0x69, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x08, 0x6d, 0x69, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x65, 0x6e, 0x74, 0x70, + 0x62, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x31, + 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, + 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, + 0x74, 0x12, 0x30, 0x0a, 0x0a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x31, 0x18, + 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, + 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x64, 0x31, 0x12, 0x1c, 0x0a, 0x03, 0x70, 0x65, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0a, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x74, 0x52, 0x03, 0x70, 0x65, + 0x74, 0x22, 0x47, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, 0x45, + 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x55, + 0x53, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x02, 0x22, 0x42, 0x0a, 0x0a, 0x44, 0x65, + 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x44, 0x45, 0x56, 0x49, + 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x4c, 0x4f, 0x57, 0x59, 0x39, 0x30, 0x30, + 0x30, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x53, 0x50, 0x45, 0x45, 0x44, 0x59, 0x33, 0x30, 0x30, 0x10, 0x01, 0x22, 0x3b, + 0x0a, 0x0a, 0x4f, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x1b, 0x0a, 0x17, + 0x4f, 0x4d, 0x49, 0x54, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x46, 0x4f, 0x4f, + 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x42, 0x41, 0x52, 0x10, 0x02, 0x22, 0x5b, 0x0a, 0x08, 0x4d, + 0x69, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x4d, 0x49, 0x4d, 0x45, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, + 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x4d, 0x49, 0x4d, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, + 0x49, 0x4d, 0x41, 0x47, 0x45, 0x5f, 0x50, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x4d, + 0x49, 0x4d, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x4d, 0x41, 0x47, 0x45, 0x5f, 0x58, + 0x4d, 0x4c, 0x5f, 0x53, 0x56, 0x47, 0x10, 0x02, 0x22, 0x34, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, + 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x65, 0x6e, + 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x8c, + 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x1a, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x52, 0x04, 0x76, 0x69, 0x65, + 0x77, 0x22, 0x3a, 0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x14, 0x0a, 0x10, 0x56, 0x49, 0x45, + 0x57, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, + 0x09, 0x0a, 0x05, 0x42, 0x41, 0x53, 0x49, 0x43, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x57, 0x49, + 0x54, 0x48, 0x5f, 0x45, 0x44, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x53, 0x10, 0x02, 0x22, 0x34, 0x0a, + 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, + 0x73, 0x65, 0x72, 0x22, 0x23, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x22, 0xba, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, + 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, + 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, + 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, + 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x04, 0x76, 0x69, 0x65, 0x77, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x56, + 0x69, 0x65, 0x77, 0x52, 0x04, 0x76, 0x69, 0x65, 0x77, 0x22, 0x3a, 0x0a, 0x04, 0x56, 0x69, 0x65, + 0x77, 0x12, 0x14, 0x0a, 0x10, 0x56, 0x49, 0x45, 0x57, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x42, 0x41, 0x53, 0x49, 0x43, + 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x45, 0x44, 0x47, 0x45, 0x5f, + 0x49, 0x44, 0x53, 0x10, 0x02, 0x22, 0x64, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x09, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x65, + 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, + 0x69, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, + 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, + 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x4f, 0x0a, 0x17, 0x42, + 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x22, 0x3d, 0x0a, 0x18, + 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x32, 0xa7, 0x03, 0x0a, 0x11, + 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, + 0x74, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x40, - 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x12, 0x43, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x0b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x12, 0x24, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, - 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x65, 0x6e, 0x74, - 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x74, - 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x32, 0xe3, 0x03, 0x0a, 0x16, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x45, 0x0a, 0x06, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x23, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x12, 0x3f, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x20, 0x2e, 0x65, 0x6e, 0x74, - 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x65, - 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x12, 0x45, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x23, - 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x75, 0x6c, - 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, - 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x45, 0x0a, 0x06, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x23, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x12, 0x4d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x21, 0x2e, 0x65, 0x6e, 0x74, - 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, - 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, - 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, - 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x64, 0x0a, 0x0b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x12, 0x29, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, - 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa7, 0x03, 0x0a, 0x11, 0x4e, 0x69, 0x6c, 0x45, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, - 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, - 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x35, 0x0a, 0x03, 0x47, 0x65, - 0x74, 0x12, 0x1b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x69, 0x6c, - 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, - 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, + 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x35, + 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x1b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, + 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, + 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x3b, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, + 0x1e, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x74, + 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x11, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x40, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, + 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x74, 0x74, 0x61, 0x63, + 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x2e, 0x65, + 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, + 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x65, 0x6e, 0x74, + 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x0b, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x24, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, + 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x74, 0x74, 0x61, + 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, + 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xe3, 0x03, 0x0a, 0x16, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, + 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x45, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x23, 0x2e, 0x65, 0x6e, 0x74, + 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, + 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, + 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x3f, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x20, + 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, + 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, + 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x45, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x12, 0x23, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, + 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, + 0x45, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x23, 0x2e, 0x65, 0x6e, 0x74, 0x70, + 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, + 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x4d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x21, + 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x75, 0x6c, 0x74, 0x69, + 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x22, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x75, + 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x64, 0x0a, 0x0b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x12, 0x29, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, + 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2a, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x57, 0x6f, 0x72, 0x64, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa7, 0x03, 0x0a, 0x11, + 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, + 0x74, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x40, - 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x12, 0x43, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x0b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x12, 0x24, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, - 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x65, 0x6e, 0x74, - 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x69, - 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x32, 0xd3, 0x02, 0x0a, 0x0a, 0x50, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x2d, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x65, 0x6e, 0x74, - 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x74, 0x12, - 0x27, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x14, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, - 0x65, 0x74, 0x50, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x65, - 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x74, 0x12, 0x2d, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x12, 0x17, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x50, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x65, 0x6e, - 0x74, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x74, 0x12, 0x39, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x12, 0x17, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x50, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x12, 0x35, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x15, 0x2e, 0x65, 0x6e, 0x74, - 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x0b, 0x42, 0x61, 0x74, - 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, - 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x74, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, - 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x74, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x5f, 0x0a, 0x0b, 0x50, 0x6f, 0x6e, 0x79, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x50, 0x0a, 0x0b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x6e, 0x69, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, - 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x6e, 0x69, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xdf, 0x02, 0x0a, 0x0b, 0x55, 0x73, 0x65, - 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x12, 0x18, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x74, 0x70, 0x62, 0x2e, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x35, + 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x1b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, + 0x74, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4e, 0x69, 0x6c, 0x45, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, + 0x1e, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x69, + 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x11, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x12, 0x40, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, + 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4e, 0x69, 0x6c, 0x45, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x2e, 0x65, + 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x65, 0x6e, 0x74, + 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x0b, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x24, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, + 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x69, 0x6c, 0x45, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, + 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x4e, 0x69, 0x6c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd3, 0x02, 0x0a, 0x0a, 0x50, 0x65, 0x74, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x17, + 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, + 0x50, 0x65, 0x74, 0x12, 0x27, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x14, 0x2e, 0x65, 0x6e, 0x74, + 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0a, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x74, 0x12, 0x2d, 0x0a, 0x06, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x0a, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x50, 0x65, 0x74, 0x12, 0x39, 0x0a, 0x06, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x35, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x15, + 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x50, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, + 0x0b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x65, + 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x50, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x65, 0x6e, + 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, + 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x5f, 0x0a, 0x0b, 0x50, + 0x6f, 0x6e, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x50, 0x0a, 0x0b, 0x42, 0x61, + 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x2e, 0x65, 0x6e, 0x74, 0x70, + 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x6e, + 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x65, 0x6e, 0x74, + 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, + 0x6e, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xdf, 0x02, 0x0a, + 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x06, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x18, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x12, 0x29, 0x0a, + 0x03, 0x47, 0x65, 0x74, 0x12, 0x15, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x65, 0x6e, + 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x12, 0x18, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x65, - 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x12, 0x29, 0x0a, 0x03, 0x47, 0x65, 0x74, - 0x12, 0x15, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, - 0x55, 0x73, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x18, - 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, - 0x18, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x12, 0x37, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x70, - 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x17, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x0b, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x65, 0x6e, 0x74, 0x70, - 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, - 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x65, 0x6e, 0x74, 0x70, - 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, - 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x39, 0x5a, 0x37, 0x65, 0x6e, - 0x74, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x2f, 0x65, - 0x6e, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2f, 0x74, 0x6f, 0x64, 0x6f, 0x2f, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x65, 0x6e, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x06, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x12, 0x18, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x37, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, + 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, + 0x0a, 0x0b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, + 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, + 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x39, + 0x5a, 0x37, 0x65, 0x6e, 0x74, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x69, 0x62, 0x2f, 0x65, 0x6e, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x6f, 0x64, 0x6f, 0x2f, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -4165,7 +4270,7 @@ func file_entpb_entpb_proto_rawDescGZIP() []byte { return file_entpb_entpb_proto_rawDescData } -var file_entpb_entpb_proto_enumTypes = make([]protoimpl.EnumInfo, 15) +var file_entpb_entpb_proto_enumTypes = make([]protoimpl.EnumInfo, 16) var file_entpb_entpb_proto_msgTypes = make([]protoimpl.MessageInfo, 51) var file_entpb_entpb_proto_goTypes = []interface{}{ (GetAttachmentRequest_View)(0), // 0: entpb.GetAttachmentRequest.View @@ -4181,195 +4286,197 @@ var file_entpb_entpb_proto_goTypes = []interface{}{ (User_Status)(0), // 10: entpb.User.Status (User_DeviceType)(0), // 11: entpb.User.DeviceType (User_OmitPrefix)(0), // 12: entpb.User.OmitPrefix - (GetUserRequest_View)(0), // 13: entpb.GetUserRequest.View - (ListUserRequest_View)(0), // 14: entpb.ListUserRequest.View - (*Attachment)(nil), // 15: entpb.Attachment - (*CreateAttachmentRequest)(nil), // 16: entpb.CreateAttachmentRequest - (*GetAttachmentRequest)(nil), // 17: entpb.GetAttachmentRequest - (*UpdateAttachmentRequest)(nil), // 18: entpb.UpdateAttachmentRequest - (*DeleteAttachmentRequest)(nil), // 19: entpb.DeleteAttachmentRequest - (*ListAttachmentRequest)(nil), // 20: entpb.ListAttachmentRequest - (*ListAttachmentResponse)(nil), // 21: entpb.ListAttachmentResponse - (*BatchCreateAttachmentsRequest)(nil), // 22: entpb.BatchCreateAttachmentsRequest - (*BatchCreateAttachmentsResponse)(nil), // 23: entpb.BatchCreateAttachmentsResponse - (*Group)(nil), // 24: entpb.Group - (*MultiWordSchema)(nil), // 25: entpb.MultiWordSchema - (*CreateMultiWordSchemaRequest)(nil), // 26: entpb.CreateMultiWordSchemaRequest - (*GetMultiWordSchemaRequest)(nil), // 27: entpb.GetMultiWordSchemaRequest - (*UpdateMultiWordSchemaRequest)(nil), // 28: entpb.UpdateMultiWordSchemaRequest - (*DeleteMultiWordSchemaRequest)(nil), // 29: entpb.DeleteMultiWordSchemaRequest - (*ListMultiWordSchemaRequest)(nil), // 30: entpb.ListMultiWordSchemaRequest - (*ListMultiWordSchemaResponse)(nil), // 31: entpb.ListMultiWordSchemaResponse - (*BatchCreateMultiWordSchemasRequest)(nil), // 32: entpb.BatchCreateMultiWordSchemasRequest - (*BatchCreateMultiWordSchemasResponse)(nil), // 33: entpb.BatchCreateMultiWordSchemasResponse - (*NilExample)(nil), // 34: entpb.NilExample - (*CreateNilExampleRequest)(nil), // 35: entpb.CreateNilExampleRequest - (*GetNilExampleRequest)(nil), // 36: entpb.GetNilExampleRequest - (*UpdateNilExampleRequest)(nil), // 37: entpb.UpdateNilExampleRequest - (*DeleteNilExampleRequest)(nil), // 38: entpb.DeleteNilExampleRequest - (*ListNilExampleRequest)(nil), // 39: entpb.ListNilExampleRequest - (*ListNilExampleResponse)(nil), // 40: entpb.ListNilExampleResponse - (*BatchCreateNilExamplesRequest)(nil), // 41: entpb.BatchCreateNilExamplesRequest - (*BatchCreateNilExamplesResponse)(nil), // 42: entpb.BatchCreateNilExamplesResponse - (*Pet)(nil), // 43: entpb.Pet - (*CreatePetRequest)(nil), // 44: entpb.CreatePetRequest - (*GetPetRequest)(nil), // 45: entpb.GetPetRequest - (*UpdatePetRequest)(nil), // 46: entpb.UpdatePetRequest - (*DeletePetRequest)(nil), // 47: entpb.DeletePetRequest - (*ListPetRequest)(nil), // 48: entpb.ListPetRequest - (*ListPetResponse)(nil), // 49: entpb.ListPetResponse - (*BatchCreatePetsRequest)(nil), // 50: entpb.BatchCreatePetsRequest - (*BatchCreatePetsResponse)(nil), // 51: entpb.BatchCreatePetsResponse - (*Pony)(nil), // 52: entpb.Pony - (*CreatePonyRequest)(nil), // 53: entpb.CreatePonyRequest - (*BatchCreatePoniesRequest)(nil), // 54: entpb.BatchCreatePoniesRequest - (*BatchCreatePoniesResponse)(nil), // 55: entpb.BatchCreatePoniesResponse - (*Todo)(nil), // 56: entpb.Todo - (*User)(nil), // 57: entpb.User - (*CreateUserRequest)(nil), // 58: entpb.CreateUserRequest - (*GetUserRequest)(nil), // 59: entpb.GetUserRequest - (*UpdateUserRequest)(nil), // 60: entpb.UpdateUserRequest - (*DeleteUserRequest)(nil), // 61: entpb.DeleteUserRequest - (*ListUserRequest)(nil), // 62: entpb.ListUserRequest - (*ListUserResponse)(nil), // 63: entpb.ListUserResponse - (*BatchCreateUsersRequest)(nil), // 64: entpb.BatchCreateUsersRequest - (*BatchCreateUsersResponse)(nil), // 65: entpb.BatchCreateUsersResponse - (*wrapperspb.StringValue)(nil), // 66: google.protobuf.StringValue - (*timestamppb.Timestamp)(nil), // 67: google.protobuf.Timestamp - (*wrapperspb.Int64Value)(nil), // 68: google.protobuf.Int64Value - (*wrapperspb.BoolValue)(nil), // 69: google.protobuf.BoolValue - (*emptypb.Empty)(nil), // 70: google.protobuf.Empty + (User_MimeType)(0), // 13: entpb.User.MimeType + (GetUserRequest_View)(0), // 14: entpb.GetUserRequest.View + (ListUserRequest_View)(0), // 15: entpb.ListUserRequest.View + (*Attachment)(nil), // 16: entpb.Attachment + (*CreateAttachmentRequest)(nil), // 17: entpb.CreateAttachmentRequest + (*GetAttachmentRequest)(nil), // 18: entpb.GetAttachmentRequest + (*UpdateAttachmentRequest)(nil), // 19: entpb.UpdateAttachmentRequest + (*DeleteAttachmentRequest)(nil), // 20: entpb.DeleteAttachmentRequest + (*ListAttachmentRequest)(nil), // 21: entpb.ListAttachmentRequest + (*ListAttachmentResponse)(nil), // 22: entpb.ListAttachmentResponse + (*BatchCreateAttachmentsRequest)(nil), // 23: entpb.BatchCreateAttachmentsRequest + (*BatchCreateAttachmentsResponse)(nil), // 24: entpb.BatchCreateAttachmentsResponse + (*Group)(nil), // 25: entpb.Group + (*MultiWordSchema)(nil), // 26: entpb.MultiWordSchema + (*CreateMultiWordSchemaRequest)(nil), // 27: entpb.CreateMultiWordSchemaRequest + (*GetMultiWordSchemaRequest)(nil), // 28: entpb.GetMultiWordSchemaRequest + (*UpdateMultiWordSchemaRequest)(nil), // 29: entpb.UpdateMultiWordSchemaRequest + (*DeleteMultiWordSchemaRequest)(nil), // 30: entpb.DeleteMultiWordSchemaRequest + (*ListMultiWordSchemaRequest)(nil), // 31: entpb.ListMultiWordSchemaRequest + (*ListMultiWordSchemaResponse)(nil), // 32: entpb.ListMultiWordSchemaResponse + (*BatchCreateMultiWordSchemasRequest)(nil), // 33: entpb.BatchCreateMultiWordSchemasRequest + (*BatchCreateMultiWordSchemasResponse)(nil), // 34: entpb.BatchCreateMultiWordSchemasResponse + (*NilExample)(nil), // 35: entpb.NilExample + (*CreateNilExampleRequest)(nil), // 36: entpb.CreateNilExampleRequest + (*GetNilExampleRequest)(nil), // 37: entpb.GetNilExampleRequest + (*UpdateNilExampleRequest)(nil), // 38: entpb.UpdateNilExampleRequest + (*DeleteNilExampleRequest)(nil), // 39: entpb.DeleteNilExampleRequest + (*ListNilExampleRequest)(nil), // 40: entpb.ListNilExampleRequest + (*ListNilExampleResponse)(nil), // 41: entpb.ListNilExampleResponse + (*BatchCreateNilExamplesRequest)(nil), // 42: entpb.BatchCreateNilExamplesRequest + (*BatchCreateNilExamplesResponse)(nil), // 43: entpb.BatchCreateNilExamplesResponse + (*Pet)(nil), // 44: entpb.Pet + (*CreatePetRequest)(nil), // 45: entpb.CreatePetRequest + (*GetPetRequest)(nil), // 46: entpb.GetPetRequest + (*UpdatePetRequest)(nil), // 47: entpb.UpdatePetRequest + (*DeletePetRequest)(nil), // 48: entpb.DeletePetRequest + (*ListPetRequest)(nil), // 49: entpb.ListPetRequest + (*ListPetResponse)(nil), // 50: entpb.ListPetResponse + (*BatchCreatePetsRequest)(nil), // 51: entpb.BatchCreatePetsRequest + (*BatchCreatePetsResponse)(nil), // 52: entpb.BatchCreatePetsResponse + (*Pony)(nil), // 53: entpb.Pony + (*CreatePonyRequest)(nil), // 54: entpb.CreatePonyRequest + (*BatchCreatePoniesRequest)(nil), // 55: entpb.BatchCreatePoniesRequest + (*BatchCreatePoniesResponse)(nil), // 56: entpb.BatchCreatePoniesResponse + (*Todo)(nil), // 57: entpb.Todo + (*User)(nil), // 58: entpb.User + (*CreateUserRequest)(nil), // 59: entpb.CreateUserRequest + (*GetUserRequest)(nil), // 60: entpb.GetUserRequest + (*UpdateUserRequest)(nil), // 61: entpb.UpdateUserRequest + (*DeleteUserRequest)(nil), // 62: entpb.DeleteUserRequest + (*ListUserRequest)(nil), // 63: entpb.ListUserRequest + (*ListUserResponse)(nil), // 64: entpb.ListUserResponse + (*BatchCreateUsersRequest)(nil), // 65: entpb.BatchCreateUsersRequest + (*BatchCreateUsersResponse)(nil), // 66: entpb.BatchCreateUsersResponse + (*wrapperspb.StringValue)(nil), // 67: google.protobuf.StringValue + (*timestamppb.Timestamp)(nil), // 68: google.protobuf.Timestamp + (*wrapperspb.Int64Value)(nil), // 69: google.protobuf.Int64Value + (*wrapperspb.BoolValue)(nil), // 70: google.protobuf.BoolValue + (*emptypb.Empty)(nil), // 71: google.protobuf.Empty } var file_entpb_entpb_proto_depIdxs = []int32{ - 57, // 0: entpb.Attachment.user:type_name -> entpb.User - 57, // 1: entpb.Attachment.recipients:type_name -> entpb.User - 15, // 2: entpb.CreateAttachmentRequest.attachment:type_name -> entpb.Attachment + 58, // 0: entpb.Attachment.user:type_name -> entpb.User + 58, // 1: entpb.Attachment.recipients:type_name -> entpb.User + 16, // 2: entpb.CreateAttachmentRequest.attachment:type_name -> entpb.Attachment 0, // 3: entpb.GetAttachmentRequest.view:type_name -> entpb.GetAttachmentRequest.View - 15, // 4: entpb.UpdateAttachmentRequest.attachment:type_name -> entpb.Attachment + 16, // 4: entpb.UpdateAttachmentRequest.attachment:type_name -> entpb.Attachment 1, // 5: entpb.ListAttachmentRequest.view:type_name -> entpb.ListAttachmentRequest.View - 15, // 6: entpb.ListAttachmentResponse.attachment_list:type_name -> entpb.Attachment - 16, // 7: entpb.BatchCreateAttachmentsRequest.requests:type_name -> entpb.CreateAttachmentRequest - 15, // 8: entpb.BatchCreateAttachmentsResponse.attachments:type_name -> entpb.Attachment - 57, // 9: entpb.Group.users:type_name -> entpb.User + 16, // 6: entpb.ListAttachmentResponse.attachment_list:type_name -> entpb.Attachment + 17, // 7: entpb.BatchCreateAttachmentsRequest.requests:type_name -> entpb.CreateAttachmentRequest + 16, // 8: entpb.BatchCreateAttachmentsResponse.attachments:type_name -> entpb.Attachment + 58, // 9: entpb.Group.users:type_name -> entpb.User 2, // 10: entpb.MultiWordSchema.unit:type_name -> entpb.MultiWordSchema.Unit - 25, // 11: entpb.CreateMultiWordSchemaRequest.multi_word_schema:type_name -> entpb.MultiWordSchema + 26, // 11: entpb.CreateMultiWordSchemaRequest.multi_word_schema:type_name -> entpb.MultiWordSchema 3, // 12: entpb.GetMultiWordSchemaRequest.view:type_name -> entpb.GetMultiWordSchemaRequest.View - 25, // 13: entpb.UpdateMultiWordSchemaRequest.multi_word_schema:type_name -> entpb.MultiWordSchema + 26, // 13: entpb.UpdateMultiWordSchemaRequest.multi_word_schema:type_name -> entpb.MultiWordSchema 4, // 14: entpb.ListMultiWordSchemaRequest.view:type_name -> entpb.ListMultiWordSchemaRequest.View - 25, // 15: entpb.ListMultiWordSchemaResponse.multi_word_schema_list:type_name -> entpb.MultiWordSchema - 26, // 16: entpb.BatchCreateMultiWordSchemasRequest.requests:type_name -> entpb.CreateMultiWordSchemaRequest - 25, // 17: entpb.BatchCreateMultiWordSchemasResponse.multi_word_schemas:type_name -> entpb.MultiWordSchema - 66, // 18: entpb.NilExample.str_nil:type_name -> google.protobuf.StringValue - 67, // 19: entpb.NilExample.time_nil:type_name -> google.protobuf.Timestamp - 34, // 20: entpb.CreateNilExampleRequest.nil_example:type_name -> entpb.NilExample + 26, // 15: entpb.ListMultiWordSchemaResponse.multi_word_schema_list:type_name -> entpb.MultiWordSchema + 27, // 16: entpb.BatchCreateMultiWordSchemasRequest.requests:type_name -> entpb.CreateMultiWordSchemaRequest + 26, // 17: entpb.BatchCreateMultiWordSchemasResponse.multi_word_schemas:type_name -> entpb.MultiWordSchema + 67, // 18: entpb.NilExample.str_nil:type_name -> google.protobuf.StringValue + 68, // 19: entpb.NilExample.time_nil:type_name -> google.protobuf.Timestamp + 35, // 20: entpb.CreateNilExampleRequest.nil_example:type_name -> entpb.NilExample 5, // 21: entpb.GetNilExampleRequest.view:type_name -> entpb.GetNilExampleRequest.View - 34, // 22: entpb.UpdateNilExampleRequest.nil_example:type_name -> entpb.NilExample + 35, // 22: entpb.UpdateNilExampleRequest.nil_example:type_name -> entpb.NilExample 6, // 23: entpb.ListNilExampleRequest.view:type_name -> entpb.ListNilExampleRequest.View - 34, // 24: entpb.ListNilExampleResponse.nil_example_list:type_name -> entpb.NilExample - 35, // 25: entpb.BatchCreateNilExamplesRequest.requests:type_name -> entpb.CreateNilExampleRequest - 34, // 26: entpb.BatchCreateNilExamplesResponse.nil_examples:type_name -> entpb.NilExample - 57, // 27: entpb.Pet.owner:type_name -> entpb.User - 15, // 28: entpb.Pet.attachment:type_name -> entpb.Attachment - 43, // 29: entpb.CreatePetRequest.pet:type_name -> entpb.Pet + 35, // 24: entpb.ListNilExampleResponse.nil_example_list:type_name -> entpb.NilExample + 36, // 25: entpb.BatchCreateNilExamplesRequest.requests:type_name -> entpb.CreateNilExampleRequest + 35, // 26: entpb.BatchCreateNilExamplesResponse.nil_examples:type_name -> entpb.NilExample + 58, // 27: entpb.Pet.owner:type_name -> entpb.User + 16, // 28: entpb.Pet.attachment:type_name -> entpb.Attachment + 44, // 29: entpb.CreatePetRequest.pet:type_name -> entpb.Pet 7, // 30: entpb.GetPetRequest.view:type_name -> entpb.GetPetRequest.View - 43, // 31: entpb.UpdatePetRequest.pet:type_name -> entpb.Pet + 44, // 31: entpb.UpdatePetRequest.pet:type_name -> entpb.Pet 8, // 32: entpb.ListPetRequest.view:type_name -> entpb.ListPetRequest.View - 43, // 33: entpb.ListPetResponse.pet_list:type_name -> entpb.Pet - 44, // 34: entpb.BatchCreatePetsRequest.requests:type_name -> entpb.CreatePetRequest - 43, // 35: entpb.BatchCreatePetsResponse.pets:type_name -> entpb.Pet - 52, // 36: entpb.CreatePonyRequest.pony:type_name -> entpb.Pony - 53, // 37: entpb.BatchCreatePoniesRequest.requests:type_name -> entpb.CreatePonyRequest - 52, // 38: entpb.BatchCreatePoniesResponse.ponies:type_name -> entpb.Pony + 44, // 33: entpb.ListPetResponse.pet_list:type_name -> entpb.Pet + 45, // 34: entpb.BatchCreatePetsRequest.requests:type_name -> entpb.CreatePetRequest + 44, // 35: entpb.BatchCreatePetsResponse.pets:type_name -> entpb.Pet + 53, // 36: entpb.CreatePonyRequest.pony:type_name -> entpb.Pony + 54, // 37: entpb.BatchCreatePoniesRequest.requests:type_name -> entpb.CreatePonyRequest + 53, // 38: entpb.BatchCreatePoniesResponse.ponies:type_name -> entpb.Pony 9, // 39: entpb.Todo.status:type_name -> entpb.Todo.Status - 57, // 40: entpb.Todo.user:type_name -> entpb.User - 67, // 41: entpb.User.joined:type_name -> google.protobuf.Timestamp + 58, // 40: entpb.Todo.user:type_name -> entpb.User + 68, // 41: entpb.User.joined:type_name -> google.protobuf.Timestamp 10, // 42: entpb.User.status:type_name -> entpb.User.Status - 68, // 43: entpb.User.opt_num:type_name -> google.protobuf.Int64Value - 66, // 44: entpb.User.opt_str:type_name -> google.protobuf.StringValue - 69, // 45: entpb.User.opt_bool:type_name -> google.protobuf.BoolValue - 66, // 46: entpb.User.big_int:type_name -> google.protobuf.StringValue - 68, // 47: entpb.User.b_user_1:type_name -> google.protobuf.Int64Value - 66, // 48: entpb.User.type:type_name -> google.protobuf.StringValue + 69, // 43: entpb.User.opt_num:type_name -> google.protobuf.Int64Value + 67, // 44: entpb.User.opt_str:type_name -> google.protobuf.StringValue + 70, // 45: entpb.User.opt_bool:type_name -> google.protobuf.BoolValue + 67, // 46: entpb.User.big_int:type_name -> google.protobuf.StringValue + 69, // 47: entpb.User.b_user_1:type_name -> google.protobuf.Int64Value + 67, // 48: entpb.User.type:type_name -> google.protobuf.StringValue 11, // 49: entpb.User.device_type:type_name -> entpb.User.DeviceType 12, // 50: entpb.User.omit_prefix:type_name -> entpb.User.OmitPrefix - 24, // 51: entpb.User.group:type_name -> entpb.Group - 15, // 52: entpb.User.attachment:type_name -> entpb.Attachment - 15, // 53: entpb.User.received_1:type_name -> entpb.Attachment - 43, // 54: entpb.User.pet:type_name -> entpb.Pet - 57, // 55: entpb.CreateUserRequest.user:type_name -> entpb.User - 13, // 56: entpb.GetUserRequest.view:type_name -> entpb.GetUserRequest.View - 57, // 57: entpb.UpdateUserRequest.user:type_name -> entpb.User - 14, // 58: entpb.ListUserRequest.view:type_name -> entpb.ListUserRequest.View - 57, // 59: entpb.ListUserResponse.user_list:type_name -> entpb.User - 58, // 60: entpb.BatchCreateUsersRequest.requests:type_name -> entpb.CreateUserRequest - 57, // 61: entpb.BatchCreateUsersResponse.users:type_name -> entpb.User - 16, // 62: entpb.AttachmentService.Create:input_type -> entpb.CreateAttachmentRequest - 17, // 63: entpb.AttachmentService.Get:input_type -> entpb.GetAttachmentRequest - 18, // 64: entpb.AttachmentService.Update:input_type -> entpb.UpdateAttachmentRequest - 19, // 65: entpb.AttachmentService.Delete:input_type -> entpb.DeleteAttachmentRequest - 20, // 66: entpb.AttachmentService.List:input_type -> entpb.ListAttachmentRequest - 22, // 67: entpb.AttachmentService.BatchCreate:input_type -> entpb.BatchCreateAttachmentsRequest - 26, // 68: entpb.MultiWordSchemaService.Create:input_type -> entpb.CreateMultiWordSchemaRequest - 27, // 69: entpb.MultiWordSchemaService.Get:input_type -> entpb.GetMultiWordSchemaRequest - 28, // 70: entpb.MultiWordSchemaService.Update:input_type -> entpb.UpdateMultiWordSchemaRequest - 29, // 71: entpb.MultiWordSchemaService.Delete:input_type -> entpb.DeleteMultiWordSchemaRequest - 30, // 72: entpb.MultiWordSchemaService.List:input_type -> entpb.ListMultiWordSchemaRequest - 32, // 73: entpb.MultiWordSchemaService.BatchCreate:input_type -> entpb.BatchCreateMultiWordSchemasRequest - 35, // 74: entpb.NilExampleService.Create:input_type -> entpb.CreateNilExampleRequest - 36, // 75: entpb.NilExampleService.Get:input_type -> entpb.GetNilExampleRequest - 37, // 76: entpb.NilExampleService.Update:input_type -> entpb.UpdateNilExampleRequest - 38, // 77: entpb.NilExampleService.Delete:input_type -> entpb.DeleteNilExampleRequest - 39, // 78: entpb.NilExampleService.List:input_type -> entpb.ListNilExampleRequest - 41, // 79: entpb.NilExampleService.BatchCreate:input_type -> entpb.BatchCreateNilExamplesRequest - 44, // 80: entpb.PetService.Create:input_type -> entpb.CreatePetRequest - 45, // 81: entpb.PetService.Get:input_type -> entpb.GetPetRequest - 46, // 82: entpb.PetService.Update:input_type -> entpb.UpdatePetRequest - 47, // 83: entpb.PetService.Delete:input_type -> entpb.DeletePetRequest - 48, // 84: entpb.PetService.List:input_type -> entpb.ListPetRequest - 50, // 85: entpb.PetService.BatchCreate:input_type -> entpb.BatchCreatePetsRequest - 54, // 86: entpb.PonyService.BatchCreate:input_type -> entpb.BatchCreatePoniesRequest - 58, // 87: entpb.UserService.Create:input_type -> entpb.CreateUserRequest - 59, // 88: entpb.UserService.Get:input_type -> entpb.GetUserRequest - 60, // 89: entpb.UserService.Update:input_type -> entpb.UpdateUserRequest - 61, // 90: entpb.UserService.Delete:input_type -> entpb.DeleteUserRequest - 62, // 91: entpb.UserService.List:input_type -> entpb.ListUserRequest - 64, // 92: entpb.UserService.BatchCreate:input_type -> entpb.BatchCreateUsersRequest - 15, // 93: entpb.AttachmentService.Create:output_type -> entpb.Attachment - 15, // 94: entpb.AttachmentService.Get:output_type -> entpb.Attachment - 15, // 95: entpb.AttachmentService.Update:output_type -> entpb.Attachment - 70, // 96: entpb.AttachmentService.Delete:output_type -> google.protobuf.Empty - 21, // 97: entpb.AttachmentService.List:output_type -> entpb.ListAttachmentResponse - 23, // 98: entpb.AttachmentService.BatchCreate:output_type -> entpb.BatchCreateAttachmentsResponse - 25, // 99: entpb.MultiWordSchemaService.Create:output_type -> entpb.MultiWordSchema - 25, // 100: entpb.MultiWordSchemaService.Get:output_type -> entpb.MultiWordSchema - 25, // 101: entpb.MultiWordSchemaService.Update:output_type -> entpb.MultiWordSchema - 70, // 102: entpb.MultiWordSchemaService.Delete:output_type -> google.protobuf.Empty - 31, // 103: entpb.MultiWordSchemaService.List:output_type -> entpb.ListMultiWordSchemaResponse - 33, // 104: entpb.MultiWordSchemaService.BatchCreate:output_type -> entpb.BatchCreateMultiWordSchemasResponse - 34, // 105: entpb.NilExampleService.Create:output_type -> entpb.NilExample - 34, // 106: entpb.NilExampleService.Get:output_type -> entpb.NilExample - 34, // 107: entpb.NilExampleService.Update:output_type -> entpb.NilExample - 70, // 108: entpb.NilExampleService.Delete:output_type -> google.protobuf.Empty - 40, // 109: entpb.NilExampleService.List:output_type -> entpb.ListNilExampleResponse - 42, // 110: entpb.NilExampleService.BatchCreate:output_type -> entpb.BatchCreateNilExamplesResponse - 43, // 111: entpb.PetService.Create:output_type -> entpb.Pet - 43, // 112: entpb.PetService.Get:output_type -> entpb.Pet - 43, // 113: entpb.PetService.Update:output_type -> entpb.Pet - 70, // 114: entpb.PetService.Delete:output_type -> google.protobuf.Empty - 49, // 115: entpb.PetService.List:output_type -> entpb.ListPetResponse - 51, // 116: entpb.PetService.BatchCreate:output_type -> entpb.BatchCreatePetsResponse - 55, // 117: entpb.PonyService.BatchCreate:output_type -> entpb.BatchCreatePoniesResponse - 57, // 118: entpb.UserService.Create:output_type -> entpb.User - 57, // 119: entpb.UserService.Get:output_type -> entpb.User - 57, // 120: entpb.UserService.Update:output_type -> entpb.User - 70, // 121: entpb.UserService.Delete:output_type -> google.protobuf.Empty - 63, // 122: entpb.UserService.List:output_type -> entpb.ListUserResponse - 65, // 123: entpb.UserService.BatchCreate:output_type -> entpb.BatchCreateUsersResponse - 93, // [93:124] is the sub-list for method output_type - 62, // [62:93] is the sub-list for method input_type - 62, // [62:62] is the sub-list for extension type_name - 62, // [62:62] is the sub-list for extension extendee - 0, // [0:62] is the sub-list for field type_name + 13, // 51: entpb.User.mime_type:type_name -> entpb.User.MimeType + 25, // 52: entpb.User.group:type_name -> entpb.Group + 16, // 53: entpb.User.attachment:type_name -> entpb.Attachment + 16, // 54: entpb.User.received_1:type_name -> entpb.Attachment + 44, // 55: entpb.User.pet:type_name -> entpb.Pet + 58, // 56: entpb.CreateUserRequest.user:type_name -> entpb.User + 14, // 57: entpb.GetUserRequest.view:type_name -> entpb.GetUserRequest.View + 58, // 58: entpb.UpdateUserRequest.user:type_name -> entpb.User + 15, // 59: entpb.ListUserRequest.view:type_name -> entpb.ListUserRequest.View + 58, // 60: entpb.ListUserResponse.user_list:type_name -> entpb.User + 59, // 61: entpb.BatchCreateUsersRequest.requests:type_name -> entpb.CreateUserRequest + 58, // 62: entpb.BatchCreateUsersResponse.users:type_name -> entpb.User + 17, // 63: entpb.AttachmentService.Create:input_type -> entpb.CreateAttachmentRequest + 18, // 64: entpb.AttachmentService.Get:input_type -> entpb.GetAttachmentRequest + 19, // 65: entpb.AttachmentService.Update:input_type -> entpb.UpdateAttachmentRequest + 20, // 66: entpb.AttachmentService.Delete:input_type -> entpb.DeleteAttachmentRequest + 21, // 67: entpb.AttachmentService.List:input_type -> entpb.ListAttachmentRequest + 23, // 68: entpb.AttachmentService.BatchCreate:input_type -> entpb.BatchCreateAttachmentsRequest + 27, // 69: entpb.MultiWordSchemaService.Create:input_type -> entpb.CreateMultiWordSchemaRequest + 28, // 70: entpb.MultiWordSchemaService.Get:input_type -> entpb.GetMultiWordSchemaRequest + 29, // 71: entpb.MultiWordSchemaService.Update:input_type -> entpb.UpdateMultiWordSchemaRequest + 30, // 72: entpb.MultiWordSchemaService.Delete:input_type -> entpb.DeleteMultiWordSchemaRequest + 31, // 73: entpb.MultiWordSchemaService.List:input_type -> entpb.ListMultiWordSchemaRequest + 33, // 74: entpb.MultiWordSchemaService.BatchCreate:input_type -> entpb.BatchCreateMultiWordSchemasRequest + 36, // 75: entpb.NilExampleService.Create:input_type -> entpb.CreateNilExampleRequest + 37, // 76: entpb.NilExampleService.Get:input_type -> entpb.GetNilExampleRequest + 38, // 77: entpb.NilExampleService.Update:input_type -> entpb.UpdateNilExampleRequest + 39, // 78: entpb.NilExampleService.Delete:input_type -> entpb.DeleteNilExampleRequest + 40, // 79: entpb.NilExampleService.List:input_type -> entpb.ListNilExampleRequest + 42, // 80: entpb.NilExampleService.BatchCreate:input_type -> entpb.BatchCreateNilExamplesRequest + 45, // 81: entpb.PetService.Create:input_type -> entpb.CreatePetRequest + 46, // 82: entpb.PetService.Get:input_type -> entpb.GetPetRequest + 47, // 83: entpb.PetService.Update:input_type -> entpb.UpdatePetRequest + 48, // 84: entpb.PetService.Delete:input_type -> entpb.DeletePetRequest + 49, // 85: entpb.PetService.List:input_type -> entpb.ListPetRequest + 51, // 86: entpb.PetService.BatchCreate:input_type -> entpb.BatchCreatePetsRequest + 55, // 87: entpb.PonyService.BatchCreate:input_type -> entpb.BatchCreatePoniesRequest + 59, // 88: entpb.UserService.Create:input_type -> entpb.CreateUserRequest + 60, // 89: entpb.UserService.Get:input_type -> entpb.GetUserRequest + 61, // 90: entpb.UserService.Update:input_type -> entpb.UpdateUserRequest + 62, // 91: entpb.UserService.Delete:input_type -> entpb.DeleteUserRequest + 63, // 92: entpb.UserService.List:input_type -> entpb.ListUserRequest + 65, // 93: entpb.UserService.BatchCreate:input_type -> entpb.BatchCreateUsersRequest + 16, // 94: entpb.AttachmentService.Create:output_type -> entpb.Attachment + 16, // 95: entpb.AttachmentService.Get:output_type -> entpb.Attachment + 16, // 96: entpb.AttachmentService.Update:output_type -> entpb.Attachment + 71, // 97: entpb.AttachmentService.Delete:output_type -> google.protobuf.Empty + 22, // 98: entpb.AttachmentService.List:output_type -> entpb.ListAttachmentResponse + 24, // 99: entpb.AttachmentService.BatchCreate:output_type -> entpb.BatchCreateAttachmentsResponse + 26, // 100: entpb.MultiWordSchemaService.Create:output_type -> entpb.MultiWordSchema + 26, // 101: entpb.MultiWordSchemaService.Get:output_type -> entpb.MultiWordSchema + 26, // 102: entpb.MultiWordSchemaService.Update:output_type -> entpb.MultiWordSchema + 71, // 103: entpb.MultiWordSchemaService.Delete:output_type -> google.protobuf.Empty + 32, // 104: entpb.MultiWordSchemaService.List:output_type -> entpb.ListMultiWordSchemaResponse + 34, // 105: entpb.MultiWordSchemaService.BatchCreate:output_type -> entpb.BatchCreateMultiWordSchemasResponse + 35, // 106: entpb.NilExampleService.Create:output_type -> entpb.NilExample + 35, // 107: entpb.NilExampleService.Get:output_type -> entpb.NilExample + 35, // 108: entpb.NilExampleService.Update:output_type -> entpb.NilExample + 71, // 109: entpb.NilExampleService.Delete:output_type -> google.protobuf.Empty + 41, // 110: entpb.NilExampleService.List:output_type -> entpb.ListNilExampleResponse + 43, // 111: entpb.NilExampleService.BatchCreate:output_type -> entpb.BatchCreateNilExamplesResponse + 44, // 112: entpb.PetService.Create:output_type -> entpb.Pet + 44, // 113: entpb.PetService.Get:output_type -> entpb.Pet + 44, // 114: entpb.PetService.Update:output_type -> entpb.Pet + 71, // 115: entpb.PetService.Delete:output_type -> google.protobuf.Empty + 50, // 116: entpb.PetService.List:output_type -> entpb.ListPetResponse + 52, // 117: entpb.PetService.BatchCreate:output_type -> entpb.BatchCreatePetsResponse + 56, // 118: entpb.PonyService.BatchCreate:output_type -> entpb.BatchCreatePoniesResponse + 58, // 119: entpb.UserService.Create:output_type -> entpb.User + 58, // 120: entpb.UserService.Get:output_type -> entpb.User + 58, // 121: entpb.UserService.Update:output_type -> entpb.User + 71, // 122: entpb.UserService.Delete:output_type -> google.protobuf.Empty + 64, // 123: entpb.UserService.List:output_type -> entpb.ListUserResponse + 66, // 124: entpb.UserService.BatchCreate:output_type -> entpb.BatchCreateUsersResponse + 94, // [94:125] is the sub-list for method output_type + 63, // [63:94] is the sub-list for method input_type + 63, // [63:63] is the sub-list for extension type_name + 63, // [63:63] is the sub-list for extension extendee + 0, // [0:63] is the sub-list for field type_name } func init() { file_entpb_entpb_proto_init() } @@ -4996,7 +5103,7 @@ func file_entpb_entpb_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_entpb_entpb_proto_rawDesc, - NumEnums: 15, + NumEnums: 16, NumMessages: 51, NumExtensions: 0, NumServices: 6, diff --git a/entproto/internal/todo/ent/proto/entpb/entpb.proto b/entproto/internal/todo/ent/proto/entpb/entpb.proto index d3bc081dd..c6afae00f 100644 --- a/entproto/internal/todo/ent/proto/entpb/entpb.proto +++ b/entproto/internal/todo/ent/proto/entpb/entpb.proto @@ -354,10 +354,20 @@ message User { repeated string labels = 24; + repeated int32 int32s = 25; + + repeated int64 int64s = 26; + + repeated uint32 uint32s = 27; + + repeated uint64 uint64s = 28; + DeviceType device_type = 100; OmitPrefix omit_prefix = 103; + MimeType mime_type = 104; + Group group = 7; Attachment attachment = 11; @@ -387,6 +397,14 @@ message User { BAR = 2; } + + enum MimeType { + MIME_TYPE_UNSPECIFIED = 0; + + MIME_TYPE_IMAGE_PNG = 1; + + MIME_TYPE_IMAGE_XML_SVG = 2; + } } message CreateUserRequest { diff --git a/entproto/internal/todo/ent/proto/entpb/entpb_multi_word_schema_service.go b/entproto/internal/todo/ent/proto/entpb/entpb_multi_word_schema_service.go index ef6154833..e6c41ddf4 100644 --- a/entproto/internal/todo/ent/proto/entpb/entpb_multi_word_schema_service.go +++ b/entproto/internal/todo/ent/proto/entpb/entpb_multi_word_schema_service.go @@ -12,6 +12,7 @@ import ( codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" emptypb "google.golang.org/protobuf/types/known/emptypb" + regexp "regexp" strconv "strconv" strings "strings" ) @@ -29,8 +30,14 @@ func NewMultiWordSchemaService(client *ent.Client) *MultiWordSchemaService { } } +var protoIdentNormalizeRegexpMultiWordSchema_Unit = regexp.MustCompile(`[^a-zA-Z0-9_]+`) + +func protoIdentNormalizeMultiWordSchema_Unit(e string) string { + return protoIdentNormalizeRegexpMultiWordSchema_Unit.ReplaceAllString(e, "_") +} + func toProtoMultiWordSchema_Unit(e multiwordschema.Unit) MultiWordSchema_Unit { - if v, ok := MultiWordSchema_Unit_value[strings.ToUpper("UNIT_"+string(e))]; ok { + if v, ok := MultiWordSchema_Unit_value[strings.ToUpper("UNIT_"+protoIdentNormalizeMultiWordSchema_Unit(string(e)))]; ok { return MultiWordSchema_Unit(v) } return MultiWordSchema_Unit(0) diff --git a/entproto/internal/todo/ent/proto/entpb/entpb_user_service.go b/entproto/internal/todo/ent/proto/entpb/entpb_user_service.go index a993ff907..0f8ccf79e 100644 --- a/entproto/internal/todo/ent/proto/entpb/entpb_user_service.go +++ b/entproto/internal/todo/ent/proto/entpb/entpb_user_service.go @@ -21,6 +21,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + regexp "regexp" strconv "strconv" strings "strings" ) @@ -38,8 +39,14 @@ func NewUserService(client *ent.Client) *UserService { } } +var protoIdentNormalizeRegexpUser_DeviceType = regexp.MustCompile(`[^a-zA-Z0-9_]+`) + +func protoIdentNormalizeUser_DeviceType(e string) string { + return protoIdentNormalizeRegexpUser_DeviceType.ReplaceAllString(e, "_") +} + func toProtoUser_DeviceType(e user.DeviceType) User_DeviceType { - if v, ok := User_DeviceType_value[strings.ToUpper("DEVICE_TYPE_"+string(e))]; ok { + if v, ok := User_DeviceType_value[strings.ToUpper("DEVICE_TYPE_"+protoIdentNormalizeUser_DeviceType(string(e)))]; ok { return User_DeviceType(v) } return User_DeviceType(0) @@ -56,8 +63,38 @@ func toEntUser_DeviceType(e User_DeviceType) user.DeviceType { return "" } +var protoIdentNormalizeRegexpUser_MimeType = regexp.MustCompile(`[^a-zA-Z0-9_]+`) + +func protoIdentNormalizeUser_MimeType(e string) string { + return protoIdentNormalizeRegexpUser_MimeType.ReplaceAllString(e, "_") +} + +func toProtoUser_MimeType(e user.MimeType) User_MimeType { + if v, ok := User_MimeType_value[strings.ToUpper("MIME_TYPE_"+protoIdentNormalizeUser_MimeType(string(e)))]; ok { + return User_MimeType(v) + } + return User_MimeType(0) +} + +func toEntUser_MimeType(e User_MimeType) user.MimeType { + if v, ok := User_MimeType_name[int32(e)]; ok { + entVal := map[string]string{ + "MIME_TYPE_IMAGE_PNG": "image/png", + "MIME_TYPE_IMAGE_XML_SVG": "image/xml+svg", + }[v] + return user.MimeType(entVal) + } + return "" +} + +var protoIdentNormalizeRegexpUser_OmitPrefix = regexp.MustCompile(`[^a-zA-Z0-9_]+`) + +func protoIdentNormalizeUser_OmitPrefix(e string) string { + return protoIdentNormalizeRegexpUser_OmitPrefix.ReplaceAllString(e, "_") +} + func toProtoUser_OmitPrefix(e user.OmitPrefix) User_OmitPrefix { - if v, ok := User_OmitPrefix_value[strings.ToUpper(string(e))]; ok { + if v, ok := User_OmitPrefix_value[strings.ToUpper(protoIdentNormalizeUser_OmitPrefix(string(e)))]; ok { return User_OmitPrefix(v) } return User_OmitPrefix(0) @@ -74,8 +111,14 @@ func toEntUser_OmitPrefix(e User_OmitPrefix) user.OmitPrefix { return "" } +var protoIdentNormalizeRegexpUser_Status = regexp.MustCompile(`[^a-zA-Z0-9_]+`) + +func protoIdentNormalizeUser_Status(e string) string { + return protoIdentNormalizeRegexpUser_Status.ReplaceAllString(e, "_") +} + func toProtoUser_Status(e user.Status) User_Status { - if v, ok := User_Status_value[strings.ToUpper("STATUS_"+string(e))]; ok { + if v, ok := User_Status_value[strings.ToUpper("STATUS_"+protoIdentNormalizeUser_Status(string(e)))]; ok { return User_Status(v) } return User_Status(0) @@ -128,10 +171,16 @@ func toProtoUser(e *ent.User) (*User, error) { v.HeightInCm = height_in_cm id := e.ID v.Id = id + int32s := e.Int32s + v.Int32S = int32s + int64s := e.Int64s + v.Int64S = int64s joined := timestamppb.New(e.Joined) v.Joined = joined labels := e.Labels v.Labels = labels + mime_type := toProtoUser_MimeType(e.MimeType) + v.MimeType = mime_type omit_prefix := toProtoUser_OmitPrefix(e.OmitPrefix) v.OmitPrefix = omit_prefix opt_bool := wrapperspb.Bool(e.OptBool) @@ -146,6 +195,10 @@ func toProtoUser(e *ent.User) (*User, error) { v.Status = status _type := wrapperspb.String(e.Type) v.Type = _type + uint32s := e.Uint32s + v.Uint32S = uint32s + uint64s := e.Uint64s + v.Uint64S = uint64s user_name := e.UserName v.UserName = user_name if edg := e.Edges.Attachment; edg != nil { @@ -294,10 +347,20 @@ func (svc *UserService) Update(ctx context.Context, req *UpdateUserRequest) (*Us m.SetExternalID(userExternalID) userHeightInCm := float32(user.GetHeightInCm()) m.SetHeightInCm(userHeightInCm) + if user.GetInt32S() != nil { + userInt32s := user.GetInt32S() + m.SetInt32s(userInt32s) + } + if user.GetInt64S() != nil { + userInt64s := user.GetInt64S() + m.SetInt64s(userInt64s) + } if user.GetLabels() != nil { userLabels := user.GetLabels() m.SetLabels(userLabels) } + userMimeType := toEntUser_MimeType(user.GetMimeType()) + m.SetMimeType(userMimeType) userOmitPrefix := toEntUser_OmitPrefix(user.GetOmitPrefix()) m.SetOmitPrefix(userOmitPrefix) if user.GetOptBool() != nil { @@ -320,6 +383,14 @@ func (svc *UserService) Update(ctx context.Context, req *UpdateUserRequest) (*Us userType := user.GetType().GetValue() m.SetType(userType) } + if user.GetUint32S() != nil { + userUint32s := user.GetUint32S() + m.SetUint32s(userUint32s) + } + if user.GetUint64S() != nil { + userUint64s := user.GetUint64S() + m.SetUint64s(userUint64s) + } userUserName := user.GetUserName() m.SetUserName(userUserName) if user.GetAttachment() != nil { @@ -517,12 +588,22 @@ func (svc *UserService) createBuilder(user *User) (*ent.UserCreate, error) { m.SetExternalID(userExternalID) userHeightInCm := float32(user.GetHeightInCm()) m.SetHeightInCm(userHeightInCm) + if user.GetInt32S() != nil { + userInt32s := user.GetInt32S() + m.SetInt32s(userInt32s) + } + if user.GetInt64S() != nil { + userInt64s := user.GetInt64S() + m.SetInt64s(userInt64s) + } userJoined := runtime.ExtractTime(user.GetJoined()) m.SetJoined(userJoined) if user.GetLabels() != nil { userLabels := user.GetLabels() m.SetLabels(userLabels) } + userMimeType := toEntUser_MimeType(user.GetMimeType()) + m.SetMimeType(userMimeType) userOmitPrefix := toEntUser_OmitPrefix(user.GetOmitPrefix()) m.SetOmitPrefix(userOmitPrefix) if user.GetOptBool() != nil { @@ -545,6 +626,14 @@ func (svc *UserService) createBuilder(user *User) (*ent.UserCreate, error) { userType := user.GetType().GetValue() m.SetType(userType) } + if user.GetUint32S() != nil { + userUint32s := user.GetUint32S() + m.SetUint32s(userUint32s) + } + if user.GetUint64S() != nil { + userUint64s := user.GetUint64S() + m.SetUint64s(userUint64s) + } userUserName := user.GetUserName() m.SetUserName(userUserName) if user.GetAttachment() != nil { diff --git a/entproto/internal/todo/ent/proto/entpb/user_service_test.go b/entproto/internal/todo/ent/proto/entpb/user_service_test.go index 73d046298..01bef322b 100644 --- a/entproto/internal/todo/ent/proto/entpb/user_service_test.go +++ b/entproto/internal/todo/ent/proto/entpb/user_service_test.go @@ -17,6 +17,7 @@ package entpb import ( "context" "fmt" + "regexp" "strings" "testing" "time" @@ -63,6 +64,9 @@ func TestUserService_Create(t *testing.T) { AccountBalance: 2000.50, Labels: []string{"member", "production"}, OmitPrefix: User_BAR, + MimeType: User_MIME_TYPE_IMAGE_XML_SVG, + Int32S: []int32{1, 2, 3}, + Int64S: []int64{1, 2, 3}, } created, err := svc.Create(ctx, &CreateUserRequest{ User: inputUser, @@ -80,6 +84,9 @@ func TestUserService_Create(t *testing.T) { require.EqualValues(t, inputUser.HeightInCm, fromDB.HeightInCm) require.EqualValues(t, inputUser.AccountBalance, fromDB.AccountBalance) require.EqualValues(t, inputUser.Labels, fromDB.Labels) + require.EqualValues(t, inputUser.Int64S, fromDB.Int64s) + require.EqualValues(t, inputUser.Int32S, fromDB.Int32s) + require.EqualValues(t, inputUser.MimeType.String(), strings.ToUpper("MIME_TYPE_"+regexp.MustCompile("[^a-zA-Z0-9_]+").ReplaceAllString(string(fromDB.MimeType), "_"))) // preexisting user _, err = svc.Create(ctx, &CreateUserRequest{ @@ -108,6 +115,7 @@ func TestUserService_Get(t *testing.T) { SetAccountBalance(2000.50). SetLabels([]string{"on", "off"}). SetOmitPrefix(user.OmitPrefixBar). + SetMimeType(user.MimeTypeSvg). SaveX(ctx) get, err := svc.Get(ctx, &GetUserRequest{ Id: created.ID, @@ -121,6 +129,7 @@ func TestUserService_Get(t *testing.T) { require.EqualValues(t, created.AccountBalance, get.AccountBalance) require.EqualValues(t, created.Labels, get.Labels) require.EqualValues(t, User_BAR, get.OmitPrefix) + require.EqualValues(t, User_MIME_TYPE_IMAGE_XML_SVG, get.MimeType) get, err = svc.Get(ctx, &GetUserRequest{ Id: 1000, }) @@ -145,6 +154,7 @@ func TestUserService_Delete(t *testing.T) { SetCrmID(uuid.New()). SetCustomPb(1). SetOmitPrefix(user.OmitPrefixBar). + SetMimeType(user.MimeTypeSvg). SaveX(ctx) d, err := svc.Delete(ctx, &DeleteUserRequest{ Id: created.ID, @@ -182,6 +192,7 @@ func TestUserService_Update(t *testing.T) { SetAccountBalance(2000.50). SetLabels(nil). SetOmitPrefix(user.OmitPrefixFoo). + SetMimeType(user.MimeTypeSvg). SaveX(ctx) attachmentID, err := attachment.ID.MarshalBinary() @@ -208,6 +219,7 @@ func TestUserService_Update(t *testing.T) { HeightInCm: 175.18, AccountBalance: 5000.75, OmitPrefix: User_FOO, + MimeType: User_MIME_TYPE_IMAGE_PNG, } updated, err := svc.Update(ctx, &UpdateUserRequest{ User: inputUser, @@ -218,6 +230,7 @@ func TestUserService_Update(t *testing.T) { afterUpd := client.User.GetX(ctx, created.ID) require.EqualValues(t, inputUser.Exp, afterUpd.Exp) require.EqualValues(t, user.OmitPrefixFoo, afterUpd.OmitPrefix) + require.EqualValues(t, user.MimeTypePng, afterUpd.MimeType) } func TestUserService_List(t *testing.T) { @@ -239,6 +252,7 @@ func TestUserService_List(t *testing.T) { SetCustomPb(1). SetLabels(nil). SetOmitPrefix(user.OmitPrefixBar). + SetMimeType(user.MimeTypeSvg). SaveX(ctx) } @@ -321,6 +335,7 @@ func TestUserService_BatchCreate(t *testing.T) { Labels: nil, Status: User_STATUS_ACTIVE, OmitPrefix: User_BAR, + MimeType: User_MIME_TYPE_IMAGE_PNG, }, } requests = append(requests, request) diff --git a/entproto/internal/todo/ent/runtime/runtime.go b/entproto/internal/todo/ent/runtime/runtime.go index 8ea0c6100..b9e9331ba 100644 --- a/entproto/internal/todo/ent/runtime/runtime.go +++ b/entproto/internal/todo/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/entproto/internal/todo/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/entproto/internal/todo/ent/schema/user.go b/entproto/internal/todo/ent/schema/user.go index 60c642d9b..731a5e00c 100644 --- a/entproto/internal/todo/ent/schema/user.go +++ b/entproto/internal/todo/ent/schema/user.go @@ -119,6 +119,26 @@ func (User) Fields() []ent.Field { Annotations( entproto.Field(24), ), + field.JSON("int32s", []int32{}). + Optional(). + Annotations( + entproto.Field(25), + ), + field.JSON("int64s", []int64{}). + Optional(). + Annotations( + entproto.Field(26), + ), + field.JSON("uint32s", []uint32{}). + Optional(). + Annotations( + entproto.Field(27), + ), + field.JSON("uint64s", []uint64{}). + Optional(). + Annotations( + entproto.Field(28), + ), field.Enum("device_type"). Values("GLOWY9000", "SPEEDY300"). Default("GLOWY9000"). @@ -141,6 +161,20 @@ func (User) Fields() []ent.Field { entproto.OmitFieldPrefix(), ), ), + field.Enum("mime_type"). + NamedValues( + "png", "image/png", + "svg", "image/xml+svg", + ). + Annotations( + entproto.Field(104), + entproto.Enum( + map[string]int32{ + "image/png": 1, + "image/xml+svg": 2, + }, + ), + ), } } diff --git a/entproto/internal/todo/ent/skipedgeexample/where.go b/entproto/internal/todo/ent/skipedgeexample/where.go index f1e34241e..e4eae9387 100644 --- a/entproto/internal/todo/ent/skipedgeexample/where.go +++ b/entproto/internal/todo/ent/skipedgeexample/where.go @@ -78,32 +78,15 @@ func HasUserWith(preds ...predicate.User) predicate.SkipEdgeExample { // And groups predicates with the AND operator between them. func And(predicates ...predicate.SkipEdgeExample) predicate.SkipEdgeExample { - return predicate.SkipEdgeExample(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.SkipEdgeExample(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.SkipEdgeExample) predicate.SkipEdgeExample { - return predicate.SkipEdgeExample(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.SkipEdgeExample(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.SkipEdgeExample) predicate.SkipEdgeExample { - return predicate.SkipEdgeExample(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.SkipEdgeExample(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/skipedgeexample_create.go b/entproto/internal/todo/ent/skipedgeexample_create.go index 1d6a986c7..adfe1b090 100644 --- a/entproto/internal/todo/ent/skipedgeexample_create.go +++ b/entproto/internal/todo/ent/skipedgeexample_create.go @@ -45,7 +45,7 @@ func (seec *SkipEdgeExampleCreate) Mutation() *SkipEdgeExampleMutation { // Save creates the SkipEdgeExample in the database. func (seec *SkipEdgeExampleCreate) Save(ctx context.Context) (*SkipEdgeExample, error) { - return withHooks[*SkipEdgeExample, SkipEdgeExampleMutation](ctx, seec.sqlSave, seec.mutation, seec.hooks) + return withHooks(ctx, seec.sqlSave, seec.mutation, seec.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -121,11 +121,15 @@ func (seec *SkipEdgeExampleCreate) createSpec() (*SkipEdgeExample, *sqlgraph.Cre // SkipEdgeExampleCreateBulk is the builder for creating many SkipEdgeExample entities in bulk. type SkipEdgeExampleCreateBulk struct { config + err error builders []*SkipEdgeExampleCreate } // Save creates the SkipEdgeExample entities in the database. func (seecb *SkipEdgeExampleCreateBulk) Save(ctx context.Context) ([]*SkipEdgeExample, error) { + if seecb.err != nil { + return nil, seecb.err + } specs := make([]*sqlgraph.CreateSpec, len(seecb.builders)) nodes := make([]*SkipEdgeExample, len(seecb.builders)) mutators := make([]Mutator, len(seecb.builders)) diff --git a/entproto/internal/todo/ent/skipedgeexample_delete.go b/entproto/internal/todo/ent/skipedgeexample_delete.go index c784a8338..a31a9f3a7 100644 --- a/entproto/internal/todo/ent/skipedgeexample_delete.go +++ b/entproto/internal/todo/ent/skipedgeexample_delete.go @@ -27,7 +27,7 @@ func (seed *SkipEdgeExampleDelete) Where(ps ...predicate.SkipEdgeExample) *SkipE // Exec executes the deletion query and returns how many vertices were deleted. func (seed *SkipEdgeExampleDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, SkipEdgeExampleMutation](ctx, seed.sqlExec, seed.mutation, seed.hooks) + return withHooks(ctx, seed.sqlExec, seed.mutation, seed.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/skipedgeexample_update.go b/entproto/internal/todo/ent/skipedgeexample_update.go index f43713b87..824bf4f49 100644 --- a/entproto/internal/todo/ent/skipedgeexample_update.go +++ b/entproto/internal/todo/ent/skipedgeexample_update.go @@ -60,7 +60,7 @@ func (seeu *SkipEdgeExampleUpdate) ClearUser() *SkipEdgeExampleUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (seeu *SkipEdgeExampleUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, SkipEdgeExampleMutation](ctx, seeu.sqlSave, seeu.mutation, seeu.hooks) + return withHooks(ctx, seeu.sqlSave, seeu.mutation, seeu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -188,7 +188,7 @@ func (seeuo *SkipEdgeExampleUpdateOne) Select(field string, fields ...string) *S // Save executes the query and returns the updated SkipEdgeExample entity. func (seeuo *SkipEdgeExampleUpdateOne) Save(ctx context.Context) (*SkipEdgeExample, error) { - return withHooks[*SkipEdgeExample, SkipEdgeExampleMutation](ctx, seeuo.sqlSave, seeuo.mutation, seeuo.hooks) + return withHooks(ctx, seeuo.sqlSave, seeuo.mutation, seeuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/todo/where.go b/entproto/internal/todo/ent/todo/where.go index b34244127..e76f749b7 100644 --- a/entproto/internal/todo/ent/todo/where.go +++ b/entproto/internal/todo/ent/todo/where.go @@ -168,32 +168,15 @@ func HasUserWith(preds ...predicate.User) predicate.Todo { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Todo(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Todo) predicate.Todo { - return predicate.Todo(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Todo(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/todo_create.go b/entproto/internal/todo/ent/todo_create.go index 03635c67f..60f4c6f08 100644 --- a/entproto/internal/todo/ent/todo_create.go +++ b/entproto/internal/todo/ent/todo_create.go @@ -67,7 +67,7 @@ func (tc *TodoCreate) Mutation() *TodoMutation { // Save creates the Todo in the database. func (tc *TodoCreate) Save(ctx context.Context) (*Todo, error) { tc.defaults() - return withHooks[*Todo, TodoMutation](ctx, tc.sqlSave, tc.mutation, tc.hooks) + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -170,11 +170,15 @@ func (tc *TodoCreate) createSpec() (*Todo, *sqlgraph.CreateSpec) { // TodoCreateBulk is the builder for creating many Todo entities in bulk. type TodoCreateBulk struct { config + err error builders []*TodoCreate } // Save creates the Todo entities in the database. func (tcb *TodoCreateBulk) Save(ctx context.Context) ([]*Todo, error) { + if tcb.err != nil { + return nil, tcb.err + } specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) nodes := make([]*Todo, len(tcb.builders)) mutators := make([]Mutator, len(tcb.builders)) diff --git a/entproto/internal/todo/ent/todo_delete.go b/entproto/internal/todo/ent/todo_delete.go index 3fb769136..f827e7504 100644 --- a/entproto/internal/todo/ent/todo_delete.go +++ b/entproto/internal/todo/ent/todo_delete.go @@ -27,7 +27,7 @@ func (td *TodoDelete) Where(ps ...predicate.Todo) *TodoDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (td *TodoDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, td.sqlExec, td.mutation, td.hooks) + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/todo_update.go b/entproto/internal/todo/ent/todo_update.go index b360cc55f..13b6f4712 100644 --- a/entproto/internal/todo/ent/todo_update.go +++ b/entproto/internal/todo/ent/todo_update.go @@ -34,6 +34,14 @@ func (tu *TodoUpdate) SetTask(s string) *TodoUpdate { return tu } +// SetNillableTask sets the "task" field if the given value is not nil. +func (tu *TodoUpdate) SetNillableTask(s *string) *TodoUpdate { + if s != nil { + tu.SetTask(*s) + } + return tu +} + // SetStatus sets the "status" field. func (tu *TodoUpdate) SetStatus(t todo.Status) *TodoUpdate { tu.mutation.SetStatus(t) @@ -80,7 +88,7 @@ func (tu *TodoUpdate) ClearUser() *TodoUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TodoUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, TodoMutation](ctx, tu.sqlSave, tu.mutation, tu.hooks) + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -188,6 +196,14 @@ func (tuo *TodoUpdateOne) SetTask(s string) *TodoUpdateOne { return tuo } +// SetNillableTask sets the "task" field if the given value is not nil. +func (tuo *TodoUpdateOne) SetNillableTask(s *string) *TodoUpdateOne { + if s != nil { + tuo.SetTask(*s) + } + return tuo +} + // SetStatus sets the "status" field. func (tuo *TodoUpdateOne) SetStatus(t todo.Status) *TodoUpdateOne { tuo.mutation.SetStatus(t) @@ -247,7 +263,7 @@ func (tuo *TodoUpdateOne) Select(field string, fields ...string) *TodoUpdateOne // Save executes the query and returns the updated Todo entity. func (tuo *TodoUpdateOne) Save(ctx context.Context) (*Todo, error) { - return withHooks[*Todo, TodoMutation](ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/user.go b/entproto/internal/todo/ent/user.go index 044df2c41..8626bcffa 100644 --- a/entproto/internal/todo/ent/user.go +++ b/entproto/internal/todo/ent/user.go @@ -62,10 +62,20 @@ type User struct { Type string `json:"type,omitempty"` // Labels holds the value of the "labels" field. Labels []string `json:"labels,omitempty"` + // Int32s holds the value of the "int32s" field. + Int32s []int32 `json:"int32s,omitempty"` + // Int64s holds the value of the "int64s" field. + Int64s []int64 `json:"int64s,omitempty"` + // Uint32s holds the value of the "uint32s" field. + Uint32s []uint32 `json:"uint32s,omitempty"` + // Uint64s holds the value of the "uint64s" field. + Uint64s []uint64 `json:"uint64s,omitempty"` // DeviceType holds the value of the "device_type" field. DeviceType user.DeviceType `json:"device_type,omitempty"` // OmitPrefix holds the value of the "omit_prefix" field. OmitPrefix user.OmitPrefix `json:"omit_prefix,omitempty"` + // MimeType holds the value of the "mime_type" field. + MimeType user.MimeType `json:"mime_type,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the UserQuery when eager-loading is set. Edges UserEdges `json:"edges"` @@ -156,7 +166,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case user.FieldLabels: + case user.FieldLabels, user.FieldInt32s, user.FieldInt64s, user.FieldUint32s, user.FieldUint64s: values[i] = new([]byte) case user.FieldBigInt: values[i] = new(schema.BigInt) @@ -166,7 +176,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullFloat64) case user.FieldID, user.FieldPoints, user.FieldExp, user.FieldExternalID, user.FieldCustomPb, user.FieldOptNum, user.FieldBUser1: values[i] = new(sql.NullInt64) - case user.FieldUserName, user.FieldStatus, user.FieldOptStr, user.FieldUnnecessary, user.FieldType, user.FieldDeviceType, user.FieldOmitPrefix: + case user.FieldUserName, user.FieldStatus, user.FieldOptStr, user.FieldUnnecessary, user.FieldType, user.FieldDeviceType, user.FieldOmitPrefix, user.FieldMimeType: values[i] = new(sql.NullString) case user.FieldJoined: values[i] = new(sql.NullTime) @@ -311,6 +321,38 @@ func (u *User) assignValues(columns []string, values []any) error { return fmt.Errorf("unmarshal field labels: %w", err) } } + case user.FieldInt32s: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field int32s", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &u.Int32s); err != nil { + return fmt.Errorf("unmarshal field int32s: %w", err) + } + } + case user.FieldInt64s: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field int64s", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &u.Int64s); err != nil { + return fmt.Errorf("unmarshal field int64s: %w", err) + } + } + case user.FieldUint32s: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field uint32s", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &u.Uint32s); err != nil { + return fmt.Errorf("unmarshal field uint32s: %w", err) + } + } + case user.FieldUint64s: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field uint64s", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &u.Uint64s); err != nil { + return fmt.Errorf("unmarshal field uint64s: %w", err) + } + } case user.FieldDeviceType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field device_type", values[i]) @@ -323,6 +365,12 @@ func (u *User) assignValues(columns []string, values []any) error { } else if value.Valid { u.OmitPrefix = user.OmitPrefix(value.String) } + case user.FieldMimeType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mime_type", values[i]) + } else if value.Valid { + u.MimeType = user.MimeType(value.String) + } case user.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field user_group", value) @@ -448,11 +496,26 @@ func (u *User) String() string { builder.WriteString("labels=") builder.WriteString(fmt.Sprintf("%v", u.Labels)) builder.WriteString(", ") + builder.WriteString("int32s=") + builder.WriteString(fmt.Sprintf("%v", u.Int32s)) + builder.WriteString(", ") + builder.WriteString("int64s=") + builder.WriteString(fmt.Sprintf("%v", u.Int64s)) + builder.WriteString(", ") + builder.WriteString("uint32s=") + builder.WriteString(fmt.Sprintf("%v", u.Uint32s)) + builder.WriteString(", ") + builder.WriteString("uint64s=") + builder.WriteString(fmt.Sprintf("%v", u.Uint64s)) + builder.WriteString(", ") builder.WriteString("device_type=") builder.WriteString(fmt.Sprintf("%v", u.DeviceType)) builder.WriteString(", ") builder.WriteString("omit_prefix=") builder.WriteString(fmt.Sprintf("%v", u.OmitPrefix)) + builder.WriteString(", ") + builder.WriteString("mime_type=") + builder.WriteString(fmt.Sprintf("%v", u.MimeType)) builder.WriteByte(')') return builder.String() } diff --git a/entproto/internal/todo/ent/user/user.go b/entproto/internal/todo/ent/user/user.go index 0143923e8..d3656d2fe 100644 --- a/entproto/internal/todo/ent/user/user.go +++ b/entproto/internal/todo/ent/user/user.go @@ -52,10 +52,20 @@ const ( FieldType = "type" // FieldLabels holds the string denoting the labels field in the database. FieldLabels = "labels" + // FieldInt32s holds the string denoting the int32s field in the database. + FieldInt32s = "int32s" + // FieldInt64s holds the string denoting the int64s field in the database. + FieldInt64s = "int64s" + // FieldUint32s holds the string denoting the uint32s field in the database. + FieldUint32s = "uint32s" + // FieldUint64s holds the string denoting the uint64s field in the database. + FieldUint64s = "uint64s" // FieldDeviceType holds the string denoting the device_type field in the database. FieldDeviceType = "device_type" // FieldOmitPrefix holds the string denoting the omit_prefix field in the database. FieldOmitPrefix = "omit_prefix" + // FieldMimeType holds the string denoting the mime_type field in the database. + FieldMimeType = "mime_type" // EdgeGroup holds the string denoting the group edge name in mutations. EdgeGroup = "group" // EdgeAttachment holds the string denoting the attachment edge name in mutations. @@ -133,8 +143,13 @@ var Columns = []string{ FieldUnnecessary, FieldType, FieldLabels, + FieldInt32s, + FieldInt64s, + FieldUint32s, + FieldUint64s, FieldDeviceType, FieldOmitPrefix, + FieldMimeType, } // ForeignKeys holds the SQL foreign-keys that are owned by the "users" @@ -245,6 +260,29 @@ func OmitPrefixValidator(op OmitPrefix) error { } } +// MimeType defines the type for the "mime_type" enum field. +type MimeType string + +// MimeType values. +const ( + MimeTypePng MimeType = "image/png" + MimeTypeSvg MimeType = "image/xml+svg" +) + +func (mt MimeType) String() string { + return string(mt) +} + +// MimeTypeValidator is a validator for the "mime_type" field enum values. It is called by the builders before save. +func MimeTypeValidator(mt MimeType) error { + switch mt { + case MimeTypePng, MimeTypeSvg: + return nil + default: + return fmt.Errorf("user: invalid enum value for mime_type field: %q", mt) + } +} + // OrderOption defines the ordering options for the User queries. type OrderOption func(*sql.Selector) @@ -353,6 +391,11 @@ func ByOmitPrefix(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldOmitPrefix, opts...).ToFunc() } +// ByMimeType orders the results by the mime_type field. +func ByMimeType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMimeType, opts...).ToFunc() +} + // ByGroupField orders the results by group field. func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/entproto/internal/todo/ent/user/where.go b/entproto/internal/todo/ent/user/where.go index e32ba1c0b..bbcfe58eb 100644 --- a/entproto/internal/todo/ent/user/where.go +++ b/entproto/internal/todo/ent/user/where.go @@ -962,6 +962,46 @@ func LabelsNotNil() predicate.User { return predicate.User(sql.FieldNotNull(FieldLabels)) } +// Int32sIsNil applies the IsNil predicate on the "int32s" field. +func Int32sIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldInt32s)) +} + +// Int32sNotNil applies the NotNil predicate on the "int32s" field. +func Int32sNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldInt32s)) +} + +// Int64sIsNil applies the IsNil predicate on the "int64s" field. +func Int64sIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldInt64s)) +} + +// Int64sNotNil applies the NotNil predicate on the "int64s" field. +func Int64sNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldInt64s)) +} + +// Uint32sIsNil applies the IsNil predicate on the "uint32s" field. +func Uint32sIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldUint32s)) +} + +// Uint32sNotNil applies the NotNil predicate on the "uint32s" field. +func Uint32sNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldUint32s)) +} + +// Uint64sIsNil applies the IsNil predicate on the "uint64s" field. +func Uint64sIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldUint64s)) +} + +// Uint64sNotNil applies the NotNil predicate on the "uint64s" field. +func Uint64sNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldUint64s)) +} + // DeviceTypeEQ applies the EQ predicate on the "device_type" field. func DeviceTypeEQ(v DeviceType) predicate.User { return predicate.User(sql.FieldEQ(FieldDeviceType, v)) @@ -1002,6 +1042,26 @@ func OmitPrefixNotIn(vs ...OmitPrefix) predicate.User { return predicate.User(sql.FieldNotIn(FieldOmitPrefix, vs...)) } +// MimeTypeEQ applies the EQ predicate on the "mime_type" field. +func MimeTypeEQ(v MimeType) predicate.User { + return predicate.User(sql.FieldEQ(FieldMimeType, v)) +} + +// MimeTypeNEQ applies the NEQ predicate on the "mime_type" field. +func MimeTypeNEQ(v MimeType) predicate.User { + return predicate.User(sql.FieldNEQ(FieldMimeType, v)) +} + +// MimeTypeIn applies the In predicate on the "mime_type" field. +func MimeTypeIn(vs ...MimeType) predicate.User { + return predicate.User(sql.FieldIn(FieldMimeType, vs...)) +} + +// MimeTypeNotIn applies the NotIn predicate on the "mime_type" field. +func MimeTypeNotIn(vs ...MimeType) predicate.User { + return predicate.User(sql.FieldNotIn(FieldMimeType, vs...)) +} + // HasGroup applies the HasEdge predicate on the "group" edge. func HasGroup() predicate.User { return predicate.User(func(s *sql.Selector) { @@ -1119,32 +1179,15 @@ func HasSkipEdgeWith(preds ...predicate.SkipEdgeExample) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/entproto/internal/todo/ent/user_create.go b/entproto/internal/todo/ent/user_create.go index ffdba1c43..8c67b5f79 100644 --- a/entproto/internal/todo/ent/user_create.go +++ b/entproto/internal/todo/ent/user_create.go @@ -220,6 +220,30 @@ func (uc *UserCreate) SetLabels(s []string) *UserCreate { return uc } +// SetInt32s sets the "int32s" field. +func (uc *UserCreate) SetInt32s(i []int32) *UserCreate { + uc.mutation.SetInt32s(i) + return uc +} + +// SetInt64s sets the "int64s" field. +func (uc *UserCreate) SetInt64s(i []int64) *UserCreate { + uc.mutation.SetInt64s(i) + return uc +} + +// SetUint32s sets the "uint32s" field. +func (uc *UserCreate) SetUint32s(u []uint32) *UserCreate { + uc.mutation.SetUint32s(u) + return uc +} + +// SetUint64s sets the "uint64s" field. +func (uc *UserCreate) SetUint64s(u []uint64) *UserCreate { + uc.mutation.SetUint64s(u) + return uc +} + // SetDeviceType sets the "device_type" field. func (uc *UserCreate) SetDeviceType(ut user.DeviceType) *UserCreate { uc.mutation.SetDeviceType(ut) @@ -240,6 +264,12 @@ func (uc *UserCreate) SetOmitPrefix(up user.OmitPrefix) *UserCreate { return uc } +// SetMimeType sets the "mime_type" field. +func (uc *UserCreate) SetMimeType(ut user.MimeType) *UserCreate { + uc.mutation.SetMimeType(ut) + return uc +} + // SetID sets the "id" field. func (uc *UserCreate) SetID(u uint32) *UserCreate { uc.mutation.SetID(u) @@ -345,7 +375,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { uc.defaults() - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -446,6 +476,14 @@ func (uc *UserCreate) check() error { return &ValidationError{Name: "omit_prefix", err: fmt.Errorf(`ent: validator failed for field "User.omit_prefix": %w`, err)} } } + if _, ok := uc.mutation.MimeType(); !ok { + return &ValidationError{Name: "mime_type", err: errors.New(`ent: missing required field "User.mime_type"`)} + } + if v, ok := uc.mutation.MimeType(); ok { + if err := user.MimeTypeValidator(v); err != nil { + return &ValidationError{Name: "mime_type", err: fmt.Errorf(`ent: validator failed for field "User.mime_type": %w`, err)} + } + } return nil } @@ -554,6 +592,22 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldLabels, field.TypeJSON, value) _node.Labels = value } + if value, ok := uc.mutation.Int32s(); ok { + _spec.SetField(user.FieldInt32s, field.TypeJSON, value) + _node.Int32s = value + } + if value, ok := uc.mutation.Int64s(); ok { + _spec.SetField(user.FieldInt64s, field.TypeJSON, value) + _node.Int64s = value + } + if value, ok := uc.mutation.Uint32s(); ok { + _spec.SetField(user.FieldUint32s, field.TypeJSON, value) + _node.Uint32s = value + } + if value, ok := uc.mutation.Uint64s(); ok { + _spec.SetField(user.FieldUint64s, field.TypeJSON, value) + _node.Uint64s = value + } if value, ok := uc.mutation.DeviceType(); ok { _spec.SetField(user.FieldDeviceType, field.TypeEnum, value) _node.DeviceType = value @@ -562,6 +616,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldOmitPrefix, field.TypeEnum, value) _node.OmitPrefix = value } + if value, ok := uc.mutation.MimeType(); ok { + _spec.SetField(user.FieldMimeType, field.TypeEnum, value) + _node.MimeType = value + } if nodes := uc.mutation.GroupIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -649,11 +707,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/entproto/internal/todo/ent/user_delete.go b/entproto/internal/todo/ent/user_delete.go index 82497218c..93a6d3a0f 100644 --- a/entproto/internal/todo/ent/user_delete.go +++ b/entproto/internal/todo/ent/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/entproto/internal/todo/ent/user_update.go b/entproto/internal/todo/ent/user_update.go index 8b38d8325..84f9d38cc 100644 --- a/entproto/internal/todo/ent/user_update.go +++ b/entproto/internal/todo/ent/user_update.go @@ -40,6 +40,14 @@ func (uu *UserUpdate) SetUserName(s string) *UserUpdate { return uu } +// SetNillableUserName sets the "user_name" field if the given value is not nil. +func (uu *UserUpdate) SetNillableUserName(s *string) *UserUpdate { + if s != nil { + uu.SetUserName(*s) + } + return uu +} + // SetPoints sets the "points" field. func (uu *UserUpdate) SetPoints(u uint) *UserUpdate { uu.mutation.ResetPoints() @@ -47,6 +55,14 @@ func (uu *UserUpdate) SetPoints(u uint) *UserUpdate { return uu } +// SetNillablePoints sets the "points" field if the given value is not nil. +func (uu *UserUpdate) SetNillablePoints(u *uint) *UserUpdate { + if u != nil { + uu.SetPoints(*u) + } + return uu +} + // AddPoints adds u to the "points" field. func (uu *UserUpdate) AddPoints(u int) *UserUpdate { uu.mutation.AddPoints(u) @@ -60,6 +76,14 @@ func (uu *UserUpdate) SetExp(u uint64) *UserUpdate { return uu } +// SetNillableExp sets the "exp" field if the given value is not nil. +func (uu *UserUpdate) SetNillableExp(u *uint64) *UserUpdate { + if u != nil { + uu.SetExp(*u) + } + return uu +} + // AddExp adds u to the "exp" field. func (uu *UserUpdate) AddExp(u int64) *UserUpdate { uu.mutation.AddExp(u) @@ -72,6 +96,14 @@ func (uu *UserUpdate) SetStatus(u user.Status) *UserUpdate { return uu } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (uu *UserUpdate) SetNillableStatus(u *user.Status) *UserUpdate { + if u != nil { + uu.SetStatus(*u) + } + return uu +} + // SetExternalID sets the "external_id" field. func (uu *UserUpdate) SetExternalID(i int) *UserUpdate { uu.mutation.ResetExternalID() @@ -79,6 +111,14 @@ func (uu *UserUpdate) SetExternalID(i int) *UserUpdate { return uu } +// SetNillableExternalID sets the "external_id" field if the given value is not nil. +func (uu *UserUpdate) SetNillableExternalID(i *int) *UserUpdate { + if i != nil { + uu.SetExternalID(*i) + } + return uu +} + // AddExternalID adds i to the "external_id" field. func (uu *UserUpdate) AddExternalID(i int) *UserUpdate { uu.mutation.AddExternalID(i) @@ -91,6 +131,14 @@ func (uu *UserUpdate) SetCrmID(u uuid.UUID) *UserUpdate { return uu } +// SetNillableCrmID sets the "crm_id" field if the given value is not nil. +func (uu *UserUpdate) SetNillableCrmID(u *uuid.UUID) *UserUpdate { + if u != nil { + uu.SetCrmID(*u) + } + return uu +} + // SetBanned sets the "banned" field. func (uu *UserUpdate) SetBanned(b bool) *UserUpdate { uu.mutation.SetBanned(b) @@ -112,6 +160,14 @@ func (uu *UserUpdate) SetCustomPb(u uint8) *UserUpdate { return uu } +// SetNillableCustomPb sets the "custom_pb" field if the given value is not nil. +func (uu *UserUpdate) SetNillableCustomPb(u *uint8) *UserUpdate { + if u != nil { + uu.SetCustomPb(*u) + } + return uu +} + // AddCustomPb adds u to the "custom_pb" field. func (uu *UserUpdate) AddCustomPb(u int8) *UserUpdate { uu.mutation.AddCustomPb(u) @@ -332,6 +388,78 @@ func (uu *UserUpdate) ClearLabels() *UserUpdate { return uu } +// SetInt32s sets the "int32s" field. +func (uu *UserUpdate) SetInt32s(i []int32) *UserUpdate { + uu.mutation.SetInt32s(i) + return uu +} + +// AppendInt32s appends i to the "int32s" field. +func (uu *UserUpdate) AppendInt32s(i []int32) *UserUpdate { + uu.mutation.AppendInt32s(i) + return uu +} + +// ClearInt32s clears the value of the "int32s" field. +func (uu *UserUpdate) ClearInt32s() *UserUpdate { + uu.mutation.ClearInt32s() + return uu +} + +// SetInt64s sets the "int64s" field. +func (uu *UserUpdate) SetInt64s(i []int64) *UserUpdate { + uu.mutation.SetInt64s(i) + return uu +} + +// AppendInt64s appends i to the "int64s" field. +func (uu *UserUpdate) AppendInt64s(i []int64) *UserUpdate { + uu.mutation.AppendInt64s(i) + return uu +} + +// ClearInt64s clears the value of the "int64s" field. +func (uu *UserUpdate) ClearInt64s() *UserUpdate { + uu.mutation.ClearInt64s() + return uu +} + +// SetUint32s sets the "uint32s" field. +func (uu *UserUpdate) SetUint32s(u []uint32) *UserUpdate { + uu.mutation.SetUint32s(u) + return uu +} + +// AppendUint32s appends u to the "uint32s" field. +func (uu *UserUpdate) AppendUint32s(u []uint32) *UserUpdate { + uu.mutation.AppendUint32s(u) + return uu +} + +// ClearUint32s clears the value of the "uint32s" field. +func (uu *UserUpdate) ClearUint32s() *UserUpdate { + uu.mutation.ClearUint32s() + return uu +} + +// SetUint64s sets the "uint64s" field. +func (uu *UserUpdate) SetUint64s(u []uint64) *UserUpdate { + uu.mutation.SetUint64s(u) + return uu +} + +// AppendUint64s appends u to the "uint64s" field. +func (uu *UserUpdate) AppendUint64s(u []uint64) *UserUpdate { + uu.mutation.AppendUint64s(u) + return uu +} + +// ClearUint64s clears the value of the "uint64s" field. +func (uu *UserUpdate) ClearUint64s() *UserUpdate { + uu.mutation.ClearUint64s() + return uu +} + // SetDeviceType sets the "device_type" field. func (uu *UserUpdate) SetDeviceType(ut user.DeviceType) *UserUpdate { uu.mutation.SetDeviceType(ut) @@ -352,6 +480,28 @@ func (uu *UserUpdate) SetOmitPrefix(up user.OmitPrefix) *UserUpdate { return uu } +// SetNillableOmitPrefix sets the "omit_prefix" field if the given value is not nil. +func (uu *UserUpdate) SetNillableOmitPrefix(up *user.OmitPrefix) *UserUpdate { + if up != nil { + uu.SetOmitPrefix(*up) + } + return uu +} + +// SetMimeType sets the "mime_type" field. +func (uu *UserUpdate) SetMimeType(ut user.MimeType) *UserUpdate { + uu.mutation.SetMimeType(ut) + return uu +} + +// SetNillableMimeType sets the "mime_type" field if the given value is not nil. +func (uu *UserUpdate) SetNillableMimeType(ut *user.MimeType) *UserUpdate { + if ut != nil { + uu.SetMimeType(*ut) + } + return uu +} + // SetGroupID sets the "group" edge to the Group entity by ID. func (uu *UserUpdate) SetGroupID(id int) *UserUpdate { uu.mutation.SetGroupID(id) @@ -495,7 +645,7 @@ func (uu *UserUpdate) ClearSkipEdge() *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -537,6 +687,11 @@ func (uu *UserUpdate) check() error { return &ValidationError{Name: "omit_prefix", err: fmt.Errorf(`ent: validator failed for field "User.omit_prefix": %w`, err)} } } + if v, ok := uu.mutation.MimeType(); ok { + if err := user.MimeTypeValidator(v); err != nil { + return &ValidationError{Name: "mime_type", err: fmt.Errorf(`ent: validator failed for field "User.mime_type": %w`, err)} + } + } return nil } @@ -659,12 +814,59 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if uu.mutation.LabelsCleared() { _spec.ClearField(user.FieldLabels, field.TypeJSON) } + if value, ok := uu.mutation.Int32s(); ok { + _spec.SetField(user.FieldInt32s, field.TypeJSON, value) + } + if value, ok := uu.mutation.AppendedInt32s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, user.FieldInt32s, value) + }) + } + if uu.mutation.Int32sCleared() { + _spec.ClearField(user.FieldInt32s, field.TypeJSON) + } + if value, ok := uu.mutation.Int64s(); ok { + _spec.SetField(user.FieldInt64s, field.TypeJSON, value) + } + if value, ok := uu.mutation.AppendedInt64s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, user.FieldInt64s, value) + }) + } + if uu.mutation.Int64sCleared() { + _spec.ClearField(user.FieldInt64s, field.TypeJSON) + } + if value, ok := uu.mutation.Uint32s(); ok { + _spec.SetField(user.FieldUint32s, field.TypeJSON, value) + } + if value, ok := uu.mutation.AppendedUint32s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, user.FieldUint32s, value) + }) + } + if uu.mutation.Uint32sCleared() { + _spec.ClearField(user.FieldUint32s, field.TypeJSON) + } + if value, ok := uu.mutation.Uint64s(); ok { + _spec.SetField(user.FieldUint64s, field.TypeJSON, value) + } + if value, ok := uu.mutation.AppendedUint64s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, user.FieldUint64s, value) + }) + } + if uu.mutation.Uint64sCleared() { + _spec.ClearField(user.FieldUint64s, field.TypeJSON) + } if value, ok := uu.mutation.DeviceType(); ok { _spec.SetField(user.FieldDeviceType, field.TypeEnum, value) } if value, ok := uu.mutation.OmitPrefix(); ok { _spec.SetField(user.FieldOmitPrefix, field.TypeEnum, value) } + if value, ok := uu.mutation.MimeType(); ok { + _spec.SetField(user.FieldMimeType, field.TypeEnum, value) + } if uu.mutation.GroupCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -852,6 +1054,14 @@ func (uuo *UserUpdateOne) SetUserName(s string) *UserUpdateOne { return uuo } +// SetNillableUserName sets the "user_name" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableUserName(s *string) *UserUpdateOne { + if s != nil { + uuo.SetUserName(*s) + } + return uuo +} + // SetPoints sets the "points" field. func (uuo *UserUpdateOne) SetPoints(u uint) *UserUpdateOne { uuo.mutation.ResetPoints() @@ -859,6 +1069,14 @@ func (uuo *UserUpdateOne) SetPoints(u uint) *UserUpdateOne { return uuo } +// SetNillablePoints sets the "points" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillablePoints(u *uint) *UserUpdateOne { + if u != nil { + uuo.SetPoints(*u) + } + return uuo +} + // AddPoints adds u to the "points" field. func (uuo *UserUpdateOne) AddPoints(u int) *UserUpdateOne { uuo.mutation.AddPoints(u) @@ -872,6 +1090,14 @@ func (uuo *UserUpdateOne) SetExp(u uint64) *UserUpdateOne { return uuo } +// SetNillableExp sets the "exp" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableExp(u *uint64) *UserUpdateOne { + if u != nil { + uuo.SetExp(*u) + } + return uuo +} + // AddExp adds u to the "exp" field. func (uuo *UserUpdateOne) AddExp(u int64) *UserUpdateOne { uuo.mutation.AddExp(u) @@ -884,6 +1110,14 @@ func (uuo *UserUpdateOne) SetStatus(u user.Status) *UserUpdateOne { return uuo } +// SetNillableStatus sets the "status" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableStatus(u *user.Status) *UserUpdateOne { + if u != nil { + uuo.SetStatus(*u) + } + return uuo +} + // SetExternalID sets the "external_id" field. func (uuo *UserUpdateOne) SetExternalID(i int) *UserUpdateOne { uuo.mutation.ResetExternalID() @@ -891,6 +1125,14 @@ func (uuo *UserUpdateOne) SetExternalID(i int) *UserUpdateOne { return uuo } +// SetNillableExternalID sets the "external_id" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableExternalID(i *int) *UserUpdateOne { + if i != nil { + uuo.SetExternalID(*i) + } + return uuo +} + // AddExternalID adds i to the "external_id" field. func (uuo *UserUpdateOne) AddExternalID(i int) *UserUpdateOne { uuo.mutation.AddExternalID(i) @@ -903,6 +1145,14 @@ func (uuo *UserUpdateOne) SetCrmID(u uuid.UUID) *UserUpdateOne { return uuo } +// SetNillableCrmID sets the "crm_id" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableCrmID(u *uuid.UUID) *UserUpdateOne { + if u != nil { + uuo.SetCrmID(*u) + } + return uuo +} + // SetBanned sets the "banned" field. func (uuo *UserUpdateOne) SetBanned(b bool) *UserUpdateOne { uuo.mutation.SetBanned(b) @@ -924,6 +1174,14 @@ func (uuo *UserUpdateOne) SetCustomPb(u uint8) *UserUpdateOne { return uuo } +// SetNillableCustomPb sets the "custom_pb" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableCustomPb(u *uint8) *UserUpdateOne { + if u != nil { + uuo.SetCustomPb(*u) + } + return uuo +} + // AddCustomPb adds u to the "custom_pb" field. func (uuo *UserUpdateOne) AddCustomPb(u int8) *UserUpdateOne { uuo.mutation.AddCustomPb(u) @@ -1144,6 +1402,78 @@ func (uuo *UserUpdateOne) ClearLabels() *UserUpdateOne { return uuo } +// SetInt32s sets the "int32s" field. +func (uuo *UserUpdateOne) SetInt32s(i []int32) *UserUpdateOne { + uuo.mutation.SetInt32s(i) + return uuo +} + +// AppendInt32s appends i to the "int32s" field. +func (uuo *UserUpdateOne) AppendInt32s(i []int32) *UserUpdateOne { + uuo.mutation.AppendInt32s(i) + return uuo +} + +// ClearInt32s clears the value of the "int32s" field. +func (uuo *UserUpdateOne) ClearInt32s() *UserUpdateOne { + uuo.mutation.ClearInt32s() + return uuo +} + +// SetInt64s sets the "int64s" field. +func (uuo *UserUpdateOne) SetInt64s(i []int64) *UserUpdateOne { + uuo.mutation.SetInt64s(i) + return uuo +} + +// AppendInt64s appends i to the "int64s" field. +func (uuo *UserUpdateOne) AppendInt64s(i []int64) *UserUpdateOne { + uuo.mutation.AppendInt64s(i) + return uuo +} + +// ClearInt64s clears the value of the "int64s" field. +func (uuo *UserUpdateOne) ClearInt64s() *UserUpdateOne { + uuo.mutation.ClearInt64s() + return uuo +} + +// SetUint32s sets the "uint32s" field. +func (uuo *UserUpdateOne) SetUint32s(u []uint32) *UserUpdateOne { + uuo.mutation.SetUint32s(u) + return uuo +} + +// AppendUint32s appends u to the "uint32s" field. +func (uuo *UserUpdateOne) AppendUint32s(u []uint32) *UserUpdateOne { + uuo.mutation.AppendUint32s(u) + return uuo +} + +// ClearUint32s clears the value of the "uint32s" field. +func (uuo *UserUpdateOne) ClearUint32s() *UserUpdateOne { + uuo.mutation.ClearUint32s() + return uuo +} + +// SetUint64s sets the "uint64s" field. +func (uuo *UserUpdateOne) SetUint64s(u []uint64) *UserUpdateOne { + uuo.mutation.SetUint64s(u) + return uuo +} + +// AppendUint64s appends u to the "uint64s" field. +func (uuo *UserUpdateOne) AppendUint64s(u []uint64) *UserUpdateOne { + uuo.mutation.AppendUint64s(u) + return uuo +} + +// ClearUint64s clears the value of the "uint64s" field. +func (uuo *UserUpdateOne) ClearUint64s() *UserUpdateOne { + uuo.mutation.ClearUint64s() + return uuo +} + // SetDeviceType sets the "device_type" field. func (uuo *UserUpdateOne) SetDeviceType(ut user.DeviceType) *UserUpdateOne { uuo.mutation.SetDeviceType(ut) @@ -1164,6 +1494,28 @@ func (uuo *UserUpdateOne) SetOmitPrefix(up user.OmitPrefix) *UserUpdateOne { return uuo } +// SetNillableOmitPrefix sets the "omit_prefix" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableOmitPrefix(up *user.OmitPrefix) *UserUpdateOne { + if up != nil { + uuo.SetOmitPrefix(*up) + } + return uuo +} + +// SetMimeType sets the "mime_type" field. +func (uuo *UserUpdateOne) SetMimeType(ut user.MimeType) *UserUpdateOne { + uuo.mutation.SetMimeType(ut) + return uuo +} + +// SetNillableMimeType sets the "mime_type" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableMimeType(ut *user.MimeType) *UserUpdateOne { + if ut != nil { + uuo.SetMimeType(*ut) + } + return uuo +} + // SetGroupID sets the "group" edge to the Group entity by ID. func (uuo *UserUpdateOne) SetGroupID(id int) *UserUpdateOne { uuo.mutation.SetGroupID(id) @@ -1320,7 +1672,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -1362,6 +1714,11 @@ func (uuo *UserUpdateOne) check() error { return &ValidationError{Name: "omit_prefix", err: fmt.Errorf(`ent: validator failed for field "User.omit_prefix": %w`, err)} } } + if v, ok := uuo.mutation.MimeType(); ok { + if err := user.MimeTypeValidator(v); err != nil { + return &ValidationError{Name: "mime_type", err: fmt.Errorf(`ent: validator failed for field "User.mime_type": %w`, err)} + } + } return nil } @@ -1501,12 +1858,59 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if uuo.mutation.LabelsCleared() { _spec.ClearField(user.FieldLabels, field.TypeJSON) } + if value, ok := uuo.mutation.Int32s(); ok { + _spec.SetField(user.FieldInt32s, field.TypeJSON, value) + } + if value, ok := uuo.mutation.AppendedInt32s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, user.FieldInt32s, value) + }) + } + if uuo.mutation.Int32sCleared() { + _spec.ClearField(user.FieldInt32s, field.TypeJSON) + } + if value, ok := uuo.mutation.Int64s(); ok { + _spec.SetField(user.FieldInt64s, field.TypeJSON, value) + } + if value, ok := uuo.mutation.AppendedInt64s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, user.FieldInt64s, value) + }) + } + if uuo.mutation.Int64sCleared() { + _spec.ClearField(user.FieldInt64s, field.TypeJSON) + } + if value, ok := uuo.mutation.Uint32s(); ok { + _spec.SetField(user.FieldUint32s, field.TypeJSON, value) + } + if value, ok := uuo.mutation.AppendedUint32s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, user.FieldUint32s, value) + }) + } + if uuo.mutation.Uint32sCleared() { + _spec.ClearField(user.FieldUint32s, field.TypeJSON) + } + if value, ok := uuo.mutation.Uint64s(); ok { + _spec.SetField(user.FieldUint64s, field.TypeJSON, value) + } + if value, ok := uuo.mutation.AppendedUint64s(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, user.FieldUint64s, value) + }) + } + if uuo.mutation.Uint64sCleared() { + _spec.ClearField(user.FieldUint64s, field.TypeJSON) + } if value, ok := uuo.mutation.DeviceType(); ok { _spec.SetField(user.FieldDeviceType, field.TypeEnum, value) } if value, ok := uuo.mutation.OmitPrefix(); ok { _spec.SetField(user.FieldOmitPrefix, field.TypeEnum, value) } + if value, ok := uuo.mutation.MimeType(); ok { + _spec.SetField(user.FieldMimeType, field.TypeEnum, value) + } if uuo.mutation.GroupCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/entproto/internal/todo/generate_test.go b/entproto/internal/todo/generate_test.go index 95edb44f3..31e918221 100644 --- a/entproto/internal/todo/generate_test.go +++ b/entproto/internal/todo/generate_test.go @@ -27,9 +27,7 @@ import ( ) func TestGenerate(t *testing.T) { - tgt, err := os.MkdirTemp(os.TempDir(), "entproto-test-*") - defer os.RemoveAll(tgt) - require.NoError(t, err) + tgt := t.TempDir() graph, err := entc.LoadGraph("./ent/schema", &gen.Config{ Target: tgt, }) @@ -42,3 +40,26 @@ func TestGenerate(t *testing.T) { require.NoError(t, err) require.True(t, strings.Contains(string(bytes), "// Code generated by entproto. DO NOT EDIT.")) } + +func TestGenerateOptionSkipGenFile(t *testing.T) { + tgt := t.TempDir() + + entprotoExt, err := entproto.NewExtension(entproto.SkipGenFile()) + require.NoError(t, err) + + err = entc.Generate( + "./ent/schema", + &gen.Config{ + Target: tgt, + }, + entc.Extensions(entprotoExt), + ) + require.NoError(t, err) + + bytes, err := os.ReadFile(filepath.Join(tgt, "proto", "entpb", "entpb.proto")) + require.NoError(t, err) + require.True(t, strings.Contains(string(bytes), "// Code generated by entproto. DO NOT EDIT.")) + + _, err = os.Stat(filepath.Join(tgt, "proto", "entpb", "generate.go")) + require.True(t, os.IsNotExist(err)) +} diff --git a/go.mod b/go.mod index 600106991..e09d41608 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,12 @@ module entgo.io/contrib -go 1.18 +go 1.21 + +toolchain go1.21.6 require ( - entgo.io/ent v0.12.2 - github.com/99designs/gqlgen v0.17.5-0.20220428154617-9250f9ac1f90 + entgo.io/ent v0.13.0 + github.com/99designs/gqlgen v0.17.43 github.com/AlekSi/pointer v1.1.0 github.com/alecthomas/kong v0.7.0 github.com/go-openapi/inflect v0.19.0 @@ -17,19 +19,19 @@ require ( github.com/oklog/ulid/v2 v2.0.2 github.com/stoewer/go-strcase v1.2.0 github.com/stretchr/testify v1.8.2 - github.com/vektah/gqlparser/v2 v2.4.3-0.20220508162109-d3d9eb001575 + github.com/vektah/gqlparser/v2 v2.5.11 github.com/vmihailenco/msgpack/v5 v5.0.0-beta.9 go.uber.org/multierr v1.9.0 go.uber.org/zap v1.24.0 golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 - golang.org/x/sync v0.1.0 - golang.org/x/tools v0.7.0 + golang.org/x/sync v0.6.0 + golang.org/x/tools v0.17.0 google.golang.org/grpc v1.52.3 - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.30.0 ) require ( - ariga.io/atlas v0.10.0 // indirect + ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect github.com/agext/levenshtein v1.2.1 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect @@ -41,25 +43,26 @@ require ( github.com/go-faster/jx v0.40.0 // indirect github.com/go-faster/yamlx v0.4.1 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect - github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl/v2 v2.13.0 // indirect github.com/logrusorgru/aurora/v3 v3.0.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/segmentio/asm v1.2.0 // indirect + github.com/sosodev/duration v1.1.0 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/vmihailenco/tagparser v0.1.2 // indirect github.com/zclconf/go-cty v1.8.0 // indirect go.uber.org/atomic v1.10.0 // indirect - golang.org/x/mod v0.9.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 781bee169..1dceb3f63 100644 --- a/go.sum +++ b/go.sum @@ -1,33 +1,39 @@ -ariga.io/atlas v0.10.0 h1:B1aCP6gSDQET6j8ybn7m6MArjQuoLH5d4DQBT+NP5k8= -ariga.io/atlas v0.10.0/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk= +ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14= +ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -entgo.io/ent v0.12.2 h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM= -entgo.io/ent v0.12.2/go.mod h1:OA1Y5bNE8EtlxKv4IyzWwt4jgvGbkoKMcwp668iEKQE= -github.com/99designs/gqlgen v0.17.5-0.20220428154617-9250f9ac1f90 h1:nGGP+sUJ6D3guzjVBgoH1PrZxoU4lUdfR/Q8THYrAJI= -github.com/99designs/gqlgen v0.17.5-0.20220428154617-9250f9ac1f90/go.mod h1:SNpLVzaF37rRLSAXtu8FKVp5I4zycneMmFX6NT4XGSU= +entgo.io/ent v0.13.0 h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE= +entgo.io/ent v0.13.0/go.mod h1:+oU8oGna69xy29O+g+NEz+/TM7yJDhQQGJfuOWq1pT8= +github.com/99designs/gqlgen v0.17.43 h1:I4SYg6ahjowErAQcHFVKy5EcWuwJ3+Xw9z2fLpuFCPo= +github.com/99designs/gqlgen v0.17.43/go.mod h1:lO0Zjy8MkZgBdv4T1U91x09r0e0WFOdhVUutlQs1Rsc= github.com/AlekSi/pointer v1.1.0 h1:SSDMPcXD9jSl8FPy9cRzoRaMJtm9g9ggGTxecRUbQoI= github.com/AlekSi/pointer v1.1.0/go.mod h1:y7BvfRI3wXPWKXEBhU71nbnIEEZX0QTSB2Bj48UJIZE= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= +github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ= github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2ojoH/0= +github.com/alecthomas/assert/v2 v2.1.0/go.mod h1:b/+1DI2Q6NckYi+3mXyH3wFb8qG37K/DuK80n7WefXA= github.com/alecthomas/kong v0.7.0 h1:YIjJUiR7AcmHxL87UlbPn0gyIGwl4+nYND0OQ4ojP7k= github.com/alecthomas/kong v0.7.0/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE= +github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= +github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -50,6 +56,7 @@ github.com/go-faster/yamlx v0.4.1/go.mod h1:QXr/i3Z00jRhskgyWkoGsEdseebd/ZbZEpGS github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -72,8 +79,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -84,38 +91,38 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/jhump/protoreflect v1.10.1 h1:iH+UZfsbRE6vpyZH7asAjTPWJf7RJbpZ9j/N3lDlKs0= github.com/jhump/protoreflect v1.10.1/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= -github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4= github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= -github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= @@ -125,32 +132,31 @@ github.com/oklog/ulid/v2 v2.0.2 h1:r4fFzBm+bv0wNKNh5eXTwU7i85y5x+uwkxCUTNVQqLc= github.com/oklog/ulid/v2 v2.0.2/go.mod h1:mtBL0Qe/0HAx6/a4Z30qxVIAL1eQDweXq5lxOEiwQ68= github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sosodev/duration v1.1.0 h1:kQcaiGbJaIsRqgQy7VGlZrVw1giWO+lDoX3MCPnpVO4= +github.com/sosodev/duration v1.1.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg= -github.com/vektah/gqlparser/v2 v2.4.2/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0= -github.com/vektah/gqlparser/v2 v2.4.3-0.20220508162109-d3d9eb001575 h1:96uWUPr8zxRRakTqu0yMKCnTPEsZ5oViVDL1XvkP4Tc= -github.com/vektah/gqlparser/v2 v2.4.3-0.20220508162109-d3d9eb001575/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0= +github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8= +github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/msgpack/v5 v5.0.0-beta.9 h1:iBRIniTnWOo0kqkg3k3XR8Vn6OCkVlIuZNo0UoBrKx4= github.com/vmihailenco/msgpack/v5 v5.0.0-beta.9/go.mod h1:HVxBVPUK/+fZMonk4bi1islLa8V3cfnBug0+4dykPzo= @@ -159,12 +165,12 @@ github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vb github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= @@ -173,7 +179,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 h1:m9O6OTJ627iFnN2JIWfdqlZCzneRO6EEBsHXI25P8ws= golang.org/x/exp v0.0.0-20221230185412-738e83a70c30/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= @@ -183,10 +188,8 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= -golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -197,43 +200,32 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -243,14 +235,11 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= @@ -275,17 +264,14 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/schemast/internal/loadtest/ent/client.go b/schemast/internal/loadtest/ent/client.go index 72b5f8798..50ee54d45 100644 --- a/schemast/internal/loadtest/ent/client.go +++ b/schemast/internal/loadtest/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/schemast/internal/loadtest/ent/migrate" "entgo.io/ent" @@ -27,9 +28,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -57,6 +56,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -104,11 +110,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -220,6 +229,21 @@ func (c *MessageClient) CreateBulk(builders ...*MessageCreate) *MessageCreateBul return &MessageCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageClient) MapCreateBulk(slice any, setFunc func(*MessageCreate, int)) *MessageCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageCreateBulk{err: fmt.Errorf("calling to MessageClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Message. func (c *MessageClient) Update() *MessageUpdate { mutation := newMessageMutation(c.config, OpUpdate) diff --git a/schemast/internal/loadtest/ent/message/where.go b/schemast/internal/loadtest/ent/message/where.go index c67db20d9..ad4c0585f 100644 --- a/schemast/internal/loadtest/ent/message/where.go +++ b/schemast/internal/loadtest/ent/message/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.Message { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Message) predicate.Message { - return predicate.Message(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Message(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Message) predicate.Message { - return predicate.Message(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Message(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Message) predicate.Message { - return predicate.Message(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Message(sql.NotPredicates(p)) } diff --git a/schemast/internal/loadtest/ent/message_create.go b/schemast/internal/loadtest/ent/message_create.go index d8aec0497..7be2f1977 100644 --- a/schemast/internal/loadtest/ent/message_create.go +++ b/schemast/internal/loadtest/ent/message_create.go @@ -25,7 +25,7 @@ func (mc *MessageCreate) Mutation() *MessageMutation { // Save creates the Message in the database. func (mc *MessageCreate) Save(ctx context.Context) (*Message, error) { - return withHooks[*Message, MessageMutation](ctx, mc.sqlSave, mc.mutation, mc.hooks) + return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (mc *MessageCreate) createSpec() (*Message, *sqlgraph.CreateSpec) { // MessageCreateBulk is the builder for creating many Message entities in bulk. type MessageCreateBulk struct { config + err error builders []*MessageCreate } // Save creates the Message entities in the database. func (mcb *MessageCreateBulk) Save(ctx context.Context) ([]*Message, error) { + if mcb.err != nil { + return nil, mcb.err + } specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) nodes := make([]*Message, len(mcb.builders)) mutators := make([]Mutator, len(mcb.builders)) diff --git a/schemast/internal/loadtest/ent/message_delete.go b/schemast/internal/loadtest/ent/message_delete.go index c585b787b..97c9bd74f 100644 --- a/schemast/internal/loadtest/ent/message_delete.go +++ b/schemast/internal/loadtest/ent/message_delete.go @@ -27,7 +27,7 @@ func (md *MessageDelete) Where(ps ...predicate.Message) *MessageDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (md *MessageDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MessageMutation](ctx, md.sqlExec, md.mutation, md.hooks) + return withHooks(ctx, md.sqlExec, md.mutation, md.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/schemast/internal/loadtest/ent/message_update.go b/schemast/internal/loadtest/ent/message_update.go index a8a7d42a5..4e1c1e523 100644 --- a/schemast/internal/loadtest/ent/message_update.go +++ b/schemast/internal/loadtest/ent/message_update.go @@ -34,7 +34,7 @@ func (mu *MessageUpdate) Mutation() *MessageMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (mu *MessageUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MessageMutation](ctx, mu.sqlSave, mu.mutation, mu.hooks) + return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (muo *MessageUpdateOne) Select(field string, fields ...string) *MessageUpda // Save executes the query and returns the updated Message entity. func (muo *MessageUpdateOne) Save(ctx context.Context) (*Message, error) { - return withHooks[*Message, MessageMutation](ctx, muo.sqlSave, muo.mutation, muo.hooks) + return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/schemast/internal/loadtest/ent/runtime/runtime.go b/schemast/internal/loadtest/ent/runtime/runtime.go index 2664987df..c74c50bf5 100644 --- a/schemast/internal/loadtest/ent/runtime/runtime.go +++ b/schemast/internal/loadtest/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/schemast/internal/loadtest/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/schemast/internal/mutatetest/ent/client.go b/schemast/internal/mutatetest/ent/client.go index d992c65e4..d3487e6ed 100644 --- a/schemast/internal/mutatetest/ent/client.go +++ b/schemast/internal/mutatetest/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/schemast/internal/mutatetest/ent/migrate" "entgo.io/ent" @@ -40,9 +41,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -74,6 +73,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -121,11 +127,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -261,6 +270,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) @@ -379,6 +403,21 @@ func (c *WithFieldsClient) CreateBulk(builders ...*WithFieldsCreate) *WithFields return &WithFieldsCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *WithFieldsClient) MapCreateBulk(slice any, setFunc func(*WithFieldsCreate, int)) *WithFieldsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &WithFieldsCreateBulk{err: fmt.Errorf("calling to WithFieldsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*WithFieldsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &WithFieldsCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for WithFields. func (c *WithFieldsClient) Update() *WithFieldsUpdate { mutation := newWithFieldsMutation(c.config, OpUpdate) @@ -497,6 +536,21 @@ func (c *WithModifiedFieldClient) CreateBulk(builders ...*WithModifiedFieldCreat return &WithModifiedFieldCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *WithModifiedFieldClient) MapCreateBulk(slice any, setFunc func(*WithModifiedFieldCreate, int)) *WithModifiedFieldCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &WithModifiedFieldCreateBulk{err: fmt.Errorf("calling to WithModifiedFieldClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*WithModifiedFieldCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &WithModifiedFieldCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for WithModifiedField. func (c *WithModifiedFieldClient) Update() *WithModifiedFieldUpdate { mutation := newWithModifiedFieldMutation(c.config, OpUpdate) @@ -631,6 +685,21 @@ func (c *WithNilFieldsClient) CreateBulk(builders ...*WithNilFieldsCreate) *With return &WithNilFieldsCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *WithNilFieldsClient) MapCreateBulk(slice any, setFunc func(*WithNilFieldsCreate, int)) *WithNilFieldsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &WithNilFieldsCreateBulk{err: fmt.Errorf("calling to WithNilFieldsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*WithNilFieldsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &WithNilFieldsCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for WithNilFields. func (c *WithNilFieldsClient) Update() *WithNilFieldsUpdate { mutation := newWithNilFieldsMutation(c.config, OpUpdate) @@ -749,6 +818,21 @@ func (c *WithoutFieldsClient) CreateBulk(builders ...*WithoutFieldsCreate) *With return &WithoutFieldsCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *WithoutFieldsClient) MapCreateBulk(slice any, setFunc func(*WithoutFieldsCreate, int)) *WithoutFieldsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &WithoutFieldsCreateBulk{err: fmt.Errorf("calling to WithoutFieldsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*WithoutFieldsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &WithoutFieldsCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for WithoutFields. func (c *WithoutFieldsClient) Update() *WithoutFieldsUpdate { mutation := newWithoutFieldsMutation(c.config, OpUpdate) diff --git a/schemast/internal/mutatetest/ent/runtime/runtime.go b/schemast/internal/mutatetest/ent/runtime/runtime.go index b31a36a87..57fbfe086 100644 --- a/schemast/internal/mutatetest/ent/runtime/runtime.go +++ b/schemast/internal/mutatetest/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/schemast/internal/mutatetest/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/schemast/internal/mutatetest/ent/user/where.go b/schemast/internal/mutatetest/ent/user/where.go index 41d2d93a1..96bcf60e2 100644 --- a/schemast/internal/mutatetest/ent/user/where.go +++ b/schemast/internal/mutatetest/ent/user/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/schemast/internal/mutatetest/ent/user_create.go b/schemast/internal/mutatetest/ent/user_create.go index 38548ca76..61499e0dd 100644 --- a/schemast/internal/mutatetest/ent/user_create.go +++ b/schemast/internal/mutatetest/ent/user_create.go @@ -25,7 +25,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/schemast/internal/mutatetest/ent/user_delete.go b/schemast/internal/mutatetest/ent/user_delete.go index 6c6e11afc..da0b9db5d 100644 --- a/schemast/internal/mutatetest/ent/user_delete.go +++ b/schemast/internal/mutatetest/ent/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/user_update.go b/schemast/internal/mutatetest/ent/user_update.go index b954088ac..74e80e469 100644 --- a/schemast/internal/mutatetest/ent/user_update.go +++ b/schemast/internal/mutatetest/ent/user_update.go @@ -34,7 +34,7 @@ func (uu *UserUpdate) Mutation() *UserMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/withfields/where.go b/schemast/internal/mutatetest/ent/withfields/where.go index 2348ac05b..dbb2bc620 100644 --- a/schemast/internal/mutatetest/ent/withfields/where.go +++ b/schemast/internal/mutatetest/ent/withfields/where.go @@ -124,32 +124,15 @@ func ExistingContainsFold(v string) predicate.WithFields { // And groups predicates with the AND operator between them. func And(predicates ...predicate.WithFields) predicate.WithFields { - return predicate.WithFields(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.WithFields(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.WithFields) predicate.WithFields { - return predicate.WithFields(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.WithFields(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.WithFields) predicate.WithFields { - return predicate.WithFields(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.WithFields(sql.NotPredicates(p)) } diff --git a/schemast/internal/mutatetest/ent/withfields_create.go b/schemast/internal/mutatetest/ent/withfields_create.go index f025174cc..01bcae22d 100644 --- a/schemast/internal/mutatetest/ent/withfields_create.go +++ b/schemast/internal/mutatetest/ent/withfields_create.go @@ -32,7 +32,7 @@ func (wfc *WithFieldsCreate) Mutation() *WithFieldsMutation { // Save creates the WithFields in the database. func (wfc *WithFieldsCreate) Save(ctx context.Context) (*WithFields, error) { - return withHooks[*WithFields, WithFieldsMutation](ctx, wfc.sqlSave, wfc.mutation, wfc.hooks) + return withHooks(ctx, wfc.sqlSave, wfc.mutation, wfc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -98,11 +98,15 @@ func (wfc *WithFieldsCreate) createSpec() (*WithFields, *sqlgraph.CreateSpec) { // WithFieldsCreateBulk is the builder for creating many WithFields entities in bulk. type WithFieldsCreateBulk struct { config + err error builders []*WithFieldsCreate } // Save creates the WithFields entities in the database. func (wfcb *WithFieldsCreateBulk) Save(ctx context.Context) ([]*WithFields, error) { + if wfcb.err != nil { + return nil, wfcb.err + } specs := make([]*sqlgraph.CreateSpec, len(wfcb.builders)) nodes := make([]*WithFields, len(wfcb.builders)) mutators := make([]Mutator, len(wfcb.builders)) diff --git a/schemast/internal/mutatetest/ent/withfields_delete.go b/schemast/internal/mutatetest/ent/withfields_delete.go index 4a9bfde2b..3cc4e01cc 100644 --- a/schemast/internal/mutatetest/ent/withfields_delete.go +++ b/schemast/internal/mutatetest/ent/withfields_delete.go @@ -27,7 +27,7 @@ func (wfd *WithFieldsDelete) Where(ps ...predicate.WithFields) *WithFieldsDelete // Exec executes the deletion query and returns how many vertices were deleted. func (wfd *WithFieldsDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, WithFieldsMutation](ctx, wfd.sqlExec, wfd.mutation, wfd.hooks) + return withHooks(ctx, wfd.sqlExec, wfd.mutation, wfd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/withfields_update.go b/schemast/internal/mutatetest/ent/withfields_update.go index 4c6138c02..d70b161a5 100644 --- a/schemast/internal/mutatetest/ent/withfields_update.go +++ b/schemast/internal/mutatetest/ent/withfields_update.go @@ -33,6 +33,14 @@ func (wfu *WithFieldsUpdate) SetExisting(s string) *WithFieldsUpdate { return wfu } +// SetNillableExisting sets the "existing" field if the given value is not nil. +func (wfu *WithFieldsUpdate) SetNillableExisting(s *string) *WithFieldsUpdate { + if s != nil { + wfu.SetExisting(*s) + } + return wfu +} + // Mutation returns the WithFieldsMutation object of the builder. func (wfu *WithFieldsUpdate) Mutation() *WithFieldsMutation { return wfu.mutation @@ -40,7 +48,7 @@ func (wfu *WithFieldsUpdate) Mutation() *WithFieldsMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (wfu *WithFieldsUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, WithFieldsMutation](ctx, wfu.sqlSave, wfu.mutation, wfu.hooks) + return withHooks(ctx, wfu.sqlSave, wfu.mutation, wfu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -103,6 +111,14 @@ func (wfuo *WithFieldsUpdateOne) SetExisting(s string) *WithFieldsUpdateOne { return wfuo } +// SetNillableExisting sets the "existing" field if the given value is not nil. +func (wfuo *WithFieldsUpdateOne) SetNillableExisting(s *string) *WithFieldsUpdateOne { + if s != nil { + wfuo.SetExisting(*s) + } + return wfuo +} + // Mutation returns the WithFieldsMutation object of the builder. func (wfuo *WithFieldsUpdateOne) Mutation() *WithFieldsMutation { return wfuo.mutation @@ -123,7 +139,7 @@ func (wfuo *WithFieldsUpdateOne) Select(field string, fields ...string) *WithFie // Save executes the query and returns the updated WithFields entity. func (wfuo *WithFieldsUpdateOne) Save(ctx context.Context) (*WithFields, error) { - return withHooks[*WithFields, WithFieldsMutation](ctx, wfuo.sqlSave, wfuo.mutation, wfuo.hooks) + return withHooks(ctx, wfuo.sqlSave, wfuo.mutation, wfuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/withmodifiedfield/where.go b/schemast/internal/mutatetest/ent/withmodifiedfield/where.go index 19212d953..c909d1fec 100644 --- a/schemast/internal/mutatetest/ent/withmodifiedfield/where.go +++ b/schemast/internal/mutatetest/ent/withmodifiedfield/where.go @@ -148,32 +148,15 @@ func HasOwnerWith(preds ...predicate.User) predicate.WithModifiedField { // And groups predicates with the AND operator between them. func And(predicates ...predicate.WithModifiedField) predicate.WithModifiedField { - return predicate.WithModifiedField(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.WithModifiedField(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.WithModifiedField) predicate.WithModifiedField { - return predicate.WithModifiedField(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.WithModifiedField(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.WithModifiedField) predicate.WithModifiedField { - return predicate.WithModifiedField(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.WithModifiedField(sql.NotPredicates(p)) } diff --git a/schemast/internal/mutatetest/ent/withmodifiedfield_create.go b/schemast/internal/mutatetest/ent/withmodifiedfield_create.go index e748a31b0..4a8bd43cb 100644 --- a/schemast/internal/mutatetest/ent/withmodifiedfield_create.go +++ b/schemast/internal/mutatetest/ent/withmodifiedfield_create.go @@ -52,7 +52,7 @@ func (wmfc *WithModifiedFieldCreate) Mutation() *WithModifiedFieldMutation { // Save creates the WithModifiedField in the database. func (wmfc *WithModifiedFieldCreate) Save(ctx context.Context) (*WithModifiedField, error) { - return withHooks[*WithModifiedField, WithModifiedFieldMutation](ctx, wmfc.sqlSave, wmfc.mutation, wmfc.hooks) + return withHooks(ctx, wmfc.sqlSave, wmfc.mutation, wmfc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -140,11 +140,15 @@ func (wmfc *WithModifiedFieldCreate) createSpec() (*WithModifiedField, *sqlgraph // WithModifiedFieldCreateBulk is the builder for creating many WithModifiedField entities in bulk. type WithModifiedFieldCreateBulk struct { config + err error builders []*WithModifiedFieldCreate } // Save creates the WithModifiedField entities in the database. func (wmfcb *WithModifiedFieldCreateBulk) Save(ctx context.Context) ([]*WithModifiedField, error) { + if wmfcb.err != nil { + return nil, wmfcb.err + } specs := make([]*sqlgraph.CreateSpec, len(wmfcb.builders)) nodes := make([]*WithModifiedField, len(wmfcb.builders)) mutators := make([]Mutator, len(wmfcb.builders)) diff --git a/schemast/internal/mutatetest/ent/withmodifiedfield_delete.go b/schemast/internal/mutatetest/ent/withmodifiedfield_delete.go index 07dca7c72..c09ce2811 100644 --- a/schemast/internal/mutatetest/ent/withmodifiedfield_delete.go +++ b/schemast/internal/mutatetest/ent/withmodifiedfield_delete.go @@ -27,7 +27,7 @@ func (wmfd *WithModifiedFieldDelete) Where(ps ...predicate.WithModifiedField) *W // Exec executes the deletion query and returns how many vertices were deleted. func (wmfd *WithModifiedFieldDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, WithModifiedFieldMutation](ctx, wmfd.sqlExec, wmfd.mutation, wmfd.hooks) + return withHooks(ctx, wmfd.sqlExec, wmfd.mutation, wmfd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/withmodifiedfield_update.go b/schemast/internal/mutatetest/ent/withmodifiedfield_update.go index 4c0838950..255c98234 100644 --- a/schemast/internal/mutatetest/ent/withmodifiedfield_update.go +++ b/schemast/internal/mutatetest/ent/withmodifiedfield_update.go @@ -60,7 +60,7 @@ func (wmfu *WithModifiedFieldUpdate) ClearOwner() *WithModifiedFieldUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (wmfu *WithModifiedFieldUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, WithModifiedFieldMutation](ctx, wmfu.sqlSave, wmfu.mutation, wmfu.hooks) + return withHooks(ctx, wmfu.sqlSave, wmfu.mutation, wmfu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -188,7 +188,7 @@ func (wmfuo *WithModifiedFieldUpdateOne) Select(field string, fields ...string) // Save executes the query and returns the updated WithModifiedField entity. func (wmfuo *WithModifiedFieldUpdateOne) Save(ctx context.Context) (*WithModifiedField, error) { - return withHooks[*WithModifiedField, WithModifiedFieldMutation](ctx, wmfuo.sqlSave, wmfuo.mutation, wmfuo.hooks) + return withHooks(ctx, wmfuo.sqlSave, wmfuo.mutation, wmfuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/withnilfields/where.go b/schemast/internal/mutatetest/ent/withnilfields/where.go index 7f7d0fde5..34d02efa0 100644 --- a/schemast/internal/mutatetest/ent/withnilfields/where.go +++ b/schemast/internal/mutatetest/ent/withnilfields/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.WithNilFields { // And groups predicates with the AND operator between them. func And(predicates ...predicate.WithNilFields) predicate.WithNilFields { - return predicate.WithNilFields(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.WithNilFields(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.WithNilFields) predicate.WithNilFields { - return predicate.WithNilFields(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.WithNilFields(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.WithNilFields) predicate.WithNilFields { - return predicate.WithNilFields(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.WithNilFields(sql.NotPredicates(p)) } diff --git a/schemast/internal/mutatetest/ent/withnilfields_create.go b/schemast/internal/mutatetest/ent/withnilfields_create.go index fd22f1207..b2150ab89 100644 --- a/schemast/internal/mutatetest/ent/withnilfields_create.go +++ b/schemast/internal/mutatetest/ent/withnilfields_create.go @@ -25,7 +25,7 @@ func (wnfc *WithNilFieldsCreate) Mutation() *WithNilFieldsMutation { // Save creates the WithNilFields in the database. func (wnfc *WithNilFieldsCreate) Save(ctx context.Context) (*WithNilFields, error) { - return withHooks[*WithNilFields, WithNilFieldsMutation](ctx, wnfc.sqlSave, wnfc.mutation, wnfc.hooks) + return withHooks(ctx, wnfc.sqlSave, wnfc.mutation, wnfc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (wnfc *WithNilFieldsCreate) createSpec() (*WithNilFields, *sqlgraph.CreateS // WithNilFieldsCreateBulk is the builder for creating many WithNilFields entities in bulk. type WithNilFieldsCreateBulk struct { config + err error builders []*WithNilFieldsCreate } // Save creates the WithNilFields entities in the database. func (wnfcb *WithNilFieldsCreateBulk) Save(ctx context.Context) ([]*WithNilFields, error) { + if wnfcb.err != nil { + return nil, wnfcb.err + } specs := make([]*sqlgraph.CreateSpec, len(wnfcb.builders)) nodes := make([]*WithNilFields, len(wnfcb.builders)) mutators := make([]Mutator, len(wnfcb.builders)) diff --git a/schemast/internal/mutatetest/ent/withnilfields_delete.go b/schemast/internal/mutatetest/ent/withnilfields_delete.go index e7ba76f31..1ee35ed91 100644 --- a/schemast/internal/mutatetest/ent/withnilfields_delete.go +++ b/schemast/internal/mutatetest/ent/withnilfields_delete.go @@ -27,7 +27,7 @@ func (wnfd *WithNilFieldsDelete) Where(ps ...predicate.WithNilFields) *WithNilFi // Exec executes the deletion query and returns how many vertices were deleted. func (wnfd *WithNilFieldsDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, WithNilFieldsMutation](ctx, wnfd.sqlExec, wnfd.mutation, wnfd.hooks) + return withHooks(ctx, wnfd.sqlExec, wnfd.mutation, wnfd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/withnilfields_update.go b/schemast/internal/mutatetest/ent/withnilfields_update.go index 3ce0ba69c..3204ac419 100644 --- a/schemast/internal/mutatetest/ent/withnilfields_update.go +++ b/schemast/internal/mutatetest/ent/withnilfields_update.go @@ -34,7 +34,7 @@ func (wnfu *WithNilFieldsUpdate) Mutation() *WithNilFieldsMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (wnfu *WithNilFieldsUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, WithNilFieldsMutation](ctx, wnfu.sqlSave, wnfu.mutation, wnfu.hooks) + return withHooks(ctx, wnfu.sqlSave, wnfu.mutation, wnfu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (wnfuo *WithNilFieldsUpdateOne) Select(field string, fields ...string) *Wit // Save executes the query and returns the updated WithNilFields entity. func (wnfuo *WithNilFieldsUpdateOne) Save(ctx context.Context) (*WithNilFields, error) { - return withHooks[*WithNilFields, WithNilFieldsMutation](ctx, wnfuo.sqlSave, wnfuo.mutation, wnfuo.hooks) + return withHooks(ctx, wnfuo.sqlSave, wnfuo.mutation, wnfuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/withoutfields/where.go b/schemast/internal/mutatetest/ent/withoutfields/where.go index d705afaa2..7dea24364 100644 --- a/schemast/internal/mutatetest/ent/withoutfields/where.go +++ b/schemast/internal/mutatetest/ent/withoutfields/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.WithoutFields { // And groups predicates with the AND operator between them. func And(predicates ...predicate.WithoutFields) predicate.WithoutFields { - return predicate.WithoutFields(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.WithoutFields(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.WithoutFields) predicate.WithoutFields { - return predicate.WithoutFields(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.WithoutFields(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.WithoutFields) predicate.WithoutFields { - return predicate.WithoutFields(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.WithoutFields(sql.NotPredicates(p)) } diff --git a/schemast/internal/mutatetest/ent/withoutfields_create.go b/schemast/internal/mutatetest/ent/withoutfields_create.go index 6ee3d238d..81b511447 100644 --- a/schemast/internal/mutatetest/ent/withoutfields_create.go +++ b/schemast/internal/mutatetest/ent/withoutfields_create.go @@ -25,7 +25,7 @@ func (wfc *WithoutFieldsCreate) Mutation() *WithoutFieldsMutation { // Save creates the WithoutFields in the database. func (wfc *WithoutFieldsCreate) Save(ctx context.Context) (*WithoutFields, error) { - return withHooks[*WithoutFields, WithoutFieldsMutation](ctx, wfc.sqlSave, wfc.mutation, wfc.hooks) + return withHooks(ctx, wfc.sqlSave, wfc.mutation, wfc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (wfc *WithoutFieldsCreate) createSpec() (*WithoutFields, *sqlgraph.CreateSp // WithoutFieldsCreateBulk is the builder for creating many WithoutFields entities in bulk. type WithoutFieldsCreateBulk struct { config + err error builders []*WithoutFieldsCreate } // Save creates the WithoutFields entities in the database. func (wfcb *WithoutFieldsCreateBulk) Save(ctx context.Context) ([]*WithoutFields, error) { + if wfcb.err != nil { + return nil, wfcb.err + } specs := make([]*sqlgraph.CreateSpec, len(wfcb.builders)) nodes := make([]*WithoutFields, len(wfcb.builders)) mutators := make([]Mutator, len(wfcb.builders)) diff --git a/schemast/internal/mutatetest/ent/withoutfields_delete.go b/schemast/internal/mutatetest/ent/withoutfields_delete.go index 6181147fe..56ca69227 100644 --- a/schemast/internal/mutatetest/ent/withoutfields_delete.go +++ b/schemast/internal/mutatetest/ent/withoutfields_delete.go @@ -27,7 +27,7 @@ func (wfd *WithoutFieldsDelete) Where(ps ...predicate.WithoutFields) *WithoutFie // Exec executes the deletion query and returns how many vertices were deleted. func (wfd *WithoutFieldsDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, WithoutFieldsMutation](ctx, wfd.sqlExec, wfd.mutation, wfd.hooks) + return withHooks(ctx, wfd.sqlExec, wfd.mutation, wfd.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/schemast/internal/mutatetest/ent/withoutfields_update.go b/schemast/internal/mutatetest/ent/withoutfields_update.go index 8cca7037d..abd62ad1f 100644 --- a/schemast/internal/mutatetest/ent/withoutfields_update.go +++ b/schemast/internal/mutatetest/ent/withoutfields_update.go @@ -34,7 +34,7 @@ func (wfu *WithoutFieldsUpdate) Mutation() *WithoutFieldsMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (wfu *WithoutFieldsUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, WithoutFieldsMutation](ctx, wfu.sqlSave, wfu.mutation, wfu.hooks) + return withHooks(ctx, wfu.sqlSave, wfu.mutation, wfu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (wfuo *WithoutFieldsUpdateOne) Select(field string, fields ...string) *With // Save executes the query and returns the updated WithoutFields entity. func (wfuo *WithoutFieldsUpdateOne) Save(ctx context.Context) (*WithoutFields, error) { - return withHooks[*WithoutFields, WithoutFieldsMutation](ctx, wfuo.sqlSave, wfuo.mutation, wfuo.hooks) + return withHooks(ctx, wfuo.sqlSave, wfuo.mutation, wfuo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/schemast/internal/printtest/ent/client.go b/schemast/internal/printtest/ent/client.go index 91a257e04..4835dc1f5 100644 --- a/schemast/internal/printtest/ent/client.go +++ b/schemast/internal/printtest/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "entgo.io/contrib/schemast/internal/printtest/ent/migrate" "entgo.io/ent" @@ -30,9 +31,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -61,6 +60,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -108,11 +114,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -230,6 +239,21 @@ func (c *MessageClient) CreateBulk(builders ...*MessageCreate) *MessageCreateBul return &MessageCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessageClient) MapCreateBulk(slice any, setFunc func(*MessageCreate, int)) *MessageCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessageCreateBulk{err: fmt.Errorf("calling to MessageClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessageCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessageCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Message. func (c *MessageClient) Update() *MessageUpdate { mutation := newMessageMutation(c.config, OpUpdate) @@ -348,6 +372,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) diff --git a/schemast/internal/printtest/ent/message/where.go b/schemast/internal/printtest/ent/message/where.go index 1df35a4f8..419de8d38 100644 --- a/schemast/internal/printtest/ent/message/where.go +++ b/schemast/internal/printtest/ent/message/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.Message { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Message) predicate.Message { - return predicate.Message(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Message(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Message) predicate.Message { - return predicate.Message(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Message(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Message) predicate.Message { - return predicate.Message(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Message(sql.NotPredicates(p)) } diff --git a/schemast/internal/printtest/ent/message_create.go b/schemast/internal/printtest/ent/message_create.go index 9ed313770..45a916a88 100644 --- a/schemast/internal/printtest/ent/message_create.go +++ b/schemast/internal/printtest/ent/message_create.go @@ -25,7 +25,7 @@ func (mc *MessageCreate) Mutation() *MessageMutation { // Save creates the Message in the database. func (mc *MessageCreate) Save(ctx context.Context) (*Message, error) { - return withHooks[*Message, MessageMutation](ctx, mc.sqlSave, mc.mutation, mc.hooks) + return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (mc *MessageCreate) createSpec() (*Message, *sqlgraph.CreateSpec) { // MessageCreateBulk is the builder for creating many Message entities in bulk. type MessageCreateBulk struct { config + err error builders []*MessageCreate } // Save creates the Message entities in the database. func (mcb *MessageCreateBulk) Save(ctx context.Context) ([]*Message, error) { + if mcb.err != nil { + return nil, mcb.err + } specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) nodes := make([]*Message, len(mcb.builders)) mutators := make([]Mutator, len(mcb.builders)) diff --git a/schemast/internal/printtest/ent/message_delete.go b/schemast/internal/printtest/ent/message_delete.go index 2d2eb7488..761fd13ae 100644 --- a/schemast/internal/printtest/ent/message_delete.go +++ b/schemast/internal/printtest/ent/message_delete.go @@ -27,7 +27,7 @@ func (md *MessageDelete) Where(ps ...predicate.Message) *MessageDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (md *MessageDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MessageMutation](ctx, md.sqlExec, md.mutation, md.hooks) + return withHooks(ctx, md.sqlExec, md.mutation, md.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/schemast/internal/printtest/ent/message_update.go b/schemast/internal/printtest/ent/message_update.go index 4e2a8e17b..247d29cd7 100644 --- a/schemast/internal/printtest/ent/message_update.go +++ b/schemast/internal/printtest/ent/message_update.go @@ -34,7 +34,7 @@ func (mu *MessageUpdate) Mutation() *MessageMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (mu *MessageUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MessageMutation](ctx, mu.sqlSave, mu.mutation, mu.hooks) + return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (muo *MessageUpdateOne) Select(field string, fields ...string) *MessageUpda // Save executes the query and returns the updated Message entity. func (muo *MessageUpdateOne) Save(ctx context.Context) (*Message, error) { - return withHooks[*Message, MessageMutation](ctx, muo.sqlSave, muo.mutation, muo.hooks) + return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks) } // SaveX is like Save, but panics if an error occurs. diff --git a/schemast/internal/printtest/ent/runtime/runtime.go b/schemast/internal/printtest/ent/runtime/runtime.go index d6a86d96c..9af3985d5 100644 --- a/schemast/internal/printtest/ent/runtime/runtime.go +++ b/schemast/internal/printtest/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in entgo.io/contrib/schemast/internal/printtest/ent/runtime.go const ( - Version = "v0.12.2" // Version of ent codegen. - Sum = "h1:Ndl/JvCX76xCtUDlrUfMnOKBRodAtxE5yfGYxjbOxmM=" // Sum of ent codegen. + Version = "v0.13.0" // Version of ent codegen. + Sum = "h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE=" // Sum of ent codegen. ) diff --git a/schemast/internal/printtest/ent/user/where.go b/schemast/internal/printtest/ent/user/where.go index 73daa1eb7..257c27fea 100644 --- a/schemast/internal/printtest/ent/user/where.go +++ b/schemast/internal/printtest/ent/user/where.go @@ -54,32 +54,15 @@ func IDLTE(id int) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/schemast/internal/printtest/ent/user_create.go b/schemast/internal/printtest/ent/user_create.go index 97ca80dbd..d98d00a02 100644 --- a/schemast/internal/printtest/ent/user_create.go +++ b/schemast/internal/printtest/ent/user_create.go @@ -25,7 +25,7 @@ func (uc *UserCreate) Mutation() *UserMutation { // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -84,11 +84,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/schemast/internal/printtest/ent/user_delete.go b/schemast/internal/printtest/ent/user_delete.go index 9a8e643ec..b032799f7 100644 --- a/schemast/internal/printtest/ent/user_delete.go +++ b/schemast/internal/printtest/ent/user_delete.go @@ -27,7 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks) + return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) } // ExecX is like Exec, but panics if an error occurs. diff --git a/schemast/internal/printtest/ent/user_update.go b/schemast/internal/printtest/ent/user_update.go index fa591754f..d9b3e2b3b 100644 --- a/schemast/internal/printtest/ent/user_update.go +++ b/schemast/internal/printtest/ent/user_update.go @@ -34,7 +34,7 @@ func (uu *UserUpdate) Mutation() *UserMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -108,7 +108,7 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } // SaveX is like Save, but panics if an error occurs.