Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow global config that allows selection between uuid vs ksuid vs ulid. #2456

Open
2 tasks
harshit9715 opened this issue Apr 15, 2024 · 1 comment
Open
2 tasks
Labels
api-graphql feature-request New feature or request

Comments

@harshit9715
Copy link

Describe the feature you'd like to request

I can see the documentation allows all 3 types of IDs.

currently it uses uuid as default and there is no override option.

Describe the solution you'd like

we can provide a global config or translation behaviour option to provide an option to select an enum from one of uuid / ksuid and ulid?

Describe alternatives you've considered

I was able to override it for my specific use case.

const graphApi = new AmplifyGraphqlApi(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", "$util.autoUlid()"))
## [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),
      },
    },
  });

it does require a management overhead. to keep that array of models updated.

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
@AnilMaktala
Copy link

Hey @harshit9715, Thank you for requesting this. We are marking this as a feature request for the team to evaluate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-graphql feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants