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

Feat: Introduce @value definition for exact values #201

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tomasjanicek
Copy link

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"}])

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.

None yet

2 participants