Esempio n. 1
0
        public async Task <ISchemaFeatures> GetSchemaFeaturesAsync(
            HttpClient client,
            CancellationToken cancellationToken = default)
        {
            if (client is null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            HttpQueryRequest request = IntrospectionQueryHelper.CreateFeatureQuery();

            IntrospectionResult result = await ExecuteIntrospectionAsync(
                client, request, cancellationToken)
                                         .ConfigureAwait(false);

            EnsureNoGraphQLErrors(result);

            return(SchemaFeatures.FromIntrospectionResult(result));
        }
Esempio n. 2
0
        internal static SchemaFeatures FromIntrospectionResult(
            IntrospectionResult result)
        {
            var      features  = new SchemaFeatures();
            FullType directive = result.Data.Schema.Types.First(t =>
                                                                t.Name.Equals(_directiveName, StringComparison.Ordinal));

            features.HasRepeatableDirectives = directive.Fields.Any(t =>
                                                                    t.Name.Equals(_isRepeatable, StringComparison.Ordinal));
            features.HasDirectiveLocations = directive.Fields.Any(t =>
                                                                  t.Name.Equals(_locations, StringComparison.Ordinal));

            FullType schema = result.Data.Schema.Types.First(t =>
                                                             t.Name.Equals(_schemaName, StringComparison.Ordinal));

            features.HasSubscriptionSupport = schema.Fields.Any(t =>
                                                                t.Name.Equals(_subscriptionType, StringComparison.Ordinal));

            return(features);
        }