Skip to content

Commit

Permalink
entgql: check fields RType for Map and use Map scalar if possible (#455)
Browse files Browse the repository at this point in the history
* fix(entgql): check fields RType for Map and use Map scalar if possible

* feat(entgql): add tests to cover field JSON with Map scalar

* entgql: update codegen

Signed-off-by: Giau. Tran Minh <hello@giautm.dev>

---------

Signed-off-by: Giau. Tran Minh <hello@giautm.dev>
Co-authored-by: Giau. Tran Minh <hello@giautm.dev>
  • Loading branch information
tankbusta and giautm authored Mar 24, 2023
1 parent f0e9994 commit bb1039b
Show file tree
Hide file tree
Showing 38 changed files with 916 additions and 20 deletions.
4 changes: 4 additions & 0 deletions entgql/internal/todo/ent.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ input CreateUserInput {
name: String
username: UUID
password: String
metadata: Map
groupIDs: [ID!]
friendIDs: [ID!]
}
Expand Down Expand Up @@ -694,6 +695,8 @@ input UpdateUserInput {
username: UUID
password: String
clearPassword: Boolean
metadata: Map
clearMetadata: Boolean
addGroupIDs: [ID!]
removeGroupIDs: [ID!]
clearGroups: Boolean
Expand All @@ -705,6 +708,7 @@ type User implements Node {
id: ID!
name: String!
username: UUID!
metadata: Map
groups(
"""Returns the elements in the list that come after the specified cursor."""
after: Cursor
Expand Down
5 changes: 5 additions & 0 deletions entgql/internal/todo/ent/gql_collection.go

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

12 changes: 12 additions & 0 deletions entgql/internal/todo/ent/gql_mutation_input.go

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

10 changes: 9 additions & 1 deletion entgql/internal/todo/ent/gql_node_descriptor.go

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

1 change: 1 addition & 0 deletions entgql/internal/todo/ent/migrate/schema.go

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

75 changes: 74 additions & 1 deletion entgql/internal/todo/ent/mutation.go

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

2 changes: 2 additions & 0 deletions entgql/internal/todo/ent/schema/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func (User) Fields() []ent.Field {
field.String("password").
Sensitive().
Optional(),
field.JSON("metadata", map[string]interface{}{}).
Optional(),
}
}

Expand Down
16 changes: 16 additions & 0 deletions entgql/internal/todo/ent/user.go

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

3 changes: 3 additions & 0 deletions entgql/internal/todo/ent/user/user.go

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

10 changes: 10 additions & 0 deletions entgql/internal/todo/ent/user/where.go

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

10 changes: 10 additions & 0 deletions entgql/internal/todo/ent/user_create.go

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

Loading

0 comments on commit bb1039b

Please sign in to comment.