Code Monkey home page Code Monkey logo

codacy-github-graphql's Introduction

codacy-github-graphql

Codacy Badge CircleCI Download

Library with Apollo compiled queries and models for GitHub API V4

Build

sbt compile

Usage

Look for queries under package com.github.api.v4._ and use com.codacy.graphql.apollo.client.ScalaApolloClient to get futures instead of callbacks from the ApolloClient.

Example

import java.net.URL

import com.github.api.v4.ListProjectMembershipsQuery
import com.codacy.graphql.apollo.client.ScalaApolloClient

import scala.collection.JavaConverters._
import scala.compat.java8.OptionConverters._
import scala.concurrent.duration._

val client = ScalaApolloClient(new URL("https://api.example.com/graphql"))
// val client = ScalaApolloClient(new URL("https://api.example.com/graphql"), okHttpClient)
// val client = ScalaApolloClient(apolloClient)

val queryMemberships = ListProjectMembershipsQuery
  .builder()
  .ownerName("codacy")
  .repositoryName("codacy-eslint")
  .build()
val result = client.execute(queryMemberships)

val data = result.map { res =>
    for {
      data <- res.data().asScala
      repositoryEntries <- data.repositoryEntries().asScala
      collaborators <- repositoryEntries.collaborators().asScala
      nodes <- collaborators.nodes().asScala.map(_.asScala)
    } yield nodes.map(c => (c.databaseId().asScala, c.login(), Option(c.email()).filter(_.nonEmpty)))
}

FAQ

  1. How to add a new query?

    • Create file in src/main/graphql/com/github/api/v4 with the query
    • Check if any new scalar is needed. Look in com.github.api.v4.type.CustomType if all the types there already have CustomTypeAdapter that is linked in com.codacy.graphql.apollo.client.ApolloClient (look for a addCustomTypeAdapter)
  2. How to add a CustomTypeAdapter?

    • Check what is the original type of the scalar in the src/main/graphql/com/github/api/v4/schema.graphql (e.g.: Date in a string format, long, ...)
    • Check package com.codacy.graphql.adapter for examples and possible implementations for existing API types
    • Add invocation of addCustomTypeAdapter when creating the com.codacy.graphql.apollo.client.ApolloClient
  3. How to handle Inline Fragments?

    • The visitor provided by the generator should help but for some reason it is not being generated. For now, since they can be of multiple types you need to check the instance type and to cast :(

What is Codacy

Codacy is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.

Among Codacy’s features

  • Identify new Static Analysis issues
  • Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
  • Auto-comments on Commits and Pull Requests
  • Integrations with Slack, HipChat, Jira, YouTrack
  • Track issues Code Style, Security, Error Proneness, Performance, Unused Code and other categories

Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.

Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others.

Free for Open Source

Codacy is free for Open Source projects.

codacy-github-graphql's People

Contributors

andreatp avatar josemiguelmelo avatar lolgab avatar lucassklp avatar machadoit avatar pedrocodacy avatar rtfpessoa avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.