graphql-faker
graphql-faker copied to clipboard
Feat: Introduce @value definition for exact values
I missed one essential thing in the whole implementation, and that is setting the exact values according to the input. In some cases, this makes it impossible to use graphql-faker as a mock only with @fake and @examples directives. So I finished the @value directive, which might help someone else.
how does it work?
for enum value:
enum UserRole {
STUDENT,
BUSINESS_STUDENT,
MANAGER
BUSINESS_MANAGER,
ADMINISTRATOR,
SUPER_ADMINISTRATOR
}
...
type User {
...
roles: [UserRole] @value(values: ["STUDENT", "BUSINESS_STUDENT"])
}
for Boolean or string values
token: String @value(value: "TOKEN")
isActive: String @value(value: true)
for other types:
type FeatureFlag {
name: String
}
featureFlags: [FeatureFlag!] @value(values: [{name: "cookie_banner"}, {name: "espresso"}])