Esempio n. 1
0
        public void AnnotateQueryFields()
        {
            // arrange
            string schemaSource = FileResource.Open("Stitching.graphql");
            string querySource  = FileResource.Open("StitchingQuery.graphql");

            ISchema schema = Schema.Create(schemaSource,
                                           c =>
            {
                c.RegisterDirective <SchemaDirectiveType>();
                c.RegisterDirective <DelegateDirectiveType>();
                c.Use(next => ctx => Task.FromResult <object>(null));
            });

            DocumentNode query = Parser.Default.Parse(querySource);

            var context = AnnotationContext.Create(schema);

            // act
            DocumentNode annotatedQuery =
                query.Rewrite <AnnotateQueryRewriter, AnnotationContext>(
                    context);

            // assert
            SerializeQuery(annotatedQuery).Snapshot();
        }