From a5ff547ecb008d21372e290a9a1fa66594c97979 Mon Sep 17 00:00:00 2001 From: Jovan Popovic Date: Wed, 22 Jul 2020 21:30:28 +0200 Subject: [PATCH] Copied graphql --- RestApi/GraphQL/UriParser.cs | 52 ++++++++++++++++++++++++++++++++++++ RestApi/RestApi.csproj | 32 +++++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 RestApi/GraphQL/UriParser.cs diff --git a/RestApi/GraphQL/UriParser.cs b/RestApi/GraphQL/UriParser.cs new file mode 100644 index 0000000..31976f7 --- /dev/null +++ b/RestApi/GraphQL/UriParser.cs @@ -0,0 +1,52 @@ +// Copyright (c) Jovan Popovic. All Rights Reserved. +// Licensed under the BSD License. See LICENSE.txt in the project root for license information. + +using Microsoft.AspNetCore.Http; +using System; +using TSql.RestApi; + +namespace TSql.GraphQL +{ + +#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP3_0 || NETCOREAPP3_1 + + using GraphQLParser; + using GraphQLParser.AST; + + public class UriParser + { + public static QuerySpec Parse (TableSpec tabSpec, HttpRequest Request) + { + var spec = new QuerySpec(); + + var parser = new Parser(new Lexer()); + GraphQLDocument document = parser.Parse(new Source(Request.Body.ToString())); + + /* + GraphQLFieldSelection selection = GetSelection(document); + BuildSelectExpandClause(spec, selection.SelectionSet); + BuildFilterClause(spec, selection); + LiftRequiredSingleNavigationPropertyFilter(spec); + */ + + + + + + spec.skip = Convert.ToInt32(Request.Query["start"]); + spec.top = Convert.ToInt32(Request.Query["length"]); + spec.select = null;//JQuery datatables don't provide column list. + if (Request.Query.ContainsKey("$systemat")) + { + spec.systemTimeAsOf = Request.Query["$systemat"]; + DateTime asof; + if (!DateTime.TryParse(spec.systemTimeAsOf, out asof)) + throw new ArgumentException(spec.systemTimeAsOf + " is not valid date."); + } + tabSpec.Validate(spec, true); + return spec; + } + + } +#endif +} \ No newline at end of file diff --git a/RestApi/RestApi.csproj b/RestApi/RestApi.csproj index 1324c3e..6f185c5 100644 --- a/RestApi/RestApi.csproj +++ b/RestApi/RestApi.csproj @@ -1,7 +1,7 @@  - net46;netstandard1.6;netstandard2.0;netcoreapp1.0;netcoreapp1.1;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1 + netcoreapp3.1;net46;netstandard1.6;netstandard2.0;netcoreapp1.0;netcoreapp1.1;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0 TSql.RestApi true Apache-2.0 @@ -54,4 +54,34 @@ + + + 5.1.2 + + + + + + 5.1.2 + + + + + + 5.1.2 + + + + + + 5.1.2 + + + + + + 5.1.2 + + +