You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Team, was wondering if it was possible to create a custom directive eg: @Prefix('String').. that would add that prefix to the uuids generated in dynamodb.
Using this directive will simply update the uuid and add a prefix on the autogenerated one.
9fbbfda1-bc51-4cf7-ba45-8a8042a40462 -> usr_9fbbfda1-bc51-4cf7-ba45-8a8042a40462
Expansion on idea: for field level we can do the same.. the value passed from mutations get a prefix automatically.
Describe alternatives you've considered
I can use something like uuid package and pass my own IDs. The only problem is that there is a management overhead when a new model is added. its needs to be added here. (and for manyToMany models too)
I tried overriding the values using slots
constgetPrefix=(fieldName: string)=>{// for createUser, we should get u_// for createQuestionTags we should get qt_// get only the first letter of each word and join themconstallCapsArray=fieldName.replace("create","").split(/(?=[A-Z])/).map((word)=>word[0].toLowerCase());returnallCapsArray.join("")+"_";};constgraphApi=newAmplifyGraphqlApi(stack,"GraphqlApi",{definition: AmplifyGraphqlDefinition.fromFiles("stacks/amplify-schema.graphql"),apiName: "GraphqlApi",translationBehavior: {},transformerPlugins: [],functionSlots: ["createQuestionTags","createQuestion","createTag","createUser","createAnswer",].map((fieldName)=>({fieldName: fieldName,function: {requestMappingTemplate:
MappingTemplate.fromString(`## [Start] Request mapping template.## get the "fieldName" from ctx.stash and add it as a prefix to id.. make sure to replace 'create' word with ''$util.qr($ctx.stash.defaultValues.put("id", "${getPrefix(fieldName)}$util.autoId()"))## [End] Initialization default values. **`),},slotIndex: 0,slotName: "init",typeName: "Mutation",})),authorizationModes: {apiKeyConfig: {expires: Duration.days(365),description: "API Key for GraphQL API - "+stack.stage,},defaultAuthorizationMode: "OPENID_CONNECT",oidcConfig: {oidcIssuerUrl: process.env.CLERK_ISSUER_BASE_URL!,oidcProviderName: "Clerk",tokenExpiryFromAuth: Duration.millis(0),tokenExpiryFromIssue: Duration.millis(0),},},});
Additional context
No response
Is this something that you'd be interested in working on?
👋 I may be able to implement this feature request
Would this feature include a breaking change?
⚠️ This feature might incur a breaking change
The text was updated successfully, but these errors were encountered:
Describe the feature you'd like to request
Hi Team, was wondering if it was possible to create a custom directive eg: @Prefix('String').. that would add that prefix to the uuids generated in dynamodb.
Describe the solution you'd like
Using this directive will simply update the uuid and add a prefix on the autogenerated one.
9fbbfda1-bc51-4cf7-ba45-8a8042a40462 -> usr_9fbbfda1-bc51-4cf7-ba45-8a8042a40462
Expansion on idea: for field level we can do the same.. the value passed from mutations get a prefix automatically.
Describe alternatives you've considered
I can use something like uuid package and pass my own IDs. The only problem is that there is a management overhead when a new model is added. its needs to be added here. (and for manyToMany models too)
I tried overriding the values using slots
Additional context
No response
Is this something that you'd be interested in working on?
Would this feature include a breaking change?
The text was updated successfully, but these errors were encountered: