-
Notifications
You must be signed in to change notification settings - Fork 70
Gitlab graphql API
query fileslist {
project(fullPath: "gitlab-org/gitlab-foss") {
repository {
tree(recursive: true) {
blobs {
edges {
node {
type
name
path
}
}
}
trees {
edges {
node {
type
path
name
}
}
}
}
}
}
}query directorylist {
project(fullPath: "gitlab-org/gitlab-foss") {
webUrl
path
repository {
paginatedTree(path: ".gitlab/ci", recursive: true) {
nodes {
trees {
nodes {
path
}
}
}
}
diskPath
}
}
}
query directorylist {
project(fullPath: "gitlab-org/gitlab-foss") {
webUrl
path
repository {
paginatedTree(path: "config", recursive: true) {
nodes {
trees {
nodes {
path
}
}
}
}
diskPath
}
}
}recursive: true is an optional argument. If this argument is not given, only the contents of the directory are given.
query filecontents {
project(fullPath: "gitlab-org/gitlab-foss") {
repository {
blobs(paths: [".codeclimate.yml"]) {
nodes {
name
rawBlob
rawTextBlob
}
}
}
}
}Quite a few microservices shall use gitlab graphql schema. It would be better to use gitlab graphql schema and make the code using schema first approach.
Use the tutorial here to get complete gitlab graphql schema from schema explorer
GitLab GraphQL Schema has a bug. Apparently, the id of a tree entry cannot be expected to have a unique identifier despite the documentation.
In query
query gitLabDirectoryListQuery(
$path: String!
$groupAndProject: ID!
) {
project(fullPath: $groupAndProject) {
repository {
paginatedTree(path: $path, recursive: false) {
nodes {
trees {
nodes {
name
path
id
}
}
}
}
}
}
}with variables
{
"path": "Data",
"groupAndProject" : "dtaas/user1",
}We get this response:
{
"data": {
"project": {
"repository": {
"paginatedTree": {
"nodes": [
{
"trees": {
"nodes": [
{
"name": "MyDopeData",
"path": "Data/MyDopeData",
"id": "gid://gitlab/Gitlab::Graphql::Representation::TreeEntry/f93e3a1a1525fb5b91020da86e44810c87a2d7bc"
},
{
"name": "OtherData",
"path": "Data/OtherData",
"id": "gid://gitlab/Gitlab::Graphql::Representation::TreeEntry/f93e3a1a1525fb5b91020da86e44810c87a2d7bc"
}
]
}
}
]
}
}
}
}
}You would expect the id of a node to be unique, but it may not be so.
The entries for dtaas and dtaas1 have the same ID, which should be impossible. The GitLab team knows this.
For a context and setup to recreate the problem, please see PR-78