wrap-cli icon indicating copy to clipboard operation
wrap-cli copied to clipboard

The @env annotation and Env type should be declared together

Open krisbitney opened this issue 3 years ago • 0 comments

The @env annotation is currently placed on methods to indicate which methods accept or require an Env. This works well until we consider interfaces and their implementations. The @env annotation must be placed on the interface method definition, but the Env definition is in the implementation.

Interface

type Module {
  foo(arg: String): Boolean @env(required=true);
}

Implementation

type Module {} implements Interface_Module

type Env { ... }

As @Niraj-Kamdar suggested, the need and use of environmental variables should be determined by implementations, not interfaces, so it makes sense to move the @env declaration from methods to another place. For example, if the GraphQL parser can manage it, we could have users list which methods accept or require the Env in an annotation on the Env type.

type Env { ... } @required(["method1", "method2", "method3"]) @optional(["method4, ...])

This issue should be discussed more before moving forward with any implementation!

krisbitney avatar Aug 19 '22 12:08 krisbitney