public static unsafe IReadOnlyList <GraphQLRequest> Parse( string sourceText, ParserOptions?options = null, IDocumentCache?cache = null, IDocumentHashProvider?hashProvider = null) { if (string.IsNullOrEmpty(sourceText)) { throw new ArgumentException(SourceText_Empty, nameof(sourceText)); } var length = checked (sourceText.Length * 4); byte[]? source = null; Span <byte> sourceSpan = length <= GraphQLConstants.StackallocThreshold ? stackalloc byte[length] : source = ArrayPool <byte> .Shared.Rent(length); try { Utf8GraphQLParser.ConvertToBytes(sourceText, ref sourceSpan); var parser = new Utf8GraphQLRequestParser(sourceSpan, options, cache, hashProvider); return(parser.Parse()); } finally { if (source != null) { sourceSpan.Clear(); ArrayPool <byte> .Shared.Return(source); } } }
public Utf8GraphQLRequestParser(ReadOnlySpan <byte> requestData) { _options = ParserOptions.Default; _reader = new Utf8GraphQLReader(requestData); _cache = null; _hashProvider = null; _useCache = false; }
public Utf8GraphQLRequestParser( ReadOnlySpan <byte> requestData, ParserOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); _reader = new Utf8GraphQLReader(requestData); _cache = null; _hashProvider = null; _useCache = false; }
public Utf8GraphQLRequestParser( ReadOnlySpan <byte> requestData, ParserOptions options, IDocumentCache cache, IDocumentHashProvider hashProvider) { _options = options ?? throw new ArgumentNullException(nameof(options)); _cache = cache; _hashProvider = hashProvider; _reader = new Utf8GraphQLReader(requestData); _useCache = cache != null; }
public Utf8GraphQLRequestParser( ReadOnlySpan <byte> requestData, ParserOptions?options = null, IDocumentCache?cache = null, IDocumentHashProvider?hashProvider = null) { _reader = new Utf8GraphQLReader(requestData); _options = options ?? ParserOptions.Default; _cache = cache; _hashProvider = hashProvider; _useCache = cache is not null; }
public static bool TryExtractHash( IReadOnlyDictionary <string, object?>?extensions, IDocumentHashProvider?hashProvider, [NotNullWhen(true)] out string?hash) { if (extensions is not null && hashProvider is not null && extensions.TryGetValue(_persistedQuery, out var obj) && obj is IReadOnlyDictionary <string, object> persistedQuery && persistedQuery.TryGetValue(hashProvider.Name, out obj) && obj is string h) { hash = h; return(true); } hash = null; return(false); }
public ClientGenerator SetHashProvider( IDocumentHashProvider hashProvider) { _hashProvider = hashProvider; return(this); }
public DocumentAnalyzer SetHashProvider(IDocumentHashProvider hashProvider) { _hashProvider = hashProvider; return(this); }
public static IReadOnlyList <GraphQLRequest> Parse( ReadOnlySpan <byte> requestData, ParserOptions?options = null, IDocumentCache?cache = null, IDocumentHashProvider?hashProvider = null) => new Utf8GraphQLRequestParser(requestData, options, cache, hashProvider).Parse();