-
-
Notifications
You must be signed in to change notification settings - Fork 272
Add support for route parameters #1067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
405fcd2
Update GraphQLController.php
alancolant b55992e
add test for route parameters schema
alancolant 8f8668d
correction empty prefix schema detection
alancolant d475c60
switch schema detection and route config using HttpMiddleware with se…
alancolant f0eecd2
remove unused code
alancolant 8ea800b
remove unused code
alancolant d2cb033
run fix style
alancolant fe5fb89
externalise function getroute in graphql
alancolant 373fe28
remove fn()=>callback instead of more simple function
alancolant 0b713d6
Merge branch 'rebing:master' into master
alancolant 0084870
Merge remote-tracking branch 'upstream/master'
alancolant 49842d7
Merge branch 'rebing:master' into master
alancolant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rebing\GraphQL\Tests\Unit; | ||
|
|
||
| use Illuminate\Contracts\Config\Repository; | ||
| use Rebing\GraphQL\GraphQLController; | ||
| use Rebing\GraphQL\Support\Facades\GraphQL; | ||
| use Rebing\GraphQL\Tests\TestCase; | ||
|
|
||
| class EndpointParamsTest extends TestCase | ||
| { | ||
| public function testGetDefaultSchemaWithRouteParameter(): void | ||
| { | ||
| $response = $this->call('GET', '/graphql/arbitrary_param', [ | ||
| 'query' => $this->queries['examples'], | ||
| ]); | ||
|
|
||
| self::assertEquals(200, $response->getStatusCode()); | ||
|
|
||
| $content = $response->getData(true); | ||
| self::assertArrayHasKey('data', $content); | ||
| self::assertEquals($content['data'], [ | ||
| 'examples' => $this->data, | ||
| ]); | ||
| } | ||
| public function testGetCustomSchemaWithRouteParameter(): void | ||
| { | ||
| $response = $this->call('GET', '/graphql/arbitrary_param/custom', [ | ||
| 'query' => $this->queries['examplesCustom'], | ||
| ]); | ||
| self::assertEquals(200, $response->getStatusCode()); | ||
| $content = $response->getData(true); | ||
| self::assertArrayHasKey('data', $content); | ||
| self::assertEquals($content['data'], [ | ||
| 'examplesCustom' => $this->data, | ||
| ]); | ||
| } | ||
|
|
||
| protected function getEnvironmentSetUp($app): void | ||
| { | ||
| parent::getEnvironmentSetUp($app); | ||
| $app['config']->set('graphql.route.prefix', 'graphql/{parameter}'); | ||
| } | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One side effect here I noticed that in
\Rebing\GraphQL\Tests\Unit\EmptyRoutePrefixTest::testEmptyRoutePrefixthe$pathwill turn into//(the test didn't break, I just noticed it and we should avoid this).But this is without considering your other suggestion.
Feel free to go wild on the routing code and propose further commits with follow-up changes, as long as everything is covered with tests (they help me immensely figuring out where to go with this).