BowlingX/ra-postgraphile

geometry (geojson) fields are missing from queries and mutations

Closed this issue · 3 comments

I've been working geometry fields using the postgis extension

It seems that these special fields are missing from queries/mutations, for example this was a generated mutation, which is missing location

mutation createLocation($input: CreateLocationInput!) {
  createLocation(input: $input) {
    location {
      id
      name
      locationType
      __typename
    }
    __typename
  }
}

Ideally, it would also have in this case, a location field that happens to be a postgis type:

      location {
        geojson
      }

or all together:

mutation createLocation($input: CreateLocationInput!) {
  createLocation(input: $input) {
    location {
      id
      name
      location {
        geojson
      }
      locationType
      __typename
    }
    __typename
  }
}

From my experience, all geometry fields are different, depending on the type. However, they all have the field geojson

Screen Shot 2021-05-01 at 9 56 39 PM

GeometryPoint

Screen Shot 2021-05-01 at 9 57 06 PM

GeometryPolygon

Screen Shot 2021-05-01 at 9 57 24 PM

GeometryGeometryCollection

Screen Shot 2021-05-01 at 10 00 38 PM

The geojson will return all information that is in the other properties also, those are essentially shortcuts, since the interface to geojson is slightly different - but it is based on the standard and contains all the information.

solution suggestion

Perhaps this isn't a bug and I'm missing something? Please correct me if I'm wrong.

I believe that a good fix is to just add geojson field, to keep it simple and working for all geometry types.

      someFieldThatIsPosgisType {
        geojson
      }

Hi :),

This can be solved with https://github.com/BowlingX/ra-postgraphile#typeconfig-options, see here for the buildins: https://github.com/BowlingX/ra-postgraphile/blob/master/src/defaultTypeConfig.ts. I explicitly did no add all of the possible types, because configuration might vary across the schemas.

You can pass additional configuration of types you want to expand in the config argument of the data provider.

Thanks! I think this would be a great example to have for the community, so I've put together a repo that is fully self contained. Would you mind helping me get the correct syntax? It's a bit hard to know exactly how to leverage these options.

If you can help, I will provide examples for locations and intervals, and also continue to add examples for folks that are learning this framework.

The interval is probably a simpler one here with my current attempt, in hopes you can help :)

I think this can be closed as it's related to #63