GithubHelp home page GithubHelp logo

Comments (6)

dmongeau avatar dmongeau commented on July 29, 2024 1

Yeah but the GraphQL facade doesn't support to pass an initial $root as you can see in the example you send. So you will have recreate the method queryAndReturnResult yourself or just call this, from your controller (or anywhere else):

$schema = GraphQL::schema();
$result = GraphQLBase::executeAndReturnResult($schema, $query, null, $params);

from laravel-graphql.

dmongeau avatar dmongeau commented on July 29, 2024

I think it doesn't work that way. If you look at the example you are sending, the second (and other) mutation doesn't receive the $root from the previous mutation. They all receive the same $root which was passed at the execute method. The test is only checking if it executes in the right order according to the GraphQL specification described here: https://facebook.github.io/graphql/#sec-Serial-execution

To do what you intent, first the login should, in my opinion, be done via a header with the token and handled with the auth middleware, or be part of the arguments of your mutations. For the mutations, since GraphQL execute them one after the other it kind of does what you want except you will have to manually retrieve the results of the mutation before (from your database for example).

from laravel-graphql.

belohlavek avatar belohlavek commented on July 29, 2024

@dmongeau thanks for the quick reply!

Then.. what's $root used for in queries/mutations?

from laravel-graphql.

dmongeau avatar dmongeau commented on July 29, 2024

It's not specific to mutations, the $root is always null at the top level if don't give a "starting root" to the GraphQL execute method.

from laravel-graphql.

belohlavek avatar belohlavek commented on July 29, 2024

@dmongeau this would be the execute method right?
https://github.com/Folkloreatelier/laravel-graphql/blob/5d6be2ababfe0974d85e0e53bd6a5892e8e1e442/src/Folklore/GraphQL/GraphQL.php#L117

I know auth is done via the header with a token bearer. But if I were to change that inital null for something else.. I should be able to pull it off, right? 😈

from laravel-graphql.

belohlavek avatar belohlavek commented on July 29, 2024

I definitively got it to work. Nice experiment, thanks!

from laravel-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.