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

Env refactor #967

Merged
merged 47 commits into from
Jul 1, 2022
Merged

Env refactor #967

merged 47 commits into from
Jul 1, 2022

Conversation

namesty
Copy link
Collaborator

@namesty namesty commented Jun 24, 2022

Overview

This PR aims to change the way environment variables/configuration is passed to wrappers. This was done with 5 main objectives in mind:

  • Change the wasm-boundary functions to follow from a a "pull" model, instead of a "push" model
  • Remove ClientEnv and sanitizeEnv concept
  • Support environment configuration for Rust wrappers
  • Enable/pass environment at the method level
  • Prepare implementation for, in the future, overriding environment properties at the method level

Over the course of the development and discussion process, we realized there were additional tasks to implement to be feature complete. So this PR also enables:

  • Support for importing external environment types
  • Support for conditional environment configs
  • Support for environment configuration for subinvoked wrappers
  • E2E tests for both subinvocation with env configurations, and Rust wrappers with env configurations.

Developer experience changes

We're introducing the @env directive, which annotates methods that use an environment configuration:

schema.graphql:

type Env {
  str: String
  requiredInt: Int!
}

type Module {
  getEnv(arg: String!): Env @env(required: false)
}

Additionally, now module methods take a second env argument, from where the wrapper developer can access the environment variables:

index.ts:

import { Env, Input_getEnv } from "./wrap";

export function getEnv(input: Input_getEnv, env: Env | null): Env | null {
  return env;
}

dOrgJelli and others added 26 commits June 17, 2022 11:06
Removal of ClientEnv + Sanitize - Reserve env arg
@dOrgJelli dOrgJelli marked this pull request as ready for review June 30, 2022 22:12
@dOrgJelli dOrgJelli merged commit 47a8c52 into prealpha-dev Jul 1, 2022
@dOrgJelli dOrgJelli deleted the env-refactor branch April 10, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants