Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Initial spatial support using Point type #334

Merged
merged 6 commits into from
Oct 31, 2019
Merged

Initial spatial support using Point type #334

merged 6 commits into from
Oct 31, 2019

Conversation

michaeldgraham
Copy link
Collaborator

This PR contains initial support for Neo4j spatial properties.

Schema Augmentation

Point types are now translated using updated transformations in the schema augmentation process, similar to the current behavior of the Neo4j temporal types (Time, Date, DateTime, etc.). Output type Point fields are transformed to _Neo4jPoint and input type Point fields are transformed to _Neo4jPointInput.

To support this, the following type definitions are now generated in the schema augmentation process:

  type _Neo4jPoint {
    x: Int
    y: Int
    z: Int
    longitude: Int
    latitude: Int
    height: Int
    crs: String
    srid: Int
  }

  input _Neo4jPointInput {
    x: Int
    y: Int
    z: Int
    longitude: Int
    latitude: Int
    height: Int
    crs: String
    srid: Int
  }
Configuration

Similar to the temporal configuration for the augmentation process, generated spatial type support can be disabled by configuring:

config: {
  spatial: false
}

For more information about spatial values and their constructor functions in Cypher, see:
https://neo4j.com/docs/cypher-manual/current/syntax/spatial/#cypher-spatial-instants

Tests

The following tests have been added:

Node

Read

Query node with spatial properties using spatial arguments
Nested Query with spatial property arguments

Write

Create node with spatial properties
Delete node using spatial property node selection
Update node spatial property using spatial property node selection

Relationship

Read

Query relationship with spatial properties

Write

Add relationship mutation using spatial property node selection
Add relationship mutation with spatial properties
Remove relationship mutation using spatial property node selection

Computed

Handle @cypher query with spatial payload
Handle @cypher mutation with spatial payload

Configuration

Config - spatial - disable spatial schema augmentation

Copy link
Contributor

@johnymontana johnymontana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this is looking good @michaeldgraham , but could you please add a little more test coverage? Specifically, I'd like to see tests that use the latitude/longitude fields (in addition to the use of the x,y,z fields) and a couple of integration tests that demonstrate creating/querying a Point type in the database. Thanks!

@codecov-io
Copy link

codecov-io commented Oct 28, 2019

Codecov Report

Merging #334 into master will increase coverage by 0.19%.
The diff coverage is 99.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #334      +/-   ##
==========================================
+ Coverage   96.27%   96.46%   +0.19%     
==========================================
  Files          23       24       +1     
  Lines        2576     2606      +30     
==========================================
+ Hits         2480     2514      +34     
+ Misses         96       92       -4
Impacted Files Coverage Δ
src/index.js 72.3% <ø> (ø) ⬆️
src/augment/fields.js 100% <100%> (ø) ⬆️
src/augment/types/spatial.js 100% <100%> (ø)
src/augment/types/temporal.js 100% <100%> (+6.89%) ⬆️
src/selections.js 98.73% <100%> (ø) ⬆️
src/augment/types/types.js 100% <100%> (ø) ⬆️
src/translate.js 98.64% <100%> (-0.01%) ⬇️
src/utils.js 94.7% <97.14%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed82d31...c5e9515. Read the comment docs.

@jonasdumas
Copy link

Great PR! We were waiting this geospatial support for our project. We're looking forward to see this published in next version!
Thank you for both of you for your great work @michaeldgraham @johnymontana

Includes refactoring that unifies some logic used by both temporal and spatial types
@johnymontana johnymontana merged commit 42f6ca3 into neo4j-graphql:master Oct 31, 2019
@johnymontana
Copy link
Contributor

🎉 🌐

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants