File tree Expand file tree Collapse file tree
graphile/graphile-postgis/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import 'graphile-build' ;
2+ import 'graphile-build-pg' ;
23import 'graphile-connection-filter' ;
4+ import type { PgCodec } from '@dataplan/pg' ;
35import type {
46 ConnectionFilterOperatorFactory ,
57 ConnectionFilterOperatorRegistration ,
@@ -225,7 +227,10 @@ export function createPostgisOperatorFactory(): ConnectionFilterOperatorFactory
225227 geography : [ ]
226228 } ;
227229
228- const codecPairs : [ string , typeof geometryCodec ] [ ] = [ [ 'geometry' , geometryCodec ] ] ;
230+ const codecPairs : [ string , PgCodec ] [ ] = [ ] ;
231+ if ( geometryCodec ) {
232+ codecPairs . push ( [ 'geometry' , geometryCodec ] ) ;
233+ }
229234 if ( geographyCodec ) {
230235 codecPairs . push ( [ 'geography' , geographyCodec ] ) ;
231236 }
Original file line number Diff line number Diff line change @@ -43,13 +43,17 @@ export const PostgisExtensionDetectionPlugin: GraphileConfig.Plugin = {
4343 schemaName = pg . schemaName || 'public' ;
4444 } else if ( pg . name === 'geography' ) {
4545 geographyCodec = codec ;
46+ if ( ! geometryCodec ) {
47+ schemaName = pg . schemaName || 'public' ;
48+ }
4649 }
4750 }
4851
49- // PostGIS requires at least the geometry codec to be present.
50- // Geography is optional — not all databases use geography columns,
51- // so PostGraphile may not introspect the geography type at all.
52- if ( ! geometryCodec ) {
52+ // PostGIS is detected when at least one of geometry or geography
53+ // codecs is present. Some databases use only geography columns
54+ // (e.g. use_geography: true in DataPostGIS), so PostGraphile may
55+ // introspect geography but not geometry.
56+ if ( ! geometryCodec && ! geographyCodec ) {
5357 return build ;
5458 }
5559
Original file line number Diff line number Diff line change 11import 'graphile-build' ;
2+ import 'graphile-build-pg' ;
23import 'graphile-connection-filter' ;
4+ import type { PgCodec } from '@dataplan/pg' ;
35import type {
46 ConnectionFilterOperatorFactory ,
57 ConnectionFilterOperatorRegistration ,
@@ -57,7 +59,10 @@ export function createWithinDistanceOperatorFactory(): ConnectionFilterOperatorF
5759 geography : [ ]
5860 } ;
5961
60- const codecPairs : [ string , typeof geometryCodec ] [ ] = [ [ 'geometry' , geometryCodec ] ] ;
62+ const codecPairs : [ string , PgCodec ] [ ] = [ ] ;
63+ if ( geometryCodec ) {
64+ codecPairs . push ( [ 'geometry' , geometryCodec ] ) ;
65+ }
6166 if ( geographyCodec ) {
6267 codecPairs . push ( [ 'geography' , geographyCodec ] ) ;
6368 }
Original file line number Diff line number Diff line change @@ -23,9 +23,9 @@ export interface GisFieldValue {
2323export interface PostgisExtensionInfo {
2424 /** The schema name where PostGIS is installed (e.g. 'public') */
2525 schemaName : string ;
26- /** The geometry codec from the registry */
27- geometryCodec : PgCodec ;
28- /** The geography codec from the registry (optional — not all databases use geography columns ) */
26+ /** The geometry codec from the registry (null if only geography columns are used) */
27+ geometryCodec : PgCodec | null ;
28+ /** The geography codec from the registry (null if only geometry columns are used ) */
2929 geographyCodec : PgCodec | null ;
3030}
3131
You can’t perform that action at this time.
0 commit comments