Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Format of Shopify GraphQL responses

Format of Shopify GraphQL responses

vedantpuri
Visitor
1 0 0

Hi,

 

I searched for this in the docs but couldn't find it, is there a defined format of responses we would get from the graphQL queries ?

I realize the bulk and non bulk endpoints have slightly different response formats, and sometimes the errors key can be present alongside the data field and sometimes by itself, which is slightly confusing to me.

I would appreciate if anyone could point me to some documentation about the response formats (Just what fields to be expected in diff scenarios) since it would help me define abstractions around those in my application.

 

Thanks in advance!

Reply 1 (1)

VivekH
Excursionist
12 1 15

Hey @vedantpuri 

Here's the generic response from any GraphQL request (in c#, but you can extend to other languages)-

[DataMember(Name = "data")]
public T Data { get; set; } // Generic type object
[DataMember(Name = "errors")]
public GraphQLError[]? Errors { get; set; }
[DataMember(Name = "extensions")]
public Dictionary<string, object>? Extensions { get; set; }

 

 

GraphQLError model:

//
// Summary:
//     The locations of the error
[DataMember(Name = "locations")]
public GraphQLLocation[]? Locations { get; set; }
//
// Summary:
//     The message of the error
[DataMember(Name = "message")]
public string Message { get; set; }
//
// Summary:
//     The Path of the error
[DataMember(Name = "path")]
public List<object>? Path { get; set; }
//
// Summary:
//     The extensions of the error
[DataMember(Name = "extensions")]
public Dictionary<string, object>? Extensions { get; set; }

 

GraphQLLocation Model:

//
// Summary:
//     The Column
public uint Column { get; set; }
//
// Summary:
//     The Line
public uint Line { get; set; }