You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So this is not really an issue, but I think it's worth discussing and I want it documented so that other people might find a use for it.
The background to this discussion is this issue. The current version of Relay (0.10) doesn't support root fields/queries to be arrays. In the linked issue above they suggest a workaround until Relay 2 is released. An updated version of the workaround has been suggested in this issue: lucasbento/graphql-pokemon#1
I don't think we should build support for this, since Relay 2 is coming, but the easiest way to add this to a project would be to extend GraphQL - since it's registered through Laravel's service container, and override the buildSchema()-method:
Nuwave\Lighthouse\GraphQL
publicfunction buildSchema() {
...$fields = $queryType->config['fields'];
$fields['query'] = [
'args' => [],
'type' => $queryType,
'resolve' => function() {
returntrue; // we need to have a closure that returns something
}
];
$queryType->config['fields'] = $fields;
...returnnewSchema([
'query' => $queryType,
'mutation' => $mutationType,
'types' => $this->typesWithInterfaces->all(),
]);
This is a hack(!) and probably shouldn't be used in production.
One could get away with doing something similar in their extension if they first call the parent on the overridden method (buildSchema()) and then get the mutations, queries and types from the generated Schema, and then instantiate a new Schema.
This is not recommended, since this package will most likely change.
If anyone has any suggestions on how (and why) support for this should be implemented for real, please, leave a comment!
The text was updated successfully, but these errors were encountered:
So this is not really an issue, but I think it's worth discussing and I want it documented so that other people might find a use for it.
The background to this discussion is this issue. The current version of Relay (0.10) doesn't support root fields/queries to be arrays. In the linked issue above they suggest a workaround until Relay 2 is released. An updated version of the workaround has been suggested in this issue: lucasbento/graphql-pokemon#1
I don't think we should build support for this, since Relay 2 is coming, but the easiest way to add this to a project would be to extend GraphQL - since it's registered through Laravel's service container, and override the buildSchema()-method:
Nuwave\Lighthouse\GraphQL
This is a hack(!) and probably shouldn't be used in production.
One could get away with doing something similar in their extension if they first call the parent on the overridden method (buildSchema()) and then get the mutations, queries and types from the generated Schema, and then instantiate a new Schema.
This is not recommended, since this package will most likely change.
If anyone has any suggestions on how (and why) support for this should be implemented for real, please, leave a comment!
The text was updated successfully, but these errors were encountered: