Skip to content

Instantly share code, notes, and snippets.

View mczachurski's full-sized avatar

Marcin Czachurski mczachurski

View GitHub Profile
public class Response
{
public object Data { get; set; }
public string StatusCode { get; set; }
public string ErrorMessage { get; set; }
public Response(object data)
{
StatusCode = "Success";
Data = data;
public class ResponseGraphType<TGraphType> : ObjectGraphType<Response> where TGraphType : GraphType
{
public ResponseGraphType()
{
Name = $"Response{typeof(TGraphType).Name}";
Field(x => x.StatusCode, nullable: true).Description("Status code of the request.");
Field(x => x.ErrorMessage, nullable: true).Description("Error message if requests fails.");
Field<TGraphType>(
{
"data": {
"project": {
"statusCode": "NotFound",
"errorMessage": "Resource not found",
"data": null
},
"projects": {
"statusCode": "Success",
"errorMessage": null,
@mczachurski
mczachurski / graphql-status-codes.json
Last active October 10, 2017 07:52
GraphQL - JSON with status codes
{
"data": {
"project": {
"statusCode": "Success",
"errorMessage": null,
"data": {
"id": "projectA",
"name": "Project A",
"visibleBranches": [
"Latest"