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

::devMode and ::prodMode with optional parameter? #728

Open
josefsabl opened this issue Feb 3, 2025 · 3 comments
Open

::devMode and ::prodMode with optional parameter? #728

josefsabl opened this issue Feb 3, 2025 · 3 comments

Comments

@josefsabl
Copy link

Maybe the GraphQLite\SchemaFactory::devMode and GraphQLite\SchemaFactory::prodMode could accept an optional parameter like this:

function devMode(bool $v = true);
function prodMode(bool $v = true);

This way, instead of:

$schemaFactory
  ->addNamespace
  ->setFinder(...);

if (DEV_MODE) {
  $schemaFactory->devMode();
} else {
  $schemaFactory->prodMode();
}

One could simply write:

$schemaFactory
  ->addNamespace
  ->setFinder(...);
  ->devMode(DEV_MODE);
@enricobono
Copy link

Hello @josefsabl.
What's the need behind your proposal?

@oojacoboo
Copy link
Collaborator

@josefsabl I agree that the API is unfortunate... This wouldn't be a BC break and I'm open to a PR. Thanks.

@oprypkhantc
Copy link
Contributor

Yeah I noticed that one too. devMode could just default to false, and accept a default parameter of true:

class SchemaFactory {
    private bool $devMode = false;

    public function devMode(bool $value = true): self
    {
        $this->devMode = $value;

        return $this;
    }
}

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

4 participants