completePoint takes in coordinates from dgraph response like [12.32, 123.32], and builds a JSON GraphQL result object for Point like { "longitude" : 12.32 , "latitude" : 123.32 }.
(field gqlSchema.Field, coordinate []interface{}, buf *bytes.Buffer)
| 1234 | // completePoint takes in coordinates from dgraph response like [12.32, 123.32], and builds |
| 1235 | // a JSON GraphQL result object for Point like { "longitude" : 12.32 , "latitude" : 123.32 }. |
| 1236 | func completePoint(field gqlSchema.Field, coordinate []interface{}, buf *bytes.Buffer) { |
| 1237 | comma := "" |
| 1238 | |
| 1239 | x.Check2(buf.WriteRune('{')) |
| 1240 | for _, f := range field.SelectionSet() { |
| 1241 | if f.Skip() || !f.Include() { |
| 1242 | continue |
| 1243 | } |
| 1244 | |
| 1245 | x.Check2(buf.WriteString(comma)) |
| 1246 | f.CompleteAlias(buf) |
| 1247 | |
| 1248 | switch f.Name() { |
| 1249 | case gqlSchema.Longitude: |
| 1250 | x.Check2(buf.WriteString(fmt.Sprintf("%v", coordinate[0]))) |
| 1251 | case gqlSchema.Latitude: |
| 1252 | x.Check2(buf.WriteString(fmt.Sprintf("%v", coordinate[1]))) |
| 1253 | case gqlSchema.Typename: |
| 1254 | x.Check2(buf.WriteString(`"Point"`)) |
| 1255 | } |
| 1256 | comma = "," |
| 1257 | } |
| 1258 | x.Check2(buf.WriteRune('}')) |
| 1259 | } |
| 1260 | |
| 1261 | // completePolygon converts the Dgraph result to GraphQL Polygon type. |
| 1262 | // Dgraph output: coordinate: [[[22.22,11.11],[16.16,15.15],[21.21,20.2]],[[22.28,11.18],[16.18,15.18],[21.28,20.28]]] |
no test coverage detected