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

Global variables do not respect custom scalar constraint #8423

Open
MiroslavPetrik opened this issue Mar 3, 2025 · 0 comments
Open

Global variables do not respect custom scalar constraint #8423

MiroslavPetrik opened this issue Mar 3, 2025 · 0 comments

Comments

@MiroslavPetrik
Copy link
Contributor

Schema:

module default {

  scalar type Lang extending str {
    constraint one_of("sk", 'en');
  }

  required global i18nLang: Lang {
    default := "sk";
  };

}

Current behavior:

The variable can be set with value not respecting the Lang type.

set global i18nLang := "cz";
OK: SET GLOBAL

Expected behavior:

Instead an error of ConstraintViolationError should be displayed.

ConstraintViolationError: Lang must be one of: ['sk', 'en'].
Details: violated constraint 'std::one_of' on scalar type 'default::Lang'

because similarly, when we set a wrong type, we get:

set global i18nLang := 32;
gel error: ConfigurationError: invalid setting value type for default::i18nLang: 'std::int64' (expecting 'default::Lang')

This would be cool also to have handled in the ui so it won't allow to set invalid values (it will fail early).

  • Gel Version: 6.1+4db24c0
  • Gel CLI 7.0.3+d9b7a86
  • OS Version: W11
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

No branches or pull requests

1 participant