-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
[11.14] GraphQL API #772
[11.14] GraphQL API #772
Changes from all commits
0421470
91cca79
23b7f98
13fb10d
6f445b8
079836d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ abstract class AbstractApi | |
* | ||
* @var string | ||
*/ | ||
private const URI_PREFIX = '/api/v4/'; | ||
protected const URI_PREFIX = '/api/v4/'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should split version out of |
||
|
||
/** | ||
* The access levels for groups and projects | ||
|
@@ -264,7 +264,7 @@ private static function prepareUri(string $uri, array $query = []): string | |
return null !== $value; | ||
}); | ||
|
||
return \sprintf('%s%s%s', self::URI_PREFIX, $uri, QueryStringBuilder::build($query)); | ||
return \sprintf('%s%s%s', static::URI_PREFIX, $uri, QueryStringBuilder::build($query)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert these changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think will work. GraphQL needs a different URL prefix |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Gitlab API library. | ||
* | ||
* (c) Matt Humphrey <matth@windsor-telecom.co.uk> | ||
* (c) Graham Campbell <hello@gjcampbell.co.uk> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gitlab\Api; | ||
|
||
class GraphQL extends AbstractApi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should have a few test cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should. But I have no time to work on |
||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected const URI_PREFIX = '/api'; | ||
|
||
/** | ||
* @param string $query | ||
* @param array $variables | ||
* | ||
* @return array | ||
*/ | ||
public function execute(string $query, array $variables = []) | ||
{ | ||
$params = [ | ||
'query' => $query, | ||
]; | ||
if (!empty($variables)) { | ||
$params['variables'] = \json_encode($variables); | ||
} | ||
|
||
return $this->post('/graphql', $params); | ||
} | ||
|
||
/** | ||
* @param string $file | ||
* @param array $variables | ||
* | ||
* @return array | ||
*/ | ||
public function fromFile(string $file, array $variables = []) | ||
{ | ||
return $this->execute(\file_get_contents($file), $variables); | ||
} | ||
} |
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.
Do you really need to change this? Since you're using static now, it should automatically use the one from the child class, no? 🤔
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.
In PHP
private
means a sub-class cannot extend/override it.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.
why does it need to be overwritten? the changes you want don't need to re-use this?
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.
@GrahamCampbell, GraphQL is versionless. The URL prefix is
/api
instead of/api/v4
, soAbstractApi::prepareUriP()
, needs to get/api
when subclassed as\Gitlab\Api\GraphQL