Skip to content

Commit 165ab27

Browse files
author
Adam Fisher
committed
Initial commit
1 parent 8bfbc56 commit 165ab27

6 files changed

Lines changed: 442 additions & 0 deletions

File tree

.gitignore

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
*.swp
2+
*.*~
3+
project.lock.json
4+
.DS_Store
5+
*.pyc
6+
nupkg/
7+
8+
# Visual Studio Code
9+
.vscode
10+
11+
# User-specific files
12+
*.suo
13+
*.user
14+
*.userosscache
15+
*.sln.docstates
16+
17+
# Build results
18+
[Dd]ebug/
19+
[Dd]ebugPublic/
20+
[Rr]elease/
21+
[Rr]eleases/
22+
x64/
23+
x86/
24+
# build/
25+
bld/
26+
[Bb]in/
27+
[Oo]bj/
28+
[Oo]ut/
29+
msbuild.log
30+
msbuild.err
31+
msbuild.wrn
32+
33+
# Visual Studio 2015
34+
.vs/
35+
36+
# MSTest test Results
37+
[Tt]est[Rr]esult*/
38+
[Bb]uild[Ll]og.*
39+
40+
# NUNIT
41+
*.VisualState.xml
42+
TestResult.xml
43+
44+
# Build Results of an ATL Project
45+
[Dd]ebugPS/
46+
[Rr]eleasePS/
47+
dlldata.c
48+
49+
# DNX
50+
project.lock.json
51+
artifacts/
52+
53+
*_i.c
54+
*_p.c
55+
*_i.h
56+
*.ilk
57+
*.meta
58+
*.obj
59+
*.pch
60+
*.pdb
61+
*.pgc
62+
*.pgd
63+
*.rsp
64+
*.sbr
65+
*.tlb
66+
*.tli
67+
*.tlh
68+
*.tmp
69+
*.tmp_proj
70+
*.log
71+
*.vspscc
72+
*.vssscc
73+
.builds
74+
*.pidb
75+
*.svclog
76+
*.scc
77+
78+
# Chutzpah Test files
79+
_Chutzpah*
80+
81+
# Visual C++ cache files
82+
ipch/
83+
*.aps
84+
*.ncb
85+
*.opendb
86+
*.opensdf
87+
*.sdf
88+
*.cachefile
89+
*.VC.db
90+
91+
# Visual Studio profiler
92+
*.psess
93+
*.vsp
94+
*.vspx
95+
*.sap
96+
97+
# TFS 2012 Local Workspace
98+
$tf/
99+
100+
# Guidance Automation Toolkit
101+
*.gpState
102+
103+
# ReSharper is a .NET coding add-in
104+
_ReSharper*/
105+
*.[Rr]e[Ss]harper
106+
*.DotSettings.user
107+
108+
# JustCode is a .NET coding add-in
109+
.JustCode
110+
111+
# TeamCity is a build add-in
112+
_TeamCity*
113+
114+
# DotCover is a Code Coverage Tool
115+
*.dotCover
116+
117+
# NCrunch
118+
_NCrunch_*
119+
.*crunch*.local.xml
120+
nCrunchTemp_*
121+
122+
# MightyMoose
123+
*.mm.*
124+
AutoTest.Net/
125+
126+
# Web workbench (sass)
127+
.sass-cache/
128+
129+
# Installshield output folder
130+
[Ee]xpress/
131+
132+
# DocProject is a documentation generator add-in
133+
DocProject/buildhelp/
134+
DocProject/Help/*.HxT
135+
DocProject/Help/*.HxC
136+
DocProject/Help/*.hhc
137+
DocProject/Help/*.hhk
138+
DocProject/Help/*.hhp
139+
DocProject/Help/Html2
140+
DocProject/Help/html
141+
142+
# Click-Once directory
143+
publish/
144+
# Publish Web Output
145+
*.[Pp]ublish.xml
146+
*.azurePubxml
147+
# but database connection strings (with potential passwords) will be unencrypted
148+
*.publishproj
149+
150+
# NuGet Packages
151+
*.nupkg
152+
# The packages folder can be ignored because of Package Restore
153+
**/packages/*
154+
# except build/, which is used as an MSBuild target.
155+
!**/packages/build/
156+
# Uncomment if necessary however generally it will be regenerated when needed
157+
#!**/packages/repositories.config
158+
159+
# Microsoft Azure Build Output
160+
csx/
161+
*.build.csdef
162+
163+
# Microsoft Azure Emulator
164+
ecf/
165+
rcf/
166+
167+
# Microsoft Azure ApplicationInsights config file
168+
ApplicationInsights.config
169+
170+
# Windows Store app package directory
171+
AppPackages/
172+
BundleArtifacts/
173+
174+
# Visual Studio cache files
175+
# files ending in .cache can be ignored
176+
*.[Cc]ache
177+
# but keep track of directories ending in .cache
178+
!*.[Cc]ache/
179+
180+
# Others
181+
ClientBin/
182+
~$*
183+
*~
184+
*.dbmdl
185+
*.dbproj.schemaview
186+
*.pfx
187+
*.publishsettings
188+
node_modules/
189+
orleans.codegen.cs
190+
191+
# RIA/Silverlight projects
192+
Generated_Code/
193+
194+
# Backup & report files from converting an old project file
195+
# to a newer Visual Studio version. Backup files are not needed,
196+
# because we have git ;-)
197+
_UpgradeReport_Files/
198+
Backup*/
199+
UpgradeLog*.XML
200+
UpgradeLog*.htm
201+
202+
# SQL Server files
203+
*.mdf
204+
*.ldf
205+
206+
# Business Intelligence projects
207+
*.rdl.data
208+
*.bim.layout
209+
*.bim_*.settings
210+
211+
# Microsoft Fakes
212+
FakesAssemblies/
213+
214+
# GhostDoc plugin setting file
215+
*.GhostDoc.xml
216+
217+
# Node.js Tools for Visual Studio
218+
.ntvs_analysis.dat
219+
220+
# Visual Studio 6 build log
221+
*.plg
222+
223+
# Visual Studio 6 workspace options file
224+
*.opt
225+
226+
# Visual Studio LightSwitch build output
227+
**/*.HTMLClient/GeneratedArtifacts
228+
**/*.DesktopClient/GeneratedArtifacts
229+
**/*.DesktopClient/ModelManifest.xml
230+
**/*.Server/GeneratedArtifacts
231+
**/*.Server/ModelManifest.xml
232+
_Pvt_Extensions
233+
234+
# Paket dependency manager
235+
.paket/paket.exe
236+
237+
# FAKE - F# Make
238+
.fake/
239+
240+
#VS config file
241+
/.[Vv]s/*
242+
/[Cc]onfig/*
243+
244+
.svn/
245+
.vs/config/applicationhost.config
246+
*.orig
247+
*.VC.db
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global using Xunit;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="FluentAssertions" Version="6.11.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
14+
<PackageReference Include="xunit" Version="2.4.1" />
15+
<PackageReference Include="xunit.categories" Version="2.0.6" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18+
<PrivateAssets>all</PrivateAssets>
19+
</PackageReference>
20+
<PackageReference Include="coverlet.collector" Version="3.1.2">
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
<PrivateAssets>all</PrivateAssets>
23+
</PackageReference>
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include="..\WaveApps.GraphQLBuilder\WaveApps.GraphQLBuilder.csproj" />
28+
</ItemGroup>
29+
30+
</Project>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System.ComponentModel.DataAnnotations;
2+
using FluentAssertions;
3+
using Xunit.Categories;
4+
5+
namespace WaveApps.GraphQLBuilder.Tests
6+
{
7+
public class WaveQueryBuilderTests
8+
{
9+
[Fact]
10+
[UnitTest]
11+
public void ListBusinesses()
12+
{
13+
var query = new WaveQueryBuilder()
14+
.WithBusinesses(
15+
new BusinessConnectionQueryBuilder()
16+
.WithEdges(new BusinessEdgeQueryBuilder()
17+
.WithNode(new BusinessQueryBuilder()
18+
.WithId()
19+
.WithName())))
20+
.Build();
21+
22+
query.Should().BeEquivalentTo("query{businesses{edges{node{id,name}}}}");
23+
}
24+
25+
[Fact]
26+
[UnitTest]
27+
public void GetUser()
28+
{
29+
var query = new WaveQueryBuilder()
30+
.WithUser(new UserQueryBuilder()
31+
.WithId()
32+
.WithFirstName()
33+
.WithLastName()
34+
.WithDefaultEmail()
35+
.WithCreatedAt()
36+
.WithCreatedAt()
37+
.WithModifiedAt()
38+
).Build();
39+
40+
query.Should().BeEquivalentTo("query{user{id,firstName,lastName,defaultEmail,createdAt,modifiedAt}}");
41+
}
42+
43+
[Fact]
44+
[UnitTest]
45+
public void ListInvoicesByCustomer()
46+
{
47+
var businessIdParameter = new GraphQlQueryParameter<Guid?>("businessId", Guid.Parse("b534b077-5640-4fa1-b8e3-f50da66c8215"));
48+
var sortParameter = new GraphQlQueryParameter<IEnumerable<InvoiceSort>>("sort", $"[{GraphQlTypes.InvoiceSort}!]!", new[] { InvoiceSort.StatusAsc });
49+
var page = new GraphQlQueryParameter<int?>("page", 1);
50+
var pageSize = new GraphQlQueryParameter<int?>("pageSize", 5);
51+
52+
var query = new WaveQueryBuilder()
53+
.WithBusiness(new BusinessQueryBuilder()
54+
.WithId()
55+
.WithInvoices(new InvoiceConnectionQueryBuilder()
56+
.WithPageInfo(new OffsetPageInfoQueryBuilder()
57+
.WithAllFields())
58+
.WithEdges(new InvoiceEdgeQueryBuilder()
59+
.WithNode(new InvoiceQueryBuilder()
60+
.WithId()
61+
.WithInvoiceNumber()
62+
.WithDueDate()
63+
.WithAmountDue(new MoneyQueryBuilder()
64+
.WithAllFields())
65+
.WithTotal(new MoneyQueryBuilder()
66+
.WithAllFields())
67+
.WithStatus()
68+
.WithCustomer(new CustomerQueryBuilder()
69+
.WithEmail())
70+
)),
71+
sortParameter, page: page, pageSize: pageSize),
72+
id: businessIdParameter)
73+
.WithParameter(businessIdParameter)
74+
.WithParameter(page)
75+
.WithParameter(pageSize)
76+
.WithParameter(sortParameter)
77+
.Build();
78+
79+
query.Should().BeEquivalentTo("query($businessId:ID=\"b534b077-5640-4fa1-b8e3-f50da66c8215\",$page:Int=1,$pageSize:Int=5,$sort:[InvoiceSort!]!){business(id:$businessId){id,invoices(page:$page,pageSize:$pageSize,sort:$sort){pageInfo{currentPage,totalPages,totalCount},edges{node{id,invoiceNumber,dueDate,amountDue{minorUnitValue,value,currency{code,symbol,name,plural,exponent}},total{minorUnitValue,value,currency{code,symbol,name,plural,exponent}},status,customer{email}}}}}}");
80+
}
81+
}
82+
}

WaveApps.GraphQLBuilder.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32929.385
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WaveApps.GraphQLBuilder", "WaveApps.GraphQLBuilder\WaveApps.GraphQLBuilder.csproj", "{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaveApps.GraphQLBuilder.Tests", "WaveApps.GraphQLBuilder.Tests\WaveApps.GraphQLBuilder.Tests.csproj", "{0044985F-9DCE-4D07-9F58-F2B084A19896}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{F89AC7BE-40AD-4106-B7E5-CBE09C284DCA}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{0044985F-9DCE-4D07-9F58-F2B084A19896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{0044985F-9DCE-4D07-9F58-F2B084A19896}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{0044985F-9DCE-4D07-9F58-F2B084A19896}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{0044985F-9DCE-4D07-9F58-F2B084A19896}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {E14BA90C-1C26-4508-BFBC-924C05808501}
30+
EndGlobalSection
31+
EndGlobal

0 commit comments

Comments
 (0)