Skip to content

feat: include cmaClientOptions in FunctionEventContext [EXT-6303] #767

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

Merged
merged 1 commit into from
Apr 1, 2025

Conversation

jjolton-contentful
Copy link
Contributor

@jjolton-contentful jjolton-contentful commented Apr 1, 2025

To use the CMA in a function, install contentful-management into your project and initialize it like so:

import * as contentful from "contentful-management";

export const handler: FunctionEventHandler<
  FunctionTypeEnum.AppEventHandler,
> = async (event: AppEventRequest, context: FunctionEventContext) => {
  const cma = contentful.createClient(
    context.cmaClientOptions!,
    {
      defaults: {
        spaceId: context.spaceId,
        environmentId: context.environmentId,
      },
      type: "plain",
    }
  );
   
  // ...
}

@jjolton-contentful jjolton-contentful requested a review from a team as a code owner April 1, 2025 15:51
@jjolton-contentful jjolton-contentful merged commit b94fcd4 into main Apr 1, 2025
11 checks passed
@jjolton-contentful jjolton-contentful deleted the feat/functions-bring-your-own-cma-client branch April 1, 2025 21:27
contentful-automation bot added a commit that referenced this pull request Apr 1, 2025
# [3.13.0](v3.12.0...v3.13.0) (2025-04-01)

### Features

* include cmaClientOptions in FunctionEventContext [EXT-6303] ([#767](#767)) ([b94fcd4](b94fcd4))
@contentful-automation
Copy link
Contributor

🎉 This PR is included in version 3.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants