Create GraphQL project (#1334)

* Create new project for GraphQL

* ...

* .

* ok?

* Update src/WireMock.Net.Shared/Extensions/AnyOfExtensions.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* --

* ...

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Stef Heyenrath
2025-08-10 19:00:22 +02:00
committed by GitHub
parent 0d510cdde8
commit 0597a73e0e
38 changed files with 266 additions and 230 deletions

View File

@@ -0,0 +1,18 @@
// Copyright © WireMock.Net
using GraphQL.Types;
using WireMock.Models.GraphQL;
namespace WireMock.Models;
/// <summary>
/// Represents a wrapper for schema data, providing access to the associated schema.
/// </summary>
/// <param name="schema"></param>
public class SchemaDataWrapper(ISchema schema) : ISchemaData
{
/// <summary>
/// Gets the schema associated with the current instance.
/// </summary>
public ISchema Schema { get; } = schema;
}

View File

@@ -0,0 +1,31 @@
// Copyright © WireMock.Net
using System;
using GraphQL.Types;
// ReSharper disable once CheckNamespace
namespace WireMock.GraphQL.Models;
/// <inheritdoc />
public abstract class WireMockCustomScalarGraphType<T> : ScalarGraphType
{
/// <inheritdoc />
public override object? ParseValue(object? value)
{
switch (value)
{
case null:
return null;
case T:
return value;
}
if (value is string && typeof(T) != typeof(string))
{
throw new InvalidCastException($"Unable to convert value '{value}' of type '{typeof(string)}' to type '{typeof(T)}'.");
}
return (T)Convert.ChangeType(value, typeof(T));
}
}