public GraphQLVisitor(ISchemaProvider schemaProvider, IMethodProvider methodProvider, QueryVariables variables, ClaimsIdentity claims) { this.claims = claims; this.schemaProvider = schemaProvider; this.methodProvider = methodProvider; this.variables = variables; }
public WhatToDoNext DoGetBuildDir(string basis) { query_mode = true; query_var = QueryVariables.BuildDir; query_basis = basis; return(Check(SetMajorMode("variable query") || SetOperation("variable query"))); }
public WhatToDoNext DoGetTopSrcDir() { query_mode = true; query_var = QueryVariables.SrcDir; query_basis = "/"; return(Check(SetMajorMode("variable query") || SetOperation("variable query"))); }
private async Task SaveMediaList(PlexPayload payload, Media anime) { var mutation = @" mutation($mediaId: Int, $status: MediaListStatus, $progress: Int, $score: Float, $startedAt: FuzzyDateInput, $completedAt: FuzzyDateInput){ SaveMediaListEntry (mediaId: $mediaId, status: $status, progress: $progress, score: $score, startedAt: $startedAt, completedAt: $completedAt) { id status } } "; var variables = new QueryVariables(); variables.MediaId = anime.Id; if (!string.IsNullOrEmpty(payload.Rating)) { variables.Score = int.Parse(payload.Rating); } else { var isMovie = payload.Metadata.Type == "movie"; var isCompleted = isMovie ? true : payload.Metadata.Index == anime.Episodes; variables.Status = isCompleted ? MediaListStatus.COMPLETED : MediaListStatus.CURRENT; if (!isCompleted) { variables.Progress = payload.Metadata.Index; } } var queryBody = new QueryBody(mutation, variables); await QueryAnilist(queryBody); }
private async Task <MediaList> SearchMediaList(int userId, Media anime) { var query = @" query($userId: Int, $mediaId: Int){ Page (page: 1, perPage: 50) { pageInfo { total currentPage lastPage hasNextPage perPage } mediaList(userId: $userId, mediaId : $mediaId, type:ANIME){ id status } } } "; var variables = new QueryVariables { UserId = userId, MediaId = anime.Id }; var queryBody = new QueryBody(query, variables); var responseData = await QueryAnilist(queryBody); var anilistReturnData = AnlistReturnData.FromJson(responseData); return(anilistReturnData.Data.Page?.MediaList?.FirstOrDefault()); }
public QueryGrammerNodeVisitor(Expression expression, ISchemaProvider schemaProvider, IMethodProvider methodProvider, QueryVariables variables) { currentContext = (ExpressionResult)expression; this.schemaProvider = schemaProvider; this.methodProvider = methodProvider; this.variables = variables; }
public OperationVisitor(QueryVariables variables, Schema.ISchemaProvider schemaProvider, ClaimsIdentity claims) { this.claims = claims; this.variables = variables; this.schemaProvider = schemaProvider; this.operation = new GraphQLOperation(); }
public EntityQueryNodeVisitor(Expression expression, ISchemaProvider schemaProvider, IMethodProvider methodProvider, QueryVariables variables, ClaimsIdentity claims) { this.claims = claims; currentContext = (ExpressionResult)expression; this.schemaProvider = schemaProvider; this.methodProvider = methodProvider; this.variables = variables; }
/// Parses a GraphQL-like query syntax into a tree respresenting the requested object graph. E.g. /// { /// entity/query { /// field1, /// field2, /// relation { field } /// }, /// ... /// } /// /// The returned DataQueryNode is a root node, it's Fields are the top level data queries public GraphQLResultNode Compile(string query, QueryVariables variables = null) { if (variables == null) { variables = new QueryVariables(); } return(Compile(new QueryRequest { Query = query, Variables = variables })); }
private string GetLabelQuery(string orginaztionName, string repoPage) { var labelQuery = FormatQuery(query); var variables = new QueryVariables(orginaztionName, repoPage); var variablesAsString = stringSerializer.Serialize(variables); var body = $"{{\"query\":\"{labelQuery}\",\"variables\":{variablesAsString}}}"; return(body); }
private string GetLabelQuery(string owner, string repository, string pageId) { var labelQuery = FormatQuery(queryText); var variables = new QueryVariables(owner, repository, pageId); var variablesAsString = stringSerializer.Serialize(variables); var body = $"{{\"query\":\"{labelQuery}\",\"variables\":{variablesAsString}}}"; return(body); }
public static CompiledQueryResult CompileWith(string query, Expression context, ISchemaProvider schemaProvider, IMethodProvider methodProvider = null, QueryVariables variables = null) { if (methodProvider == null) { methodProvider = new DefaultMethodProvider(); } if (variables == null) { variables = new QueryVariables(); } var expression = CompileQuery(query, context, schemaProvider, methodProvider, variables); var parameters = expression.Expression.NodeType == ExpressionType.Lambda ? ((LambdaExpression)expression.Expression).Parameters.ToList() : new List<ParameterExpression>(); return new CompiledQueryResult(expression, parameters); }
private async Task <Media> SearchAnilist(PlexPayload payload) { var query = @" query($search:String, $seasonYear: Int, $format: MediaFormat){ Page (page: 1, perPage: 1) { pageInfo { total currentPage lastPage hasNextPage perPage } media(search:$search, seasonYear:$seasonYear, format: $format, type:ANIME){ id title { romaji } episodes } } } "; if (string.IsNullOrEmpty(payload.Metadata.GrandparentTitle)) { payload.Metadata.GrandparentTitle = null; } var variables = new QueryVariables { Search = payload.Metadata.GrandparentTitle ?? payload.Metadata.ParentTitle ?? payload.Metadata.Title, SeasonYear = payload.Metadata.Year, Format = payload.Metadata.Type == "movie" ? MediaFormat.MOVIE : MediaFormat.TV }; var queryBody = new QueryBody(query, variables); var responseData = await QueryAnilist(queryBody); var anilistReturnData = AnlistReturnData.FromJson(responseData); return(anilistReturnData.Data.Page?.Media?.FirstOrDefault()); }
public OperationVisitor(QueryVariables variables, Schema.ISchemaProvider schemaProvider) { this.variables = variables; this.operation = new GraphQLOperation(); this.constantVisitor = new ConstantVisitor(schemaProvider); }
public OperationVisitor(QueryVariables variables) { this.variables = variables; this.operation = new GraphQLOperation(); }
private static ExpressionResult CompileQuery(string query, Expression context, ISchemaProvider schemaProvider, ClaimsIdentity claims, IMethodProvider methodProvider, QueryVariables variables) { AntlrInputStream stream = new AntlrInputStream(query); var lexer = new EntityGraphQLLexer(stream); var tokens = new CommonTokenStream(lexer); var parser = new EntityGraphQLParser(tokens) { BuildParseTree = true }; var tree = parser.startRule(); var visitor = new QueryGrammerNodeVisitor(context, schemaProvider, methodProvider, variables, claims); var expression = visitor.Visit(tree); return(expression); }
/// <summary> /// Compile a query. /// </summary> /// <param name="query">The query text</param> /// <param name="schemaProvider"></param> /// <param name="methodProvider"></param> /// <returns></returns> public static CompiledQueryResult Compile(string query, ISchemaProvider schemaProvider, ClaimsIdentity claims, IMethodProvider methodProvider, QueryVariables variables) { ParameterExpression contextParam = null; if (schemaProvider != null) { contextParam = Expression.Parameter(schemaProvider.ContextType); } var expression = CompileQuery(query, contextParam, schemaProvider, claims, methodProvider, variables); var contextParams = new List <ParameterExpression>(); if (contextParam != null) { contextParams.Add(contextParam); } return(new CompiledQueryResult(expression, contextParams)); }
public static QueryResult CompileWith(string query, Expression context, ISchemaProvider schemaProvider, IMethodProvider methodProvider, QueryVariables variables) { var expression = CompileQuery(query, context, schemaProvider, methodProvider, variables); var parameters = expression.Expression.NodeType == ExpressionType.Lambda ? ((LambdaExpression)expression.Expression).Parameters.ToList() : new List <ParameterExpression>(); if (expression.ConstantParameters != null) { parameters.AddRange(expression.ConstantParameters.Keys); } return(new QueryResult(expression, parameters, expression.ConstantParameters?.Values)); }
/// <summary> /// Compile a query. /// </summary> /// <param name="query">The query text</param> /// <param name="schemaProvider"></param> /// <param name="methodProvider"></param> /// <returns></returns> public static QueryResult Compile(string query, ISchemaProvider schemaProvider, IMethodProvider methodProvider, QueryVariables variables) { ParameterExpression contextParam = null; if (schemaProvider != null) { contextParam = Expression.Parameter(schemaProvider.ContextType); } var expression = CompileQuery(query, contextParam, schemaProvider, methodProvider, variables); var contextParams = new List <ParameterExpression>(); if (contextParam != null) { contextParams.Add(contextParam); } if (expression.ConstantParameters.Any()) { contextParams.AddRange(expression.ConstantParameters.Keys); } return(new QueryResult(expression, contextParams, expression.ConstantParameters.Values)); }
public QueryBody(string query, QueryVariables variables = null) { Query = query; Variables = variables; }
public WhatToDoNext DoGetTopSrcDir () { query_mode = true; query_var = QueryVariables.SrcDir; query_basis = "/"; return Check (SetMajorMode ("variable query") || SetOperation ("variable query")); }
public GraphQLVisitor(ISchemaProvider schemaProvider, IMethodProvider methodProvider, QueryVariables variables) { this.schemaProvider = schemaProvider; this.methodProvider = methodProvider; this.variables = variables; }
public OperationVisitor(QueryVariables variables, Schema.ISchemaProvider schemaProvider) { this.variables = variables; this.schemaProvider = schemaProvider; this.operation = new GraphQLOperation(); }
public WhatToDoNext DoGetBuildDir (string basis) { query_mode = true; query_var = QueryVariables.BuildDir; query_basis = basis; return Check (SetMajorMode ("variable query") || SetOperation ("variable query")); }