在 GraphQL 中报错:Variable “$sessionId” of type “String” used in position expecting type “String!”.
1、在 GraphQL 中报错:Variable “$sessionId” of type “String” used in position expecting type “String!”.。如图1
{
"errors": [
{
"message": "Variable \"$sessionId\" of type \"String\" used in position expecting type \"String!\".",
"extensions": {
"category": "graphql"
},
"locations": [
{
"line": 2,
"column": 163
},
{
"line": 8,
"column": 16
}
]
}
]
}
2、查看请求查询
mutation ThemeUpdate($themeId: ID!, $settings: [ThemeSettingDataInput!], $sections: [ThemeSettingsDataSectionInput!], $appEmbeds: [ThemeSettingsDataBlockInput!], $sessionId: String) {
onlineStoreThemeSettingsDataUpdate(
themeId: $themeId
settings: $settings
sections: $sections
appEmbeds: $appEmbeds
sessionId: $sessionId
) {
sessionId
__typename
}
}
3、查看 GraphQL 文档,$sessionId: String!。缺少了 !。如图2
4、在请求查询中调整后,不再报错。如图3
mutation ThemeUpdate($themeId: ID!, $settings: [ThemeSettingDataInput!], $sections: [ThemeSettingsDataSectionInput!], $appEmbeds: [ThemeSettingsDataBlockInput!], $sessionId: String!) {
onlineStoreThemeSettingsDataUpdate(
themeId: $themeId
settings: $settings
sections: $sections
appEmbeds: $appEmbeds
sessionId: $sessionId
) {
sessionId
__typename
}
}


近期评论