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

Initialize UserContributedToStream using Graphql #78

Merged
merged 15 commits into from
Feb 7, 2022
Merged

Conversation

ericboucher
Copy link
Contributor

@ericboucher ericboucher commented Feb 4, 2022

Initialize UserContributedToStream using Graphql

This also fixes #48

@ericboucher ericboucher marked this pull request as ready for review February 4, 2022 02:16
@ericboucher ericboucher linked an issue Feb 4, 2022 that may be closed by this pull request
@ericboucher ericboucher changed the title Initialize UserContributionsStream using Graphql Initialize UserContributedToStream using Graphql Feb 6, 2022
Copy link
Contributor

@laurentS laurentS left a comment

Choose a reason for hiding this comment

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

Nice! I like that this consumes from a different quota than the REST calls :)


name = "user_contributed_to"
query_path = "user.repositoriesContributedTo.nodes"
primary_keys = ["username"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to fetch the data by some other, more stable, identifier (thinking nodeId or id), as users can change their username at any time? I don't know what consequences this would have on this stream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sadly, I did not find any...

tap_github/client.py Outdated Show resolved Hide resolved
"""

schema = th.PropertiesList(
th.Property("id", th.StringType),
Copy link
Contributor

Choose a reason for hiding this comment

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

From what I understand, id in github's graphql context is the same as nodeId in REST. Would it be worth renaming the properties here to give a consistent naming in the output of the tap? REST has both id (an integer) and node_id (string).

Co-authored-by: Laurent Savaete <laurent@where.tf>
https://docs.python-requests.org/en/latest/api/#requests.Response
"""
resp_json = response.json()
data = glom(resp_json["data"], self.query_path)
Copy link
Member

Choose a reason for hiding this comment

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

TIL glom 🙂

The SDK already supports JSONPath, so I'm curious what are the benefits of glom over that.

Copy link
Contributor Author

@ericboucher ericboucher Feb 7, 2022

Choose a reason for hiding this comment

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

@edgarrmondragon I am trying to use JSONPath and it works with online tools but I can't get it to work in the code.

This is what I am doing:

resp_json = response.json()
yield from extract_jsonpath(self.query_jsonpath, input=resp_json)

with query_jsonpath = "$.data.user.repositoriesContributedTo.nodes.*"

The list returns empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nvm I think I fixed it in 9435df7

Copy link
Member

Choose a reason for hiding this comment

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

@ericboucher looks good!

@sonarcloud
Copy link

sonarcloud bot commented Feb 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ericboucher ericboucher merged commit b803989 into main Feb 7, 2022
@ericboucher ericboucher deleted the graphql-query branch February 7, 2022 20:13
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.

Implement a base GraphQL stream to reduce unnecessary API calls
3 participants