Skip to content

GraphQL API #510

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

Merged
merged 14 commits into from
Jan 30, 2017
Merged

GraphQL API #510

merged 14 commits into from
Jan 30, 2017

Conversation

m1guelpf
Copy link
Contributor

@m1guelpf m1guelpf commented Jan 23, 2017

Add support for the Github GraphQL API.

@m1guelpf m1guelpf mentioned this pull request Jan 23, 2017
1 task
@m1guelpf m1guelpf changed the title Glaphql api Glaphql API Jan 23, 2017
@m1guelpf m1guelpf changed the title Glaphql API GraphQL API Jan 23, 2017
@@ -0,0 +1,25 @@
<?php
namespace Github\Api;
Copy link
Contributor

Choose a reason for hiding this comment

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

1 space line before namespace tag is required

@m1guelpf
Copy link
Contributor Author

@cursedcoder Done!

/**
* GraphQL API.
*
* @link http://developer.github.com/v3/markdown/
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it should

Copy link
Collaborator

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Where can I find documentation about the endpoint? These docs just explain parameters.

Also, may you add a simple test?

/**
* GraphQL API.
*
* @link http://developer.github.com/v3/markdown/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it should

namespace Github\Api;

/**
* GraphQL API.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be mention that this is the Early Access program?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@m1guelpf
Copy link
Contributor Author

@Nyholm I keep having the same problem with the tests. I don't know how the fake data is generated, so I cannot add simple GraphQL data.
Maybe you should add that to the test docs.

*
* @return array
*/
public function graphql($query)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want the signature to be:
$github->graphql()->graphql($query)

Compare to:
$github->graphql()->execute($query)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want me to change it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think? What does @cursedcoder think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think execute() is more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Nyholm Changed.

@Nyholm
Copy link
Collaborator

Nyholm commented Jan 26, 2017

This test would work (I've not run it)

class GraphQLTest extends TestCase
{
    // ...

    /**
     * @test
     */
    public function shouldShowGistComment()
    {
        $api = $this->getApiMock();

        $api->expects($this->once())
            ->method('post')
            ->with('/graphql', 'bar')
            ->will($this->returnValue('foo'));

        $result = $api-> graphql('bar');
        $this->assertEquals('foo', $result);
    }

    protected function getApiClass()
    {
        return \Github\Api\GraphQL::class;
    }
}

@m1guelpf
Copy link
Contributor Author

@Nyholm Added Test.

@m1guelpf
Copy link
Contributor Author

@Nyholm Changed function name.

@@ -0,0 +1,25 @@
class GraphQLTest extends TestCase
{
// ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

copy/pate typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What typo?

@@ -0,0 +1,25 @@
class GraphQLTest extends TestCase
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file should have class comment and namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (I think)

/**
* @test
*/
public function shouldShowGistComment()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update this method name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* GraphQL API.
*
* Part of the Github API Early-Access Program
* @link https://developer.github.com/early-access/graphql/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be an extra space before this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

/**
* @test
*/

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this space.


$api->expects($this->once())
->method('post')
->with('/graphql', 'bar')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I missed that you are building an array.

->with($this->equalTo('/graphql'), $this->equalTo(['query'=>'bar']))

@m1guelpf
Copy link
Contributor Author

@Nyholm Fixed.

Copy link
Collaborator

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Awesome. Thank you!

@m1guelpf
Copy link
Contributor Author

@Nyholm @cursedcoder Merge?

@Nyholm
Copy link
Collaborator

Nyholm commented Jan 26, 2017

Im 👍 to merge. But since other collaborators were involved here I would like to give them some time to review the changes as well.

@cursedcoder
Copy link
Contributor

@xabbuh what would you say?

@cursedcoder
Copy link
Contributor

Anyway merging this because we got 2/3 votes.

@cursedcoder cursedcoder merged commit 22d967d into KnpLabs:master Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants