Skip to content

Commit 379d8af

Browse files
authored
Merge pull request #1073 from constructive-io/fix/resolve-storage-config-codec-name
fix(presigned-url): codec table name matching + ownerId type resolution
2 parents 3491da5 + 22e5252 commit 379d8af

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

graphile/graphile-presigned-url-plugin/src/plugin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ export function createPresignedUrlPlugin(
184184
continue;
185185
}
186186

187+
// Resolve the GraphQL type for ownerId from the codec's attribute codec
188+
// (e.g. UUID scalar instead of String) so Grafast's type matching works.
189+
const ownerIdType = hasOwnerId
190+
? (build as any).getGraphQLTypeByPgCodec(codec.attributes.owner_id.codec, 'input')
191+
: null;
192+
187193
log.debug(`Adding mutation entry point "${fieldName}" for bucket type ${typeName} (entity-scoped=${hasOwnerId})`);
188194

189195
newFields[fieldName] = context.fieldWithHooks(
@@ -194,7 +200,7 @@ export function createPresignedUrlPlugin(
194200
args: {
195201
key: { type: new GraphQLNonNull(GraphQLString), description: 'Bucket key (e.g., "public", "private")' },
196202
...(hasOwnerId
197-
? { ownerId: { type: new GraphQLNonNull(GraphQLString), description: 'Owner entity ID (required for entity-scoped buckets)' } }
203+
? { ownerId: { type: new GraphQLNonNull(ownerIdType || GraphQLString), description: 'Owner entity ID (required for entity-scoped buckets)' } }
198204
: {}),
199205
},
200206
plan(_$mutation: any, fieldArgs: any) {

graphile/graphile-presigned-url-plugin/src/storage-module-cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ export async function loadAllStorageModules(
367367
* @returns The matching StorageModuleConfig or null
368368
*/
369369
export function resolveStorageConfigFromCodec(
370-
pgCodec: { name: string; extensions?: { pg?: { schemaName?: string } }; sqlType?: string },
370+
pgCodec: { name: string; extensions?: { pg?: { schemaName?: string; name?: string } }; sqlType?: string },
371371
allConfigs: StorageModuleConfig[],
372372
): StorageModuleConfig | null {
373373
const schemaName = pgCodec.extensions?.pg?.schemaName;
374-
const tableName = pgCodec.name;
374+
const tableName = pgCodec.extensions?.pg?.name ?? pgCodec.name;
375375

376376
if (!schemaName || !tableName) return null;
377377

0 commit comments

Comments
 (0)