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(GraphQL): Add support for Geo point type in Graphql. #6481

Merged
merged 25 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
72df5bc
Add support for Geo point type in Graphql.
arijitAD Sep 17, 2020
b2ab70c
Query filter.
arijitAD Sep 23, 2020
8b19ad4
Temp
arijitAD Sep 25, 2020
c7abe00
Add and fix unit test.
arijitAD Sep 25, 2020
c34192e
Merge remote-tracking branch 'origin/master' into arijitAD/geo-point-…
arijitAD Sep 25, 2020
ccc3ddd
Fix test.
arijitAD Sep 25, 2020
3f6346f
Minor nit.
arijitAD Sep 25, 2020
b61c96b
Fix bugs and add E2E test.
arijitAD Sep 28, 2020
290ea93
Fix unit test.
arijitAD Sep 28, 2020
f5d4548
Fix schema E2E test.
arijitAD Sep 28, 2020
5cf4761
Fix GQL directives E2E tests.
arijitAD Sep 28, 2020
8192fa8
Fix deepsource errors.
arijitAD Sep 28, 2020
ca32d2e
Fix test and address comments.
arijitAD Sep 29, 2020
a94b4dd
Merge remote-tracking branch 'origin/master' into arijitAD/geo-point-…
arijitAD Sep 29, 2020
4d711a9
Fix E2E test.
arijitAD Sep 29, 2020
b5f9ee1
Fix test failures after merge.
arijitAD Sep 29, 2020
ed4d9bf
Merge remote-tracking branch 'origin/master' into arijitAD/geo-point-…
arijitAD Sep 30, 2020
7a2307e
Resolve merge conflict.
arijitAD Sep 30, 2020
fa30a59
Address comments.
arijitAD Sep 30, 2020
5a649ec
Address comments.
arijitAD Oct 1, 2020
f2782b7
Merge remote-tracking branch 'origin/master' into arijitAD/geo-point-…
arijitAD Oct 1, 2020
cfeff0f
Update the schema response for e2e tests
pawanrawal Oct 1, 2020
b65fcd4
Add E2E test for near filter.
arijitAD Oct 5, 2020
9fe33a8
Merge remote-tracking branch 'origin/master' into arijitAD/geo-point-…
arijitAD Oct 7, 2020
ba94862
Fix E2E test after merging.
arijitAD Oct 7, 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
3 changes: 3 additions & 0 deletions graphql/dgraph/graphquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ func writeFilterFunction(b *strings.Builder, f *gql.Function) {
x.Check2(b.WriteString(fmt.Sprintf("%s(%s)", f.Name, f.Args[0].Value)))
case len(f.Args) == 2:
x.Check2(b.WriteString(fmt.Sprintf("%s(%s, %s)", f.Name, f.Args[0].Value, f.Args[1].Value)))
case len(f.Args) == 3:
x.Check2(b.WriteString(fmt.Sprintf("%s(%s, %s, %s)", f.Name, f.Args[0].Value, f.Args[1].Value,
f.Args[2].Value)))
}
}

Expand Down
1 change: 1 addition & 0 deletions graphql/e2e/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ func RunAll(t *testing.T) {
t.Run("update mutation without set & remove", updateMutationWithoutSetRemove)
t.Run("Input coercing for int64 type", int64BoundaryTesting)
t.Run("Check cascade with mutation without ID field", checkCascadeWithMutationWithoutIDField)
t.Run("Geo type", mutationGeoType)

// error tests
t.Run("graphql completion on", graphQLCompletionOn)
Expand Down
43 changes: 43 additions & 0 deletions graphql/e2e/common/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3746,3 +3746,46 @@ func nestedAddMutationWithHasInverse(t *testing.T) {
// cleanup
deleteGqlType(t, "Person1", map[string]interface{}{}, 3, nil)
}

func mutationGeoType(t *testing.T) {
addHotelParams := &GraphQLParams{
Query: `
mutation addHotel($hotel: AddHotelInput!) {
addHotel(input: [$hotel]) {
hotel {
name
location {
latitude
longitude
}
}
}
}`,
Variables: map[string]interface{}{"hotel": map[string]interface{}{
"name": "Taj Hotel",
"location": map[string]interface{}{
"latitude": 11.11,
"longitude": 22.22,
},
}},
}
gqlResponse := addHotelParams.ExecuteAsPost(t, GraphqlURL)
RequireNoGQLErrors(t, gqlResponse)

addHotelExpected := `
{
"addHotel": {
"hotel": [{
"name": "Taj Hotel",
"location": {
"latitude": 11.11,
"longitude": 22.22
}
}]
}
}`
testutil.CompareJSON(t, addHotelExpected, string(gqlResponse.Data))

// Cleanup
deleteGqlType(t, "Hotel", map[string]interface{}{}, 1, nil)
}
6 changes: 6 additions & 0 deletions graphql/e2e/directives/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# **Don't delete** Comments at top of schemas should work
# See: https://github.com/dgraph-io/dgraph/issues/4227

type Hotel {
id: ID!
name: String! @search(by: [exact])
location: Point @search
}

type Country {
# **Don't delete** Comments in types should work
id: ID! # **Don't delete** Comments in lines should work
Expand Down
Loading