So, Dave, you're sort of right that these fields are not supported..."out of the box"? We just did this for another field type TreeList
which is similar to MultiList
.
You can add fields to the GraphQL service by creating a patch file to modify the Sitecore.Services.GraphQL.Content.config. Under the Content > fieldTypeMappings > inputTypeMapping
section, you add mapping to another field type.
The config patch file could look something like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore>
<api>
<GraphQL>
<defaults>
<content>
<fieldTypeMappings>
<inputTypeMapping type="Sitecore.Services.GraphQL.Content.Mutations.FieldTypeToJsonTypeMapper, Sitecore.Services.GraphQL.Content">
<typeMapping hint="raw:AddTypeMapping">
<map field="treelist" type="Sitecore.Services.GraphQL.Content.Mutations.JsonFields.JsonChecklistField, Sitecore.Services.GraphQL.Content" />
</typeMapping>
</inputTypeMapping>
</fieldTypeMappings>
</content>
</defaults>
</GraphQL>
</api>
</sitecore>
</configuration>
The data need to be sent as an array to add multiple item GUIDs to the field. Your GraphQL query would by similar to this:
mutation UpdateItem {
updateItem(
path: "aaaaaaaa-bbbb-cccc-dddd-5771ad6ed443"
fields: [
{name: "myMultilistFieldName", value: [
"ffffffff-0611-aaaa-8aa9-0b819239a15a",
"eeeeeeee-5fdb-bbbb-a48a-4326b94c7ffa",
"dddddddd-cba4-cccc-a4e9-a3108e538d93",
"cccccccc-e300-dddd-bdd3-6eb182cf8018",
"bbbbbbbb-c2df-eeee-87a5-c90a152f77be",
"aaaaaaaa-c389-ffff-b4b9-62f51f39daa2"
] }
]
)
}
So, when you do your query search, you can see the results list as a string (value) and in an array (targetIds) this way:
Items: items {
Item: item {
id
locationGroup {
value
targetIds
}
}
}
As far as your need to do this for DropLink
, you should be able to just add another field mapping to the same patch config file similar to that of the out-of-the-box general link
mapping:
<map field="droplink" type="Sitecore.Services.GraphQL.Content.Mutations.JsonFields.JsonGeneralLinkField, Sitecore.Services.GraphQL.Content" />
Hope this helps you out.