enonic / lib-graphql

GraphQL lib for Enonic XP
Apache License 2.0
2 stars 0 forks source link

Type for GeoPoint #95

Closed ComLock closed 3 years ago

ComLock commented 3 years ago

It would be nice to have a type for GeoPoint

sigdestad commented 3 years ago

I think this is too specific for this library, you should rather add custom scalars to your own implementations.

ComLock commented 3 years ago

ASFAIK there is no JS API for custom scalars available?

ComLock commented 3 years ago

Like they are doing here: https://stackoverflow.com/questions/49897319/graphql-union-scalar-type new GraphQLScalarType

Personally I was thinking of an object with lat and long, not a string...

ComLock commented 3 years ago

But I guess object is just possible as input, not output https://developer.enonic.com/docs/xp/stable/api/lib-value#geopoint

sigdestad commented 3 years ago

Ask @anatol-sialitski how this was done for Guillotine perhaps?

anatol-sialitski commented 3 years ago

In Guillotine we use object for both object output type and for object input type.

But GeoPoint output object type has three fields:

I fully agree with @sigdestad's comment https://github.com/enonic/lib-graphql/issues/95#issuecomment-892587323

ComLock commented 3 years ago

@anatol-sialitski Yes, but how do I make custom scalar?

anatol-sialitski commented 3 years ago

@ComLock Please have a look at these files:

The same you can do in your application/lib

ComLock commented 3 years ago

@anatol-sialitski Nice, but sure would be nice with JS API for creating custom scalars... Perhaps I should make a new issue for that and close this one?

anatol-sialitski commented 3 years ago

Anyway you have to implement COERCING on Java. I do not see simple solution to create a scalar by a user using lib-graphql now.

In order to do not block your development you can use examples from my previous reply.