-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: Change default value for BUTLER_GRAPHQL_NAMESPACE. #24
Conversation
Will this break implementations relying on the current default value? It might be worth adding test cases that describes the old and new behaviour :) |
It can definitely break existing implementations, yes. If someone added a It's kind of an laravel detail that is the issue, not sure how we could add test-cases for that... Will have to think about that one..... :) ❤️ |
It can break if you manually have registered @emil-nasso this PR should also update the README and CHANGELOG |
b5792ce
to
c07a9a4
Compare
As this is a library, we have no need for a checked in lock-file.
The value of the `BUTLER_GRAPHQL_NAMESPACE` environment variable is used when resolving graphql queries, mutations and types. The default value for this namespace is prefixed by `\\`. When this library resolves a query from the container it resolves object with the `\` prefix included. The problem arises when you try to bind or resolve something in the container using `ExampleQuery::class` as this does not use `\` as a prefix. Example: The namespace in our config is `\App\Http\Graphql` and we are trying to resolve the `Example` query. This library will resolve `\App\Http\Graphql\Example` in the container. We need to inject a specific instance of a class to the constructor of the query so we declare the following: ``` $app->when(Example::class)->needs(Dep::class)->give(...) ``` `Example::class` will expand to `App\Http\Graphql\Example`. Because this doesn't match `\App\Http\Graphql\Example`, the binding won't work. This commit changes the default namespace in the config to use the standard format in php.
c07a9a4
to
96fccea
Compare
The value of the
BUTLER_GRAPHQL_NAMESPACE
environment variable is used when resolving graphql queries, mutations and types.The default value for this namespace is prefixed by
\\
. When this library resolves a query from the container it resolves object with the\
prefix included. The problem arises when you try to bind or resolve something in the container usingExampleQuery::class
as this does not use\
as a prefix.Example:
The namespace in our config is
\App\Http\Graphql
and we are trying to resolve theExample
query. This library will resolve\App\Http\Graphql\Example
in the container.We need to inject a specific instance of a class to the constructor of the query so we declare the following:
Example::class
will expand toApp\Http\Graphql\Example
. Because this doesn't match\App\Http\Graphql\Example
, the binding won't work.This commit changes the default namespace in the config to use the standard format in php.