Skip to content

Commit 2fc6edb

Browse files
committed
review and fixed issues
1 parent 34fc88c commit 2fc6edb

30 files changed

Lines changed: 298 additions & 205 deletions

File tree

graphile/graphile-cache/src/graphile-cache.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ const disposeEntry = async (entry: GraphileCacheEntry, key: string): Promise<voi
125125
}
126126
} catch (err) {
127127
log.error(`Error disposing PostGraphile[${key}]:`, err);
128+
} finally {
129+
disposedKeys.delete(key);
128130
}
129131
};
130132

graphile/graphile-misc-plugins/package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@
3030
},
3131
"dependencies": {
3232
"@graphile-contrib/pg-many-to-many": "2.0.0-rc.1",
33-
"grafast": "1.0.0-rc.7",
34-
"graphile-build": "5.0.0-rc.4",
35-
"graphile-build-pg": "5.0.0-rc.5",
36-
"graphile-config": "1.0.0-rc.5",
3733
"graphile-utils": "^5.0.0-rc.5",
38-
"graphql": "^16.9.0",
3934
"inflekt": "^0.3.0",
40-
"pg-query-context": "workspace:^",
41-
"pg-sql2": "5.0.0-rc.4"
35+
"pg": "^8.17.1",
36+
"pg-query-context": "workspace:^"
37+
},
38+
"peerDependencies": {
39+
"grafast": "^1.0.0-rc.7",
40+
"graphile-build": "^5.0.0-rc.4",
41+
"graphile-build-pg": "^5.0.0-rc.5",
42+
"graphile-config": "^1.0.0-rc.5",
43+
"graphql": "^16.9.0",
44+
"pg-sql2": "^5.0.0-rc.4"
4245
},
4346
"devDependencies": {
4447
"@types/node": "^22.19.1",

graphile/graphile-misc-plugins/src/PublicKeySignature.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { context as grafastContext, lambda, object } from 'grafast';
44
import type { GraphileConfig } from 'graphile-config';
55
import { extendSchema, gql } from 'graphile-utils';
6+
import { escapeIdentifier } from 'pg';
67
import pgQueryWithContext from 'pg-query-context';
78

89
export interface PublicKeyChallengeConfig {
@@ -115,7 +116,7 @@ export const PublicKeySignature = (pubkey_challenge: PublicKeyChallengeConfig):
115116
await pgQueryWithContext({
116117
client: pgClient,
117118
context: { role: 'anonymous' },
118-
query: `SELECT * FROM "${schema}"."${sign_up_with_key}"($1)`,
119+
query: `SELECT * FROM ${escapeIdentifier(schema)}.${escapeIdentifier(sign_up_with_key)}($1)`,
119120
variables: [input.publicKey],
120121
skipTransaction: true
121122
});
@@ -125,7 +126,7 @@ export const PublicKeySignature = (pubkey_challenge: PublicKeyChallengeConfig):
125126
} = await pgQueryWithContext({
126127
client: pgClient,
127128
context: { role: 'anonymous' },
128-
query: `SELECT * FROM "${schema}"."${sign_in_request_challenge}"($1)`,
129+
query: `SELECT * FROM ${escapeIdentifier(schema)}.${escapeIdentifier(sign_in_request_challenge)}($1)`,
129130
variables: [input.publicKey],
130131
skipTransaction: true
131132
});
@@ -156,9 +157,8 @@ export const PublicKeySignature = (pubkey_challenge: PublicKeyChallengeConfig):
156157
} = await pgQueryWithContext({
157158
client: pgClient,
158159
context: { role: 'anonymous' },
159-
query: `SELECT * FROM "${schema}"."${sign_in_request_challenge}"($1)`,
160-
variables: [input.publicKey],
161-
skipTransaction: true
160+
query: `SELECT * FROM ${escapeIdentifier(schema)}.${escapeIdentifier(sign_in_request_challenge)}($1)`,
161+
variables: [input.publicKey]
162162
});
163163

164164
if (!message) throw new Error('NO_ACCOUNT_EXISTS');
@@ -203,7 +203,7 @@ export const PublicKeySignature = (pubkey_challenge: PublicKeyChallengeConfig):
203203
} = await pgQueryWithContext({
204204
client: pgClient,
205205
context: { role: 'anonymous' },
206-
query: `SELECT * FROM "${schema}"."${sign_in_with_challenge}"($1, $2)`,
206+
query: `SELECT * FROM ${escapeIdentifier(schema)}.${escapeIdentifier(sign_in_with_challenge)}($1, $2)`,
207207
variables: [publicKey, message],
208208
skipTransaction: true
209209
});

graphile/graphile-plugin-connection-filter-postgis/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@
2525
"build": "makage build",
2626
"build:dev": "makage build --dev",
2727
"lint": "eslint . --fix",
28-
"test": "jest --passWithNoTests",
28+
"test": "jest",
2929
"test:watch": "jest --watch"
3030
},
31-
"dependencies": {
32-
"graphile-build": "5.0.0-rc.4",
33-
"graphile-config": "1.0.0-rc.5",
34-
"pg-sql2": "5.0.0-rc.4"
35-
},
31+
"dependencies": {},
3632
"peerDependencies": {
33+
"graphile-build": "^5.0.0-rc.4",
34+
"graphile-config": "^1.0.0-rc.5",
3735
"graphql": "^16.9.0",
36+
"pg-sql2": "^5.0.0-rc.4",
3837
"postgraphile": "^5.0.0-rc.4",
3938
"postgraphile-plugin-connection-filter": "^3.0.0-rc.1",
4039
"graphile-postgis": "^2.0.0"

graphile/graphile-postgis/__tests__/codec.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,17 @@ describe('PostgisCodecPlugin', () => {
206206
expect(result).toBe(JSON.stringify(geojson));
207207
});
208208

209-
it('should JSON.stringify GisFieldValue objects', () => {
209+
it('should extract __geojson from GisFieldValue objects', () => {
210210
const value: GisFieldValue = {
211211
__gisType: 'Point',
212212
__srid: 4326,
213213
__geojson: { type: 'Point', coordinates: [1, 2] }
214214
};
215215
const result = toPg(value);
216-
expect(JSON.parse(result).__gisType).toBe('Point');
216+
const parsed = JSON.parse(result);
217+
expect(parsed.type).toBe('Point');
218+
expect(parsed.coordinates).toEqual([1, 2]);
219+
expect(parsed.__gisType).toBeUndefined();
217220
});
218221
});
219222

graphile/graphile-postgis/__tests__/detect-extension.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ describe('PostgisExtensionDetectionPlugin', () => {
8585
expect(result.pgGISExtensionInfo.geometryCodec).toBe(geometryCodec);
8686
expect(result.pgGISExtensionInfo.geographyCodec).toBe(geographyCodec);
8787
expect(result.pgGISGraphQLTypesByCodecAndSubtype).toEqual({});
88-
expect(result.pgGISGraphQLInterfaceTypesByCodec).toEqual({});
89-
expect(result.pgGISIncludedTypes).toEqual([]);
9088
});
9189

9290
it('should detect custom schema for PostGIS installation', () => {

graphile/graphile-postgis/package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"build": "makage build",
1515
"build:dev": "makage build --dev",
1616
"lint": "eslint . --fix",
17-
"test": "jest --passWithNoTests",
17+
"test": "jest",
1818
"test:watch": "jest --watch"
1919
},
2020
"publishConfig": {
@@ -40,16 +40,15 @@
4040
"bugs": {
4141
"url": "https://github.com/constructive-io/constructive/issues"
4242
},
43-
"dependencies": {
44-
"@dataplan/pg": "1.0.0-rc.5",
45-
"grafast": "1.0.0-rc.7",
46-
"graphile-build": "5.0.0-rc.4",
47-
"graphile-build-pg": "5.0.0-rc.5",
48-
"graphile-config": "1.0.0-rc.5",
49-
"pg-sql2": "5.0.0-rc.4"
50-
},
43+
"dependencies": {},
5144
"peerDependencies": {
45+
"@dataplan/pg": "^1.0.0-rc.5",
46+
"grafast": "^1.0.0-rc.7",
47+
"graphile-build": "^5.0.0-rc.4",
48+
"graphile-build-pg": "^5.0.0-rc.5",
49+
"graphile-config": "^1.0.0-rc.5",
5250
"graphql": "^16.9.0",
51+
"pg-sql2": "^5.0.0-rc.4",
5352
"postgraphile": "^5.0.0-rc.4"
5453
},
5554
"devDependencies": {

graphile/graphile-postgis/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ export { GisSubtype, SUBTYPE_STRING_BY_SUBTYPE, GIS_SUBTYPE_NAME, CONCRETE_SUBTY
2828
export { getGISTypeDetails, getGISTypeModifier, getGISTypeName } from './utils';
2929

3030
// Types
31-
export type { GisTypeDetails, GisFieldValue, PostgisCodecInfo } from './types';
31+
export type { GisTypeDetails, GisFieldValue } from './types';
3232
export type { PostgisExtensionInfo } from './plugins/detect-extension';

graphile/graphile-postgis/src/plugins/codec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,14 @@ function buildGisCodec(
146146
* PostgreSQL can process via ST_GeomFromGeoJSON.
147147
*/
148148
toPg(value: GisFieldValue): string {
149+
if (value && typeof value === 'object' && '__geojson' in value) {
150+
return JSON.stringify(value.__geojson);
151+
}
149152
return JSON.stringify(value);
150153
},
151154

152155
attributes: undefined,
153-
executor: null,
156+
executor: undefined,
154157
extensions: {
155158
oid: typeOid,
156159
pg: {

graphile/graphile-postgis/src/plugins/detect-extension.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ export const PostgisExtensionDetectionPlugin: GraphileConfig.Plugin = {
6161

6262
return build.extend(build, {
6363
pgGISExtensionInfo: postgisInfo,
64-
pgGISGraphQLTypesByCodecAndSubtype: {} as Record<string, Record<string | number, string>>,
65-
pgGISGraphQLInterfaceTypesByCodec: {},
66-
pgGISIncludedTypes: []
64+
pgGISGraphQLTypesByCodecAndSubtype: {} as Record<string, Record<string | number, string>>
6765
}, 'PostgisExtensionDetectionPlugin adding PostGIS build state');
6866
}
6967
}

0 commit comments

Comments
 (0)