Feedback on existing schema


#1

Is something about the schema bugging you? :smile: Add your feedback here about existing objects in the schema.

  • Include a sample query with your feedback.
  • How would you prefer the object/connection to work.

#2

Hey, thanks for the great schema! I just had one surprise while exploring it and I thought I’d share it here:

I’m used to using short (~6 character) git SHAs to reference specific commits, whether on the command line or in GitHub comments. But, I found that, when using a GitObjectID as input, it requires the full SHA. Of course, it’s trivial to get the full thing, but I was surprised to need it all, since it’s fairly common to just use the first few characters.

Here’s an example query that doesn’t work:

{
  node(id: "MDEwOlJlcG9zaXRvcnkzMDMzNzE3MA==") {
    ... on Repository {
      commit(oid: "9b6fd30") {
        message 
      }
    }
  }
}

It responds with:

{
  "data": null,
  "errors": [
    {
      "message": "Argument 'oid' on Field 'commit' has an invalid value. Expected type 'GitObjectID!'.",
      "locations": [
        {
          "line": 4,
          "column": 7
        }
      ]
    }
  ]
}

And here’s one that does work:

{
  node(id: "MDEwOlJlcG9zaXRvcnkzMDMzNzE3MA==") {
    ... on Repository {
      commit(oid: "9b6fd302893acf3e7a5fad136d06c25df8591795") {
        message 
      }
    }
  }
}

It responds with:

{
  "data": {
    "node": {
      "commit": {
        "message": "Merge pull request #240 from josh/fix-leaked-global-const\n\nFix leaked global constant"
      }
    }
  }
}

Thanks again, hope that’s helpful!


#3

Great suggestion.

I’d still like to maintain the consistency of the “oid” scalar strictly meaning 20 byte hash. But we should support short sha expansion via a generic git-rev-parse lookup. git-rev-parse supports a number of other noncanonical formats.

Would probably look something like:

fragment on Repository {
  object(expression: "dae86e1950b1277e545cee180551750029cfe735")
  object(expression: "dae86e")
  object(expression: "v1.7.4.2")
  object(expression: "master")
  object(expression: "master@{1}")
}

https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection

Edit Oh, hey, @charliesome had already added this. The argument is expression, instead of revision. Updating my code snippet.


#4

Hi!

I’m very excited about the possibilities the graphql api opens!

Is there a way to get the content of a file? I’m checking the Blob object and it looks like it doesn’t have a “content” field or anything similar. I might be missing the right link.

Thanks!
David


#5

Hey @calavera, sorry for the late reply. You can definitely get the Blob content with text:

{
  node(id: "MDEwOlJlcG9zaXRvcnkyMjIyODQwMg==") {
    ... on Repository {
      object(oid: "29b6327d2e0b31cde05a50ff5af0c8e5faa525f2") {
        oid
        ... on Blob {
          byteSize
          isBinary
          text
        }
      }
    }
  }
}

#6

That makes sense. Thanks @gjtorikian!


#7

is there a way to list a project branches? couldn’t find the Branch entity on the schema. if there’s no Branch yet, when will it be available?


#8

I’d like a way to get the line added/removed count in a PR similar to v3. I wasn’t able to find it on the PR or Commit objects.