(V5.5.6 and later) GraphQL variables
Starting in V5.5.6, the use of GraphQL variables is fully supported.
A placeholder variable can be supplied as the value for any input argument or field while the values of those variables are passed as a separate JSON portion of the request payload. Using the Graphiql UI tool, the variable values can be supplied in a section underneath the main GraphQL section.
Variables can be supplied for top-level arguments to a mutation or query:
mutation DocUpdate(
$repoId:String!,
$docId:String!,
$docProperties:DocumentPropertiesInput!
)
{
updateDocument(
repositoryIdentifier:$repoId,
identifier:$docId,
documentProperties:$docProperties
)
{
id
name
versionStatus
mimeType
}
}
The following JSON variable values can be supplied for the previous
mutation:
{
"repoId":"OS1",
"docId":"/My Folder/Test Document",
"docProperties":{
"name": "Test Document",
"properties":[
{ "DocumentTitle":"Test Document" }
]
}
}
Variables can also be passed as values of lower level fields in a hierarchy of input
types:
mutation DocUpdate(
$repoId:String!,
$docId:String!,
$nm:String!,
$scalarProps:[PropertyIdentifierAndScalarValue!]!
)
{
updateDocument(
repositoryIdentifier:$repoId,
identifier:$docId,
documentProperties:{
name:$nm
properties:$scalarProps
}
)
{
id
name
versionStatus
mimeType
}
}
The following JSON variable values can be supplied for the previous
mutation:
{
"repoId":"OS1",
"docId":"/My Folder/Test Document",
"nm": "Test Document",
"scalarProps":[
{ "DocumentTitle":"Test Document"}
]
}
Variables can be passed as arguments to lower-level fields that are part of the selections that control the output data shaping for a higher-level field.
This example passes the "includes" argument to a properties field as a
variable:
query DocFetch(
$repoId:String!,
$docId:String!,
$includeProps:[String!]
)
{
document(
repositoryIdentifier:$repoId,
identifier:$docId,
)
{
id
name
versionStatus
mimeType
properties(includes:$includeProps) {
id
type
cardinality
value
}
}
}
The following JSON variable values can be supplied for the previous
query:
{
"repoId":"OS1",
"docId":"/My Folder/Test Document",
"includeProps": [
"Id",
"DocumentTitle"
]
}