Graphql API to deals with GIS objects. Code functions:
- Create Partner
- List all partners
- Get partner by ID
- Search partners by location (which the coverage area includes the location)
- Delete partner
- Node
- Typescript
- Graphql
- MongoDB
- Jest
- Docker
yarn
OR npm install
docker-compose up
yarn test
JSON example:
{
"getPartnerById": {
"_id": "60bbbe68ff671a038d4ba20a",
"tradingName": "CD Marilia",
"ownerName": "Toninho da Silva",
"document": "83639240000168",
"coverageArea": {
"coordinates": [
[
[
-22.199537,
-49.976083
],
[
-22.221122,
-49.972595
],
[
-22.216581,
-49.93396
],
[
-22.189877,
-49.945984
],
[
-22.199537,
-49.976083
]
]
],
"type": "Polygon"
},
"address": {
"type": "Point",
"coordinates": [
-22.199656,
-49.95326
]
}
}
}
- The
coverageArea
field follows the GeoJSON Polygon format - The
address
field follows the GeoJSON Point format - The
document
must be a unique field
Mutation:
mutation {
createPartner(partner: {
tradingName: "CD Marilia 2",
ownerName: "Toninho da Silva",
document: "93639240000168",
coverageArea: {
type: "Polygon",
coordinates: [
[
[-22.199537, -49.976083],[-22.221122, -49.972595], [-22.216581, -49.933960], [-22.189877, -49.945984], [-22.199537, -49.976083]
]
]
},
address: {
type: "Point",
coordinates: [-22.207205, -49.958582]
}
}) {
_id
tradingName
document
coverageArea
address
}
}
query getById {
getPartnerById(_id: "60bbbe68ff671a038d4ba20a") {
_id
tradingName
ownerName
document
coverageArea
address
}
}
query searchPartnerByLocation {
searchPartner(lat: -22.200738, long: -49.955690) {
_id
tradingName
address
}
}
mutation deletePartner {
deletePartner(_id: "60bbe42526d984002d46396f")
}