The @env annotation and Env type should be declared together
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!