Skip to content
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

Closed
wants to merge 6 commits into from
Closed

Conversation

claudiu-cristea
Copy link

Fixes #766

@claudiu-cristea claudiu-cristea mentioned this pull request Aug 21, 2023
@@ -36,7 +36,7 @@ abstract class AbstractApi
*
* @var string
*/
private const URI_PREFIX = '/api/v4/';
protected const URI_PREFIX = '/api/v4/';

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? 🤔

Copy link
Author

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.

Copy link
Member

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?

Copy link
Author

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, so AbstractApi::prepareUriP(), needs to get /api when subclassed as \Gitlab\Api\GraphQL

private const URI_PREFIX = '/api/v4/';
protected const URI_PREFIX = '/api/v4/';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should split version out of URI_PREFIX, into a protected class? Then we override the version in GraphQL as GitLab GraphQL is versionless


namespace Gitlab\Api;

class GraphQL extends AbstractApi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a few test cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should. But I have no time to work on

@@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert these changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think will work. GraphQL needs a different URL prefix

@GrahamCampbell GrahamCampbell changed the title GraphQL API [11.13] GraphQL API Oct 8, 2023
@GrahamCampbell GrahamCampbell changed the base branch from 11.11 to 11.13 October 8, 2023 14:05
Copy link
Member

@GrahamCampbell GrahamCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a mistake to extend AbstractApi at all.

@claudiu-cristea
Copy link
Author

I think it's a mistake to extend AbstractApi at all.

Maybe but I wanted to reuse AbstractApi::post(). Or should we move that in a trait?

@GrahamCampbell
Copy link
Member

We should just take the hit on a little duplication. Traits are horrible for this type of thing (most things imo :trollface:).

@GrahamCampbell GrahamCampbell changed the title [11.13] GraphQL API [11.14] GraphQL API Dec 3, 2023
@GrahamCampbell GrahamCampbell changed the base branch from 11.13 to 11.14 December 3, 2023 22:46
@GrahamCampbell
Copy link
Member

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

GraphQL API
3 participants