我正在尝试调用Shopify storefront
GraphQL来创建客户。正在成功创建客户。但是,它不设置为突变提供的电话号码。
突变:
const String customerCreateMutation = r'''
mutation MyMutation($firstName: String, $lastName: String, $email: String!, $password: String!) {
customerCreate(input: {firstName: $firstName, lastName: $lastName, email: $email, password: $password}) {
customer{
acceptsMarketing
createdAt
tags
displayName
email
firstName
id
lastName
phone
}
customerUserErrors {
code
field
message
}
}
}
''';
Graphql:
final MutationOptions _options = MutationOptions(
document: gql(customerCreateMutation),
variables: {
'firstName': "john",
'lastName':"doe",
'email':"[email protected]",
'password': "password",
'acceptsMarketing': false,
'phone': "9876543211", /// tried as "+919876543211" too
},
);
final QueryResult result = await _graphQLClient!.mutate(_options);
当我在结果中打印客户时,我得到的是result.data['customerCreate']['customer']
,我可能得到的是null。
{__typename: Customer, acceptsMarketing: false, createdAt: 2023-10-19T12:56:35Z, tags: [], displayName: asdasd asdasd, email: [email protected], firstName: asdasd, id: ********, lastName: asdasd, phone: null, lastIncompleteCheckout: null}
在这里,它将电话作为null发送回去。
我也检查了Shopify商店中创建的客户。但它也是空白的。
如何设置客户的电话号码?还有别的办法吗
1条答案
按热度按时间z9gpfhce1#
Shopify店面GraphQL API在
customerCreate
突变中使用E.164 standard.
作为电话号码这意味着你需要添加
[+] [country code] [number]
,然后它将接受电话号码。尝试添加
+91
我认为你在突变定义中错过了
phone
变量如有疑问,请评论。