Skip to content

Commit f68195f

Browse files
author
Raul Hidalgo Caballero
committed
FileExtensions
1 parent 825881a commit f68195f

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/GraphQL.Client/GraphQL.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<Import Project="../src.props" />
55

66
<PropertyGroup>
7-
<TargetFrameworks>netstandard1.1;netstandard2.0</TargetFrameworks>
7+
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<ProjectReference Include="..\GraphQL.Common\GraphQL.Common.csproj" />
11+
<ProjectReference Include="..\GraphQL.Common\GraphQL.Common.csproj" />
1212
</ItemGroup>
1313

1414
</Project>

src/GraphQL.Client/GraphQLClientExtensions.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.IO;
12
using System.Threading.Tasks;
23
using GraphQL.Common.Request;
34
using GraphQL.Common.Response;
@@ -95,7 +96,7 @@ fragment TypeRef on __Type {
9596
}
9697
}
9798
}
98-
}".Replace("\t","").Replace("\n", "").Replace("\r", ""),
99+
}".Replace("\t", "").Replace("\n", "").Replace("\r", ""),
99100
Variables = null
100101
};
101102

@@ -115,6 +116,24 @@ public static async Task<GraphQLResponse> GetIntrospectionQueryAsync(this GraphQ
115116
public static async Task<GraphQLResponse> PostIntrospectionQueryAsync(this GraphQLClient graphQLClient) =>
116117
await graphQLClient.PostAsync(IntrospectionQuery).ConfigureAwait(false);
117118

119+
/// <summary>
120+
/// Send the Query defined in a file via GET
121+
/// </summary>
122+
/// <param name="graphQLClient">The GraphQLClient</param>
123+
/// <param name="filePath">The Path of the File</param>
124+
/// <returns>The GraphQLResponse</returns>
125+
public static async Task<GraphQLResponse> GetFromFile(this GraphQLClient graphQLClient, string filePath) =>
126+
await graphQLClient.GetQueryAsync(File.ReadAllText(filePath)).ConfigureAwait(false);
127+
128+
/// <summary>
129+
/// Send the Query defined in a file via POST
130+
/// </summary>
131+
/// <param name="graphQLClient">The GraphQLClient</param>
132+
/// <param name="filePath">The Path of the File</param>
133+
/// <returns>The GraphQLResponse</returns>
134+
public static async Task<GraphQLResponse> PostFromFile(this GraphQLClient graphQLClient, string filePath) =>
135+
await graphQLClient.PostQueryAsync(File.ReadAllText(filePath)).ConfigureAwait(false);
136+
118137
}
119138

120139
}

0 commit comments

Comments
 (0)