Skip to content

Commit

Permalink
Fix GQL Coords type missing lng / update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Dec 1, 2020
1 parent 04e1988 commit db8fc01
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 3.9.0.2 - 2020-12-01
### Improved
- Improved GQL docs

### Fixed
- Fix GQL Coords type missing `lng`

## 3.9.0.1 - 2020-11-27
### Fixed
- Removed distance field from GQL mutation input
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ether/simplemap",
"description": "A beautifully simple Map field type for Craft CMS 3",
"version": "3.9.0.1",
"version": "3.9.0.2",
"type": "craft-plugin",
"license": "proprietary",
"minimum-stability": "dev",
Expand Down
31 changes: 14 additions & 17 deletions docs/how-to/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ title: Querying in GraphQL

# Querying in GraphQL

While the _CraftQL_ plugin has great support for custom arguments for field
types, Crafts current built-in implementation of GraphQL doesn't. To work
around this, we've added support for JSON strings within the query argument for
Map fields. It's not pretty, but it works.

The JSON object can support all the parameters that you can use in regular
[Searching](../getting-started/usage/#searching). You can also order by a
locations distance from the search location.
The query input can support all the parameters that you can use in regular
[Searching](../getting-started/usage/#searching), with the exception that
`location` only supports a string value. This means if you want to search by
lat/lng you need to pass them to the `coordinate` input.

```graphql
{
entries (
map:"{\"location\":\"Maidstone, Kent\", \"country\": \"UK\", \"radius\": 50}"
map: {
unit: Kilometres
location: "Maidstone, Kent"
country: "UK"
radius: 10
coordinate: {
lat: 51.27136675686769
lng: 0.4939985275268555
}
}
section: "locations"
orderBy: "distance"
) {
Expand All @@ -42,11 +47,3 @@ locations distance from the search location.
}
}
```

As you can see in the example above, the JSON string is escaped within a string
argument. Remember, you can't pass a JSON object to the argument, it has to be
stringified.

If and when Craft give plugins the ability to define their own arguments we'll
switch to using a Map specific type, until then we'll have to make do with
JSON in a string.
2 changes: 1 addition & 1 deletion src/integrations/graphql/MapType.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static function getCoordsType (): InputType
'type' => Type::nonNull(Type::float()),
],
'lng' => [
'name' => 'lat',
'name' => 'lng',
'type' => Type::nonNull(Type::float()),
],
],
Expand Down

0 comments on commit db8fc01

Please sign in to comment.