Customer is not returned by graphql mutation
anders-christiansen opened this issue · 2 comments
anders-christiansen commented
Im trying to create customers using the GraphQL API.
I have the below code, but somehow the response object is a customer with all properties being null values. The customer is created in Shopify though, so that works. Maybe im making some mistake?
public async Task<Customer> CreateCustomerFromInputModelAsync(Register.InputModel inputModel)
{
GraphRequest request = new()
{
query = $@"
mutation customerCreate($input: CustomerInput!) {{
customerCreate(input: $input) {{
customer {{
id
email
firstName
lastName
phone
metafields(first: 10) {{
edges {{
node {{
id
key
value
}}
}}
}}
}}
userErrors {{
field
message
}}
}}
}}
",
variables = new
{
input = new
{
email = inputModel.Email,
firstName = "testname",
}
}
};
var service = _graphServiceFactory.Create(_credentials.Shop_Domain, _credentials.Shop_AccessToken);
var response = await service.SendAsync<Customer>(request);
return response;
}
clement911 commented
The return type passed to the Send method should not be Customer but CustomerCreatePayload
anders-christiansen commented
@clement911 Thanks a lot.