GraphQL queries & mutations accepting projectPath type it as ID instead of String
Summary
When a queries and mutations accept projectPath
or fullPath
, it usually means "full path to project" e.g. gitlab-org/gitlab
. However, it's also usually typed as ID!
which gives expectation of GID (e.g. gid://gitlab/Project/278964
). Attempting to use GID as fullPath
or projectPath
doesn't work.
Steps to reproduce
- Go to https://gitlab.com/-/graphql-explorer and input the following query:
query {
project(fullPath: "gitlab-org/gitlab") {
id
}
}
- Hover on the text
fullPath
. The tooltip will show thatfullPath
has typeID!
. - Run the query to grab the
id
. Then put it asfullPath
instead. - Run the query again, and notice that it doesn't work.
Example 2:
- Input this query:
mutation createBranch(
$projectPath: ID!,
$name: String!,
$ref: String!
) {
createBranch(input: {
projectPath: $projectPath,
name: $name,
ref: $ref
}) {
errors
}
}
- Hover on
input
, then clickCreateBranchInput
. - Notice that
projectPath
is typed asID!
. - If you actually put GID in here, it won't work.
What is the current bug behavior?
Many arguments or inputs with fullPath
or projectPath
are typed as ID
. Attempting to actually use GID doesn't work.
What is the expected correct behavior?
Those arguments and inputs should be typed as String
instead. Attempting to use GID should probably continue to not work.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Possible fixes
I believe this line of code [1] can be changed to say GraphQL::Types::String
and it will affect many queries. For mutations, more manual work is needed. For example, createBranch
[2] can be changed to say the same.
Of course, I didn't inspect the whole of GraphQL code, so there probably is more places which is similar to this. Also, I have no idea if actually using GraphQL::Types::String
will cause collateral damage anywhere.
[1] https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/graphql/resolvers/full_path_resolver.rb#L8 [2] https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/graphql/mutations/branches/create.rb#L10