driesvints / sponsors

A package for PHP to interact with GitHub Sponsors.
MIT License
104 stars 7 forks source link

Fake GraphQL requests with HTTP client #12

Open driesvints opened 2 years ago

driesvints commented 2 years ago

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.

claudiodekker commented 2 years ago

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'.",
            ],
        ],
    ]),
]);