olliethedev / amplify-graphql-typesense-transformer

Apache License 2.0
5 stars 0 forks source link

Is this plugin compatible with AmplifyGraphqlApi construct? #1

Open harshit9715 opened 7 months ago

harshit9715 commented 7 months ago

Hi, I read your blog and saw your plugin. I love it and I appreciate your work!

Here is what I am trying to do. I am not so much fan of amplify cli. but I really like the graphql transformer it offers.

So, I went to constructs.dev and started looking into alternate options and found @aws-amplify/graphql-api-construct.

I can use this in my CDK or sst.dev projects and get everything working.

const graphApi = new AmplifyGraphqlApi(stack, "GraphqlApi", {
    definition: AmplifyGraphqlDefinition.fromFiles(
      "stacks/amplify-schema.graphql"
    ),
    apiName: "GraphqlApi",
    translationBehavior: {},
    transformerPlugins: [],
    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),
      },
    },
  });

I was trying to put the plugin config into transformerPlugins but I am unable to do it. It does not have types and I am not sure how to link it.

I would be glad if you can help me out with this if you can even guide me to some directions I can start from there. I have looked into amplify-category-api repo and your repo code with no luck so far.

Quick note if you are trying this out on yout CDK project.

set the context variable app.nodesetContext("amplifyEnvironmentName", "dev");

olliethedev commented 7 months ago

Hi @harshit9715, This transformer was tested with AmplifyCLI, so by extension, it should technically work with the AmplifyGraphqlApi construct. However, I have not used the AmplifyGraphqlApi construct with the transformer directly. I will check this issue. In the meantime, can you specify the exact error you are seeing when initializing the AmplifyGraphqlApi construct with the transformer?

harshit9715 commented 7 months ago

Hi @olliethedev , thank you for looking into this.

I did spent quite some time trying to make it work and spent countless hours exploring the amplify-category-api GitHub.

Eventually i pulled the code from your repo and used the CDK code directly to attach the transformer upon which I got the error Asset Manager is not initialised. I believe this error is from how the VTL templates are generated. My best guess is, its trying to load the plugin before the templates are generated.

This is a side project for me and I did learn quite a few tricks.

https://github.com/aws-amplify/amplify-category-api/issues/2456 https://github.com/aws-amplify/amplify-category-api/issues/2455 https://github.com/aws-amplify/amplify-category-api/issues/2467 (this one has a video attached)