- GraphiQL
- Errors handler
- Promise adapter interface
- Expression language
- Type autoMapping and Symfony DI autoconfigure
- Events
- Explicitly declare non detected types
- Change fluent resolvers id
- The GraphiQL interface has been removed in favor of a new bundle.
Upgrading:
- Remove the graphiql route from your application
- For standard Symfony installation:
/app/config/routing_dev.yml
- For Symfony Flex:
/config/routes/dev/graphql_graphiql.yaml
- For standard Symfony installation:
- Installing OverblogGraphiQLBundle
composer require --dev overblog/graphiql-bundle
- Follow instructions at https://github.com/overblog/GraphiQLBundle
- In case you have defined the
versions
in your configuration- Remove it from
overblog_graphql
overblog_graphql: - versions: - graphiql: "0.11" - react: "15.6" - fetch: "2.0" - relay: "classic"
- Add it to
overblog_graphiql
overblog_graphiql: + javascript_libraries: + graphiql: "0.11" + react: "15.6" + fetch: "2.0"
- If you were using the
graphql:dump-schema
and depending on therelay
version as in the previous configuration, now you have to explicitly choose for a format during the command:bin/console graphql:dump-schema --modern
- Remove it from
- Made errors handler more customizable
Upgrading:
- Delete configuration to override base user exception classes.
overblog_graphql: definitions: exceptions: - types: - warnings: ~ - errors: ~
- Move
internal_error_message
,map_exceptions_to_parent
andexceptions
configurations fromdefinitions
to new dedicatederror_handler
section.overblog_graphql: definitions: - internal_error_message: ~ - map_exceptions_to_parent: ~ - exceptions: ~ + errors_handler: + internal_error_message: ~ + map_exceptions_to_parent: ~ + exceptions: ~
- Changed the promise adapter interface (
Overblog\GraphQLBundle\Executor\ExecutorInterface
) as the promiseAdapter is not nullable in the bundle context.
Upgrading:
setPromiseAdapter
method no more nullable.- public function setPromiseAdapter(PromiseAdapter $promiseAdapter = null); + public function setPromiseAdapter(PromiseAdapter $promiseAdapter);
- user expression variable has been replaced by getUser expression function
- container, request and token expression variables has been removed.
service
orserv
expression function should be used instead.
Upgrading your schema configuration:
-
Replace
user
bygetUser()
:- resolve: '@=user' + resolve: '@=getUser()'
or
- resolve: '@=resolver('foo', [user])' + resolve: '@=resolver('foo', [getUser()])'
-
Replace
token
byserv('security.token_storage')
- resolve: '@=token' + resolve: '@=serv('security.token_storage')'
or
- resolve: '@=resolver('foo', [token])' + resolve: '@=resolver('foo', [serv('security.token_storage')])'
-
Replace
request
byserv('request_stack')
- resolve: '@=request' + resolve: '@=serv('request_stack')'
or
- resolve: '@=resolver('foo', [request])' + resolve: '@=resolver('foo', [serv('request_stack')])'
When using these functionalities, type will be accessible only by FQCN in schema definition
(if class doesn't implement Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface
).
So if you want to use the true
type name don't forget to declare it as an alias using interface.
This change is to increase performance, types are lazy-loaded.
Here's an example:
<?php
namespace App\GraphQL\Type;
use GraphQL\Type\Definition\ScalarType;
class DateTimeType extends ScalarType
{
public $name = 'DateTime';
// ...
}
Before 0.11: DateTimeType could be accessed by FQCN App\GraphQL\Type\DateTimeType
and the real DateTimeType
.
Since 0.11: Only FQCN App\GraphQL\Type\DateTimeType
is accessible
Here is how this can be done in 0.11:
<?php
namespace App\GraphQL\Type;
use GraphQL\Type\Definition\ScalarType;
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
class DateTimeType extends ScalarType implements AliasedInterface
{
public $name = 'DateTime';
/**
* {@inheritdoc}
*/
public static function getAliases()
{
return ['DateTime'];
}
// ...
}
Before 0.11 all types was declare as non detected types, this was not the correct way of declaring types. This could lead to some performances issues or/and wrong types public exposition (in introspection query). See webonyx/graphql-php documentations for more details
Since 0.11 Non detect types should be explicitly declared
Here is a concrete example:
Query:
type: object
config:
fields:
foo: {type: FooInterface!}
FooInterface:
type: interface
config:
fields:
id: {type: ID!}
resolveType: '@=resolver("foo", [value])'
Bar:
type: object
config:
fields:
id: {type: ID!}
# ...
interfaces: [FooInterface]
Baz:
type: object
config:
fields:
id: {type: ID!}
# ...
interfaces: [FooInterface]
In above example Baz
and Bar
can not be detected by graphql-php during static schema analysis,
an GraphQL\Error\InvariantViolation
exception will be thrown with the following message:
Could not find possible implementing types for FooInterface in schema.
Check that schema.types is defined and is an array of all possible types in the schema.
Here is how this can be fixed:
overblog_graphql:
definitions:
schema:
query: Query
types: [Bar, Baz]
Overblog\GraphQLBundle\Event\ExecutorContextEvent::setExecutorContext
method has been removed as context
is now an ArrayObject
. When using graphql.executor.context
listener the value will now be accessible only
in context
variables and not in rootValue
. context
and rootValue
have been separated, if you need to
use rootValue
see event documentation for more details.
Before 0.11
context
and rootValue
were of type array
with same value so $context === $info->rootValue
and
$context === $value
in root query resolver. Because of this, uploaded files was accessible in
$context['request_files']
and $info->rootValue['request_files']
.
Since 0.11
context
is of type ArrayObject
and rootValue
has no typeHint (default: null
) so
$context !== $info->rootValue
and $context !== $value
in root query resolver.
Uploaded files is no longer accessible under $info->rootValue['request_files']
out of the box.
The use of class name as prefix of fluent resolver id removes the possibility to use same class as 2 different services. See issue #296 for more detail Because of this, in v0.11 we are using service id as prefix (like in Symfony 4.1)...
Example:
services:
app.resolver.greetings:
class: App\GraphQL\Resolver\Greetings
tags:
- { name: overblog_graphql.resolver, method: __invoke, alias: say_hello }
- { name: overblog_graphql.resolver }
Before 0.11: '@=resolver("App\\GraphQL\\Resolver\\Greetings", [args['name']])'
Since 0.11: '@=resolver("app.resolver.greetings", [args['name']])'