sponsors icon indicating copy to clipboard operation
sponsors copied to clipboard

Fake GraphQL requests with HTTP client

Open driesvints opened this issue 3 years ago • 1 comments

To speed things up we should fake the GraphQL requests. This will also be necessary to allow pull requests from GitHub since those won't be authenticated with a token and thus all PR's will fail.

We should also keep a portion of an integration test suite with a real token but those tests can be skipped if no token is set on the environment.

driesvints avatar Aug 21 '21 14:08 driesvints

Posting for relevance / use-for-parts (copied from my WIP inertiajs implementation):

Http::fake([
    'https://api.github.com/graphql' => Http::response([
        'data' => [
            'user' => [
                'viewerIsSponsoring' => false,
            ],
            'organization' => null,
        ],
        'errors' => [
            [
                'type' => 'NOT_FOUND',
                'path' => [
                    'organization',
                ],
                'locations' => [
                    'line' => 5,
                    'column' => 3,
                ],
                'message' => "Could not resolve to an Organization with the login of 'reinink'.",
            ],
        ],
    ]),
]);

claudiodekker avatar Aug 25 '21 21:08 claudiodekker