sponsors
sponsors copied to clipboard
Fake GraphQL requests with HTTP client
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.
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'.",
],
],
]),
]);