cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Updating spatial coords in custom resolvers with neo4j/graphql-ogm

nelson
Node Link

Hi everyone!
I come to you because I have a problem with a custom resolver.
In my project I use neo4j / graphql-ogm and the resolver is supposed to create a Resto node (restaurant) from the data provided by an admin. The admin being itself a node, there is an "OWNED_BY" relationship between the admin and the restaurant.
among the data provided (name, password ...) there is also the address in character string and the coordinates (latitude, longitute). the Resto type has a Location property (Point type).
In my resolver I use the connectOrCreate function to create the restaurant but the coordinates are rejected.
If anyone can enlighten me on this that would be great.

export async function createResto(_source: any, { adminId, name, password, brand, adress, lat, long }: any): Promise<any | undefined> {
    try {
        console.log(`latitude: ${lat} et longitude: ${long}`);
     // latitude: 14.78426 et longitude: -60.99555
        const hp = await hash(password, 12);
            const rp = await Admin.update({connectOrCreate: {
                restos: {
                    where: { node: {name}},
                    onCreate: {node: {
                        name,
                        password: hp,
                        brand,
                        adress,
                        location: {
                            latitude: lat,
                             longitude: long
                        }
                    }}
                }
            },
                where:{id: adminId}})
            if  (!rp) {
                throw new Error('une erreur s\'est produite');
            }
            console.log(rp);
        return true;
    } catch (err: any) {
        return err;
    }
}

In the client side, the console show this:
Property values can only be of primitive types or arrays thereof. Encountered: Map{longitude -> Double(-6.099555e+01), latitude -> Double(1.478426e+01)}.

Why is 14.78426 transformed into Double (1.478426e + 01) and -60.99555 transformed into Double (-6.099555e + 01)?

1 REPLY 1

William_Lyon
Graph Fellow

Can you share the generated Cypher statement? It looks like trying to set a map/dictionary/object as the property value instead of just the decimal lat/lon values.