Giter Site home page Giter Site logo

laravel-graphql-test's People

Contributors

davidnadejdin avatar ivanyeoh avatar marvinrabe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ivanyeoh ag-php

laravel-graphql-test's Issues

PHPUnit testing Authentication - Logout

I have tried testing the authentication process with PHPUnit. I have managed to test all mutations apart from the logout.

$this->mutation('logout', ['status', 'message']); logout = the mutation, [status and message] = the LogoutResponse payload

When I run that, I get the below error message:

“message” => “Syntax Error: Expected Name, found Int”

It would seem that it is asking for a second parameter (Which I am guessing is the Authorization Bearer info), but in the schema, there are no parameters, just the payload:

Schema: logout: LogoutResponse!

I have got it working with another package:

$response = $this->postGraphQL([
'query' => 'mutation {
logout {
status
message
}
}'
], [
'Authorization' => 'Bearer '.$token
]);

But I would ideally like to get it working with your package.

Would appreciate a stir in the right direct.

Upgrading to laravel 8

Hello,
Thak thank you support this project.

I just upgraded one of my projects and got an error in phpDoc.
Your package describes \Illuminate\Foundation\Testing\TestResponse as a returning type.
But In laravel 8 it has been moved to \Illuminate\Testing\TestResponse.

Example: file marvinrabe/laravel-graphql-test/src/TestGraphQL.php

/**
* Returns a TestGraphQL client. If no arguments and selection is provided, it will query the server directly.
* @param string $object GraphQL query name
* @param array|null $arguments Specifies arguments send to the server. When selection is null it will be used as a selection set instead.
* @param array|null $selection Specifies Selection set send to the server.
* @return GraphQLClient|\Illuminate\Foundation\Testing\TestResponse
**/
public function query(string $object, $arguments = null, $selection = null)
{
$client = GraphQLClient::query($object, function ($query) {
return $this->postJson(
$this->graphQLEndpoint ?? 'graphql',
[
'query' => $query,
]
);
});

    return $this->prepareClient($client, $arguments, $selection);
}

My tests still working but ide inform that It can't find a response and autocomplete doesn't work anymore.
I can create PR just let me know

Empty array arguments returns GraphQLClient

Nice work @marvinrabe
This library make our life easier for our GraphQL testing.

Recently I encounter the same issue as #3 when I tried to test logout mutation that doesn't need any arguments and selection

I tried your suggestion in #3:
$this->mutation('logout', [], ['status', 'message'])
and
$this->mutation('logout', [])
and found that it always returns GraphQLClient because in php empty array is equals to null

I've submitted a PR fix for this, please take a look
#4

how could we use header in requests

i want to set authentication header for my test.
how can i do this ?
in postJson i can set header parameter. should i edit package manually ? or we have any option to add header in requests.

and also thank you for this package

Enum Formatting

Currently:

$this->setArguments(['enum' => 'foo'])

results in

(enum: "foo")

Expected:

$this->setArguments(['enum' => 'foo'])

results in

(enum: foo)

Workaround:

Create a class

class Enum {
  protected $value;

  public function __construct($value) {
    $this->value = $value;
  }

  public function __toString() {
    return $this->value;
  }
}

And then:

$this->setArguments(['enum' => new Enum('foo')])

results in

(enum: foo)

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.