public void GetFieldDependencies()
        {
            // arrange
            ISchema schema = Schema.Create(
                FileResource.Open("Stitching.graphql"),
                c =>
            {
                c.RegisterType <DateTimeType>();
                c.RegisterDirective <DelegateDirectiveType>();
                c.Use(next => context => Task.CompletedTask);
            });

            DocumentNode query = Utf8GraphQLParser.Parse(
                FileResource.Open("StitchingQuery.graphql"));

            FieldNode selection = query.Definitions
                                  .OfType <OperationDefinitionNode>().Single()
                                  .SelectionSet.Selections
                                  .OfType <FieldNode>().Single();

            // act
            var fieldDependencyResolver         = new FieldDependencyResolver(schema);
            ISet <FieldDependency> dependencies = fieldDependencyResolver
                                                  .GetFieldDependencies(
                query,
                selection,
                schema.GetType <ObjectType>("Customer"));

            // assert
            Snapshot.Match(dependencies);
        }
Example #2
0
 public ExtractFieldQuerySyntaxRewriter(
     ISchema schema,
     IEnumerable <IQueryDelegationRewriter> rewriters)
 {
     _schema             = schema ?? throw new ArgumentNullException(nameof(schema));
     _dependencyResolver = new FieldDependencyResolver(schema);
     _rewriters          = rewriters.ToArray();
 }