-
Notifications
You must be signed in to change notification settings - Fork 234
passing some extra value from GraphQLController@query method to Folklore\GraphQL\Support\Mutation@resolve? #393
Comments
You can implement your own GraphQLController. In order to do that, just change in config/graphql.php the following: But just to warn you, file upload with GraphQL is not trivial. |
For one, nothing in your resolver prevents you from simply calling A better approach is to make use of the GraphQL "context". The default context is created in As you can see, it only consists of the authenticated user, so However: you can replace the GraphQLController with your own, override this method and return whatever context you have. This is explicitly supported because in Since the Folklore controller already receives the
A totally different option: nuwave/lighthouse is another GraphQL server which a) is actually maintained and has a lot development activity (this is seems like a dead horse and b) has a Context which actually does implement exactly what you asked for. |
BTW, yes, overriding queryContext is a good idea to store, for example, some non-user data in the request lifecycle. (IMHO) |
@mfn, i had a look on this package when we started our project and it was not ready for production at that moment... How do you think, is it hard to transfer a project from folklore package to nuawe package? And is it production-ready at the moment, in your opinion? Thanks! |
Although I'm not using lighthouse, unfortunately I have an opinion 😄
I think it depends. My mid-sized project using Folklore is using some construct with the programmatic Type definition approach which do not translate to any schema DSL approach. Or, not easy. lighthouse is schema-first and radically different but OTOH also more "mainstream" (i.e. other tech stacks very well do this schema-first approach, too). Schema-first also has the benefit of better tooling: many IDE tools understand the GraphQL schema and assist in writing it.
From what I gather, Yes! And if you find a problem: they're incredible fast helping/answering/fixing stuff. Not so this library, you're basically on your own. I lost track of the amount of workarounds (a few weeks of work) I required to make Folklore work the way I need it. Unfortunately back then I wasn't aware of lighthouse 💣 |
Well, if so, probably we'll be looking forward to implement it, because now we have a huge problem with integrating folklore due to non-published tag 😸 (every time we need to drop vendor/folklore in order to run |
You can work this around. Composer allows to specify "repositories" and by basically copying the composer.json of Folklore and adjusting in, it kind of "shadows" the real one. I.e. under the top level {
"type": "package",
"package": {
"version": "v1.1.0.1",
"dist": {
"url": "https://github.com/Folkloreatelier/laravel-graphql/archive/66e92331ff677cf02d2ecfecec8103ada965fbad.zip",
"type": "zip"
},
"name": "folklore/graphql",
"description": "Facebook GraphQL for Laravel",
"keywords": ["framework", "laravel", "graphql", "react"],
"authors": [
{
"name": "Folklore",
"email": "[email protected]",
"homepage": "http://atelierfolklore.ca"
},
{
"name": "David Mongeau-Petitpas",
"email": "[email protected]",
"homepage": "http://mongo.ca",
"role": "Developer"
}
],
"license": "MIT",
"type": "library",
"require": {
"php": ">=5.5.9",
"illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*",
"webonyx/graphql-php": "~0.10.2"
},
"require-dev": {
"orchestra/testbench": "3.1.*|3.2.*|3.3.*|3.4.*|3.5.*",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"satooshi/php-coveralls": "^1.0",
"phpunit/phpunit": "~4.0|~5.0|~5.7|~6.0"
},
"autoload": {
"psr-0": {
"Folklore\\GraphQL\\": "src/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"extra": {
"laravel": {
"providers": [
"Folklore\\GraphQL\\ServiceProvider"
],
"aliases": {
"GraphQL": "Folklore\\GraphQL\\Support\\Facades\\GraphQL"
}
}
}
} and I reference it with this made up version number: "folklore/graphql": "1.1.0.1", I guess there are better ways but this isn't the first time I had to apply this for 3rd party packages starting to get problematic due to be orphaned. Of course another solution is to fork it, rename it, etc. |
Nice workaround, i'll definitely try it. Recently we were thinking about forking it, because actually this package solves the majority of our problems. |
Is it possible to send some extra value from GraphQLController@query method to Folklore\GraphQL\Support\Mutation@resolve?
I need to be able to get file from $request object in my resolve method of my mutation classes.
Is such a thing possible?
The text was updated successfully, but these errors were encountered: