-
-
Notifications
You must be signed in to change notification settings - Fork 231
Create GraphQL project #1334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Create GraphQL project #1334
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e3d579e
Create new project for GraphQL
StefH f5dad15
...
StefH 70f872d
.
StefH 07a950d
Merge branch 'master' into separate-graphql
StefH af1350a
ok?
StefH 3be4db6
Update src/WireMock.Net.Shared/Extensions/AnyOfExtensions.cs
StefH b4adf96
--
StefH 014c3ae
...
StefH f01341d
Merge branch 'master' into separate-graphql
StefH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright © WireMock.Net | ||
|
||
namespace WireMock.Models.GraphQL; | ||
|
||
public interface ISchemaData; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright © WireMock.Net | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
// [assembly: InternalsVisibleTo("WireMock.Net.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")] | ||
|
||
// Needed for Moq in the UnitTest project | ||
// [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] |
94 changes: 94 additions & 0 deletions
94
src/WireMock.Net.GraphQL/RequestBuilders/IRequestBuilderExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright © WireMock.Net | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using GraphQL.Types; | ||
using Stef.Validation; | ||
using WireMock.Matchers; | ||
using WireMock.Matchers.Request; | ||
using WireMock.Models; | ||
using WireMock.Models.GraphQL; | ||
|
||
namespace WireMock.RequestBuilders; | ||
|
||
/// <summary> | ||
/// IRequestBuilderExtensions extensions for GraphQL. | ||
/// </summary> | ||
// ReSharper disable once InconsistentNaming | ||
public static class IRequestBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// WithBodyAsGraphQL: The GraphQL body as a string. | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="schema">The GraphQL schema.</param> | ||
/// <param name="matchBehaviour">The match behaviour. (Default is <c>MatchBehaviour.AcceptOnMatch</c>).</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithGraphQLSchema(this IRequestBuilder requestBuilder, string schema, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageGraphQLMatcher(matchBehaviour, schema)); | ||
} | ||
|
||
/// <summary> | ||
/// WithBodyAsGraphQL: The GraphQL schema as a string. | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="schema">The GraphQL schema.</param> | ||
/// <param name="customScalars">A dictionary defining the custom scalars used in this schema. (optional)</param> | ||
/// <param name="matchBehaviour">The match behaviour. (Default is <c>MatchBehaviour.AcceptOnMatch</c>).</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithGraphQLSchema(this IRequestBuilder requestBuilder, string schema, IDictionary<string, Type>? customScalars, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageGraphQLMatcher(matchBehaviour, schema, customScalars)); | ||
} | ||
|
||
/// <summary> | ||
/// WithBodyAsGraphQL: The GraphQL schema as a <see cref="ISchema"/>. | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="schema">The GraphQL schema.</param> | ||
/// <param name="matchBehaviour">The match behaviour. (Default is <c>MatchBehaviour.AcceptOnMatch</c>).</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithGraphQLSchema(this IRequestBuilder requestBuilder, ISchema schema, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageGraphQLMatcher(matchBehaviour, new SchemaDataWrapper(schema))); | ||
} | ||
|
||
/// <summary> | ||
/// WithBodyAsGraphQL: The GraphQL schema as a <see cref="ISchema"/>. | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="schema">The GraphQL schema.</param> | ||
/// <param name="customScalars">A dictionary defining the custom scalars used in this schema. (optional)</param> | ||
/// <param name="matchBehaviour">The match behaviour. (Default is <c>MatchBehaviour.AcceptOnMatch</c>).</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithGraphQLSchema(this IRequestBuilder requestBuilder, ISchema schema, IDictionary<string, Type>? customScalars, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageGraphQLMatcher(matchBehaviour, new SchemaDataWrapper(schema), customScalars)); | ||
} | ||
|
||
/// <summary> | ||
/// WithBodyAsGraphQL: The GraphQL schema as a <see cref="ISchemaData"/>. | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="schema">The GraphQL schema.</param> | ||
/// <param name="matchBehaviour">The match behaviour. (Default is <c>MatchBehaviour.AcceptOnMatch</c>).</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithGraphQLSchema(this IRequestBuilder requestBuilder, ISchemaData schema, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageGraphQLMatcher(matchBehaviour, schema)); | ||
} | ||
|
||
/// <summary> | ||
/// WithBodyAsGraphQL: The GraphQL schema as a <see cref="ISchemaData"/>. | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="schema">The GraphQL schema.</param> | ||
/// <param name="customScalars">A dictionary defining the custom scalars used in this schema. (optional)</param> | ||
/// <param name="matchBehaviour">The match behaviour. (Default is <c>MatchBehaviour.AcceptOnMatch</c>).</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithGraphQLSchema(this IRequestBuilder requestBuilder, ISchemaData schema, IDictionary<string, Type>? customScalars, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageGraphQLMatcher(matchBehaviour, schema, customScalars)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Description>GraphQL support for WireMock.Net</Description> | ||
<AssemblyTitle>WireMock.Net.Matchers.GraphQL</AssemblyTitle> | ||
<Authors>Stef Heyenrath</Authors> | ||
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net8.0</TargetFrameworks> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<PackageTags>wiremock;matchers;matcher;graphql</PackageTags> | ||
<RootNamespace>WireMock</RootNamespace> | ||
<ProjectGuid>{B6269AAC-170A-4346-8B9A-444DED3D9A45}</ProjectGuid> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> | ||
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>../WireMock.Net/WireMock.Net.snk</AssemblyOriginatorKeyFile> | ||
<!--<DelaySign>true</DelaySign>--> | ||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="GraphQL.NewtonsoftJson" Version="8.2.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> | ||
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\WireMock.Net.Shared\WireMock.Net.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> | ||
<PackageReference Include="Nullable" Version="1.3.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.