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

Github GraphQL #178

Draft
wants to merge 2 commits into
base: principale
Choose a base branch
from
Draft

Github GraphQL #178

wants to merge 2 commits into from

Conversation

DavidBruant
Copy link
Contributor

Dans un autre contexte, j'ai besoin de faire du GraphQL
Et vu que je connais pas, je me suis dis que j'allais apprendre
Et j'ai découvert que Github avait une API GraphQL, donc, je me suis dis que j'allais voir ce que ça donnait sur Scribouilli

Le premier commit a été un peu laborieux parce que je découvrais, mais en vrai, ça a l'air facile

J'imagine que tout traduire en GraphQL serait assez facile, mais je ne sais pas si ça a trop de valeur vu que nos appels sont assez simples
À l'exception peut-être de getPagesWebsiteDeploymentStatus qui fait 2 appels successifs et j'imagine que ça serait moins laborieux en une requête GraphQL unique (et j'imagine que ça résoudrai le problème du cache directement aussi vu qu'il n'y a pas de cache HTTP en GraphQL)

Un autre avantage, c'est qu'en GraphQL, on contrôle ce que l'API retourne et donc on peut être assez minimalistes (là où l'API REST balance des floppées d'information dont on n'a pas besoin par défaut)

Lors du premier commit, les appels REST et GraphQL cohabitent et ça n'a pas l'air d'être un problème du tout

}`

return this.graphQLCall(query)
.then(resp => resp.data.repository.deployments.nodes[0].statuses.nodes[0].state.toLowerString())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

on a troqué un gloubiboulga de .then et response.json()
contre cette ligne un peu affreuse (et la requête ci-dessus qui est plutôt cool)

.then(response => response.json())
.then(json => {
const statusesUrl = json[0].statuses_url
const [owner, name] = repoId.split('/')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

l'histoire du repoId marchait bien avec les URLs REST, mais moins bien avec les requêtes GraphQL

Voir #174 pour une solution

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.

1 participant