Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(entgql): add input field directives #612

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions entgql/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ type (
Directive struct {
Name string `json:"name,omitempty"`
Arguments []*ast.Argument `json:"arguments,omitempty"`

SkipTypeField bool `json:"skipOnTypeField,omitempty"`
AddCreateMutationField bool `json:"onInputMutationField,omitempty"`
AddUpdateMutationField bool `json:"onUpdateMutationField,omitempty"`
}

// SkipMode is a bit flag for the Skip annotation.
Expand All @@ -80,6 +84,21 @@ type (
}
)

func (d Directive) SkipOnTypeField() Directive {
d.SkipTypeField = true
return d
}

func (d Directive) OnCreateMutationField() Directive {
d.AddCreateMutationField = true
return d
}

func (d Directive) OnUpdateMutationField() Directive {
d.AddUpdateMutationField = true
return d
}

const (
// SkipType skips generating GraphQL types or fields in the schema.
SkipType SkipMode = 1 << iota
Expand Down
146 changes: 146 additions & 0 deletions entgql/internal/todo/ent.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,17 @@ input CreateCategoryInput {
subCategoryIDs: [ID!]
}
"""
CreateDirectiveExampleInput is used for create DirectiveExample object.
Input was generated by ent.
"""
input CreateDirectiveExampleInput {
onTypeField: String
onMutationFields: String @fieldDirective
onMutationCreate: String @fieldDirective
onMutationUpdate: String
onAllFields: String @fieldDirective
}
"""
CreateTodoInput is used for create Todo object.
Input was generated by ent.
"""
Expand Down Expand Up @@ -342,6 +353,124 @@ Define a Relay Cursor type:
https://relay.dev/graphql/connections.htm#sec-Cursor
"""
scalar Cursor
type DirectiveExample implements Node {
id: ID!
onTypeField: String @fieldDirective
onMutationFields: String
onMutationCreate: String
onMutationUpdate: String
onAllFields: String @fieldDirective
}
"""
DirectiveExampleWhereInput is used for filtering DirectiveExample objects.
Input was generated by ent.
"""
input DirectiveExampleWhereInput {
not: DirectiveExampleWhereInput
and: [DirectiveExampleWhereInput!]
or: [DirectiveExampleWhereInput!]
"""
id field predicates
"""
id: ID
idNEQ: ID
idIn: [ID!]
idNotIn: [ID!]
idGT: ID
idGTE: ID
idLT: ID
idLTE: ID
"""
on_type_field field predicates
"""
onTypeField: String
onTypeFieldNEQ: String
onTypeFieldIn: [String!]
onTypeFieldNotIn: [String!]
onTypeFieldGT: String
onTypeFieldGTE: String
onTypeFieldLT: String
onTypeFieldLTE: String
onTypeFieldContains: String
onTypeFieldHasPrefix: String
onTypeFieldHasSuffix: String
onTypeFieldIsNil: Boolean
onTypeFieldNotNil: Boolean
onTypeFieldEqualFold: String
onTypeFieldContainsFold: String
"""
on_mutation_fields field predicates
"""
onMutationFields: String
onMutationFieldsNEQ: String
onMutationFieldsIn: [String!]
onMutationFieldsNotIn: [String!]
onMutationFieldsGT: String
onMutationFieldsGTE: String
onMutationFieldsLT: String
onMutationFieldsLTE: String
onMutationFieldsContains: String
onMutationFieldsHasPrefix: String
onMutationFieldsHasSuffix: String
onMutationFieldsIsNil: Boolean
onMutationFieldsNotNil: Boolean
onMutationFieldsEqualFold: String
onMutationFieldsContainsFold: String
"""
on_mutation_create field predicates
"""
onMutationCreate: String
onMutationCreateNEQ: String
onMutationCreateIn: [String!]
onMutationCreateNotIn: [String!]
onMutationCreateGT: String
onMutationCreateGTE: String
onMutationCreateLT: String
onMutationCreateLTE: String
onMutationCreateContains: String
onMutationCreateHasPrefix: String
onMutationCreateHasSuffix: String
onMutationCreateIsNil: Boolean
onMutationCreateNotNil: Boolean
onMutationCreateEqualFold: String
onMutationCreateContainsFold: String
"""
on_mutation_update field predicates
"""
onMutationUpdate: String
onMutationUpdateNEQ: String
onMutationUpdateIn: [String!]
onMutationUpdateNotIn: [String!]
onMutationUpdateGT: String
onMutationUpdateGTE: String
onMutationUpdateLT: String
onMutationUpdateLTE: String
onMutationUpdateContains: String
onMutationUpdateHasPrefix: String
onMutationUpdateHasSuffix: String
onMutationUpdateIsNil: Boolean
onMutationUpdateNotNil: Boolean
onMutationUpdateEqualFold: String
onMutationUpdateContainsFold: String
"""
on_all_fields field predicates
"""
onAllFields: String
onAllFieldsNEQ: String
onAllFieldsIn: [String!]
onAllFieldsNotIn: [String!]
onAllFieldsGT: String
onAllFieldsGTE: String
onAllFieldsLT: String
onAllFieldsLTE: String
onAllFieldsContains: String
onAllFieldsHasPrefix: String
onAllFieldsHasSuffix: String
onAllFieldsIsNil: Boolean
onAllFieldsNotNil: Boolean
onAllFieldsEqualFold: String
onAllFieldsContainsFold: String
}
type Friendship implements Node {
id: ID!
createdAt: Time!
Expand Down Expand Up @@ -836,6 +965,7 @@ type Query {
"""
where: CategoryWhereInput
): CategoryConnection!
directiveExamples: [DirectiveExample!]!
groups(
"""
Returns the elements in the list that come after the specified cursor.
Expand Down Expand Up @@ -1203,6 +1333,22 @@ input UpdateCategoryInput {
clearSubCategories: Boolean
}
"""
UpdateDirectiveExampleInput is used for update DirectiveExample object.
Input was generated by ent.
"""
input UpdateDirectiveExampleInput {
onTypeField: String
clearOnTypeField: Boolean
onMutationFields: String @fieldDirective
clearOnMutationFields: Boolean @fieldDirective
onMutationCreate: String
clearOnMutationCreate: Boolean
onMutationUpdate: String @fieldDirective
clearOnMutationUpdate: Boolean @fieldDirective
onAllFields: String @fieldDirective
clearOnAllFields: Boolean @fieldDirective
}
"""
UpdateFriendshipInput is used for update Friendship object.
Input was generated by ent.
"""
Expand Down
6 changes: 6 additions & 0 deletions entgql/internal/todo/ent.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading