GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - VerifyTests/Verify.GraphQL: Adds Verify support to verify GraphQL.

BranchesTags
Open more actions menu

Latest commit

 

History

81 Commits
81 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
src
src
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
global.json
global.json
 
 
license.txt
license.txt
 
 
readme.md
readme.md
 
 

Repository files navigation

Verify.GraphQL

Discussions Build status NuGet Status

Adds Verify support to verify GraphQL.

See Milestones for release notes.

NuGet

  • https://nuget.org/packages/Verify.GraphQL

Usage

[ModuleInitializer]
public static void Initialize() =>
    VerifyGraphQL.Initialize();

snippet source | anchor

Result with data

[Test]
public Task ExecutionResultWithData()
{
    var result = new ExecutionResult
    {
        Executed = true,
        Data = new Dictionary<string, object?>
        {
            {
                "user", new Dictionary<string, object?>
                {
                    {
                        "name", "John"
                    },
                    {
                        "age", 30
                    }
                }
            }
        }
    };
    return Verify(result);
}

snippet source | anchor

Result:

{
  Data: {
    user: {
      age: 30,
      name: John
    }
  }
}

snippet source | anchor

Result with errors

[Test]
public Task ExecutionResultWithErrors()
{
    var error = new ExecutionError("Some error")
    {
        Path = ["query", "user"]
    };
    error.AddLocation(new(1, 5));

    var result = new ExecutionResult
    {
        Executed = true,
        Errors = [error]
    };
    return Verify(result);
}

snippet source | anchor

Result:

{
  Errors: [
    {
      Message: Some error,
      Locations: [
        {
          Line: 1,
          Column: 5
        }
      ],
      Path: [
        query,
        user
      ]
    }
  ]
}

snippet source | anchor

Result with extensions

[Test]
public Task ExecutionResultWithExtensions()
{
    var result = new ExecutionResult
    {
        Executed = true,
        Data = new Dictionary<string, object?>
        {
            {
                "hello", "world"
            }
        },
        Extensions = new()
        {
            {
                "tracing", "some-trace-data"
            }
        }
    };
    return Verify(result);
}

snippet source | anchor

Result:

{
  Data: {
    hello: world
  },
  Extensions: {
    tracing: some-trace-data
  }
}

snippet source | anchor

Full result

[Test]
public Task ExecutionResultFull()
{
    var error = new ExecutionError("Some error")
    {
        Path = ["query", "user"]
    };
    error.AddLocation(new(1, 5));

    var result = new ExecutionResult
    {
        Executed = true,
        Data = new Dictionary<string, object?>
        {
            {
                "hello", "world"
            }
        },
        Errors = [error],
        Extensions = new()
        {
            {
                "tracing", "some-trace-data"
            }
        }
    };
    return Verify(result);
}

snippet source | anchor

Result:

{
  Errors: [
    {
      Message: Some error,
      Locations: [
        {
          Line: 1,
          Column: 5
        }
      ],
      Path: [
        query,
        user
      ]
    }
  ],
  Data: {
    hello: world
  },
  Extensions: {
    tracing: some-trace-data
  }
}

snippet source | anchor

Not executed result

[Test]
public Task ExecutionResultNotExecuted()
{
    var result = new ExecutionResult
    {
        Executed = false,
        Data = new Dictionary<string, object?>
        {
            {
                "hello", "world"
            }
        }
    };
    return Verify(result);
}

snippet source | anchor

Result:

{}

snippet source | anchor

GraphQL request

[Test]
public Task GraphQLRequest()
{
    var request = new GraphQLRequest
    {
        Query = "{ hero { name } }",
        OperationName = "HeroQuery",
        Variables = new(
            new Dictionary<string, object?>
            {
                {
                    "id", "1"
                }
            }),
        Extensions = new(
            new Dictionary<string, object?>
            {
                {
                    "tracing", true
                }
            })
    };
    return Verify(request);
}

snippet source | anchor

Result:

{
  Query: { hero { name } },
  OperationName: HeroQuery,
  Variables: {
    id: 1
  },
  Extensions: {
    tracing: true
  }
}

snippet source | anchor

Operation message

[Test]
public Task OperationMessage()
{
    var message = new OperationMessage
    {
        Type = "connection_init",
        Id = "1",
        Payload = new Dictionary<string, object?>
        {
            {
                "query", "{ hero { name } }"
            }
        }
    };
    return Verify(message);
}

snippet source | anchor

Result:

{
  Type: connection_init,
  Id: 1,
  Payload: {
    query: { hero { name } }
  }
}

snippet source | anchor

About

Adds Verify support to verify GraphQL.

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.