Skip to content

[Breaking] graphql: Add camelCase for add/update mutation. #5547

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

Merged
merged 25 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
17e90f6
Modified lowercase typename for add/update mutation to camelCase
JatinDev543 May 29, 2020
f9d9fe1
Added camelCase function and modified tests
JatinDev543 Jun 1, 2020
d06a664
Removed antipattern error
JatinDev543 Jun 1, 2020
5f7728e
Removed Bug risk
JatinDev543 Jun 1, 2020
9bcd19e
Modified Tests
JatinDev543 Jun 1, 2020
e9b5612
modify tests
JatinDev543 Jun 1, 2020
05e8b05
Removed dependencies
JatinDev543 Jun 1, 2020
1549cb3
Merge branch 'master' of https://github.com/dgraph-io/dgraph into Jat…
JatinDev543 Jun 1, 2020
0a55030
Modified tests for merged master
JatinDev543 Jun 1, 2020
2212348
Merge branch 'master' of https://github.com/dgraph-io/dgraph into Jat…
JatinDev543 Jun 1, 2020
46723c8
removed comments
JatinDev543 Jun 1, 2020
a918905
Changes according to Abhimanyu review
JatinDev543 Jun 2, 2020
9b7f78b
Simplified camelCase function
JatinDev543 Jun 2, 2020
f6e42de
removed antipattern error
JatinDev543 Jun 2, 2020
5d3444f
Merge branch 'master' of https://github.com/dgraph-io/dgraph into Jat…
JatinDev543 Jun 2, 2020
f05527a
Merge branch 'master' of https://github.com/dgraph-io/dgraph into Jat…
JatinDev543 Jun 3, 2020
30fddc6
removed antipattern error
JatinDev543 Jun 3, 2020
9c4f68f
removed bug risk
JatinDev543 Jun 3, 2020
2ebbad3
removed antipattern error
JatinDev543 Jun 3, 2020
7ba2a22
removed bug risk
JatinDev543 Jun 3, 2020
0a61ed7
removed anti pattern error
JatinDev543 Jun 3, 2020
8d161bc
removed bug
JatinDev543 Jun 3, 2020
9082dd3
Removed anti pattern error
JatinDev543 Jun 5, 2020
7acb882
removed anti status error
JatinDev543 Jun 5, 2020
ec7904e
Merge branch 'master' of github.com:dgraph-io/dgraph into Jatin/graph…
abhimanyusinghgaur Jun 5, 2020
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
2 changes: 1 addition & 1 deletion graphql/e2e/auth/add_mutation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func TestAddGQLOnly(t *testing.T) {
query := `
mutation addUser($user: AddUserSecretInput!) {
addUserSecret(input: [$user]) {
usersecret {
userSecret {
aSecret
}
}
Expand Down
2 changes: 1 addition & 1 deletion graphql/e2e/common/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2576,7 +2576,7 @@ func addMutationWithReverseDgraphEdge(t *testing.T) {
addMovieDirectorParams := &GraphQLParams{
Query: `mutation addMovieDirector($dir: [AddMovieDirectorInput!]!) {
addMovieDirector(input: $dir) {
moviedirector {
movieDirector {
id
name
}
Expand Down
2 changes: 1 addition & 1 deletion graphql/resolve/add_mutation_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@
gqlmutation: |
mutation addMovieDirector($dir: AddMovieDirectorInput!) {
addMovieDirector(input: [$dir]) {
moviedirector {
movieDirector {
id
}
}
Expand Down
12 changes: 6 additions & 6 deletions graphql/resolve/auth_add_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
gqlquery: |
mutation addUserSecret($secret: AddUserSecretInput!) {
addUserSecret(input: [$secret]) {
usersecret {
userSecret {
id
}
}
Expand Down Expand Up @@ -30,7 +30,7 @@
gqlquery: |
mutation addUserSecret($secrets: [AddUserSecretInput!]!) {
addUserSecret(input: $secrets) {
usersecret {
userSecret {
id
}
}
Expand Down Expand Up @@ -59,7 +59,7 @@
gqlquery: |
mutation addUserSecret($secret: AddUserSecretInput!) {
addUserSecret(input: [$secret]) {
usersecret {
userSecret {
id
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@
gqlquery: |
mutation addUserSecret($secrets: [AddUserSecretInput!]!) {
addUserSecret(input: $secrets) {
usersecret {
userSecret {
id
}
}
Expand Down Expand Up @@ -932,7 +932,7 @@
gqlquery: |
mutation addComplexLog($log: AddComplexLogInput!) {
addComplexLog(input: [$log]) {
complexlog {
complexLog {
id
}
}
Expand All @@ -953,7 +953,7 @@
gqlquery: |
mutation addComplexLog($log: AddComplexLogInput!) {
addComplexLog(input: [$log]) {
complexlog {
complexLog {
id
}
}
Expand Down
6 changes: 3 additions & 3 deletions graphql/resolve/auth_update_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
gqlquery: |
mutation updateUserSecret($upd: UpdateUserSecretInput!) {
updateUserSecret(input: $upd) {
usersecret {
userSecret {
id
}
}
Expand Down Expand Up @@ -600,7 +600,7 @@
gqlquery: |
mutation updateComplexLog($log: UpdateComplexLogInput!) {
updateComplexLog(input: $log) {
complexlog {
complexLog {
id
}
}
Expand All @@ -626,7 +626,7 @@
gqlquery: |
mutation updateComplexLog($log: UpdateComplexLogInput!) {
updateComplexLog(input: $log) {
complexlog {
complexLog {
id
}
}
Expand Down
6 changes: 3 additions & 3 deletions graphql/resolve/update_mutation_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@
gqlmutation: |
mutation updateMovieDirector($patch: UpdateMovieDirectorInput!) {
updateMovieDirector(input: $patch) {
moviedirector {
movieDirector {
id
}
}
Expand Down Expand Up @@ -912,7 +912,7 @@
gqlmutation: |
mutation updateMovieDirector($patch: UpdateMovieDirectorInput!) {
updateMovieDirector(input: $patch) {
moviedirector {
movieDirector {
id
}
}
Expand Down Expand Up @@ -1375,7 +1375,7 @@
gqlmutation: |
mutation updateComputerOwner($patch: UpdateComputerOwnerInput!) {
updateComputerOwner(input: $patch) {
computerowner {
computerOwner {
name
}
}
Expand Down
12 changes: 10 additions & 2 deletions graphql/schema/gqlschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ func addTypeOrderable(schema *ast.Schema, defn *ast.Definition) {

func addAddPayloadType(schema *ast.Schema, defn *ast.Definition) {
qry := &ast.FieldDefinition{
Name: strings.ToLower(defn.Name),
Name: camelCase(defn.Name),
Type: ast.ListType(&ast.Type{
NamedType: defn.Name,
}, nil),
Expand Down Expand Up @@ -1001,7 +1001,7 @@ func addUpdatePayloadType(schema *ast.Schema, defn *ast.Definition) {
}

qry := &ast.FieldDefinition{
Name: strings.ToLower(defn.Name),
Name: camelCase(defn.Name),
Type: &ast.Type{
Elem: &ast.Type{
NamedType: defn.Name,
Expand Down Expand Up @@ -1640,3 +1640,11 @@ func isGraphqlSpecScalar(typ string) bool {
_, ok := graphqlSpecScalars[typ]
return ok
}

func camelCase(x string) string {
if x == "" {
return ""
}

return strings.ToLower(x[:1]) + x[1:]
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type AddDirectorPayload {
}

type AddOscarMoviePayload {
oscarmovie(filter: OscarMovieFilter, order: OscarMovieOrder, first: Int, offset: Int): [OscarMovie]
oscarMovie(filter: OscarMovieFilter, order: OscarMovieOrder, first: Int, offset: Int): [OscarMovie]
numUids: Int
}

Expand Down Expand Up @@ -178,7 +178,7 @@ type UpdateMoviePayload {
}

type UpdateOscarMoviePayload {
oscarmovie(filter: OscarMovieFilter, order: OscarMovieOrder, first: Int, offset: Int): [OscarMovie]
oscarMovie(filter: OscarMovieFilter, order: OscarMovieOrder, first: Int, offset: Int): [OscarMovie]
numUids: Int
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type AddDirectorPayload {
}

type AddOscarMoviePayload {
oscarmovie(filter: OscarMovieFilter, order: OscarMovieOrder, first: Int, offset: Int): [OscarMovie]
oscarMovie(filter: OscarMovieFilter, order: OscarMovieOrder, first: Int, offset: Int): [OscarMovie]
numUids: Int
}

Expand Down Expand Up @@ -178,7 +178,7 @@ type UpdateMoviePayload {
}

type UpdateOscarMoviePayload {
oscarmovie(filter: OscarMovieFilter, order: OscarMovieOrder, first: Int, offset: Int): [OscarMovie]
oscarMovie(filter: OscarMovieFilter, order: OscarMovieOrder, first: Int, offset: Int): [OscarMovie]
numUids: Int
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ input StringHashFilter {
#######################

type AddMovieDirectorPayload {
moviedirector(filter: MovieDirectorFilter, order: MovieDirectorOrder, first: Int, offset: Int): [MovieDirector]
movieDirector(filter: MovieDirectorFilter, order: MovieDirectorOrder, first: Int, offset: Int): [MovieDirector]
numUids: Int
}

Expand All @@ -156,7 +156,7 @@ type DeleteMoviePayload {
}

type UpdateMovieDirectorPayload {
moviedirector(filter: MovieDirectorFilter, order: MovieDirectorOrder, first: Int, offset: Int): [MovieDirector]
movieDirector(filter: MovieDirectorFilter, order: MovieDirectorOrder, first: Int, offset: Int): [MovieDirector]
numUids: Int
}

Expand Down