public GqlQueryProviderTest(GqlClientFixture clientFixture)
        {
            var mapper = new Mock <IGraphTypeNameMapper>();

            mapper.Setup(_ => _.GetTypeName(It.IsAny <Type>())).Returns((Type t) => t.Name);

            var schema = Schema.For(@"
                type Object {
                    id: Int!
                }
                type Query {
                    objects: [Object]
                }");

            queryBuilder = new GqlQueryBuilder(schema, mapper.Object);

            client = clientFixture.CreateClientFor(
                schema,
                new
            {
                objects = new[]
                {
                    new { id = 1 },
                    new { id = 2 },
                    new { id = 3 }
                }
            });
        }
Ejemplo n.º 2
0
        internal GqlContext(Func <IGraphQLClient> clientFactory, ISchemaSource schemaSource)
        {
            queryProvider = new Lazy <GqlQueryProvider>(() =>
            {
                var gqlClient = clientFactory();
                var schema    = schemaSource.GetSchema();

                var mapper       = new GraphTypeMapper(schema, fluentContext);
                var serializer   = GetSerializer(new EntityCache(mapper));
                var queryBuilder = new GqlQueryBuilder(schema, mapper);

                return(new GqlQueryProvider(gqlClient, queryBuilder, serializer));
            });

            fluentContext = new FluentContext();
        }
Ejemplo n.º 3
0
 public GqlQueryProvider(IGraphQLClient client, GqlQueryBuilder queryBuilder, JsonSerializer serializer)
 {
     this.client       = client ?? throw new ArgumentNullException(nameof(client));
     this.queryBuilder = queryBuilder ?? throw new ArgumentNullException(nameof(queryBuilder));
     this.serializer   = serializer ?? throw new ArgumentNullException(nameof(serializer));
 }
Ejemplo n.º 4
0
 public GqlQueryProvider(IGraphQLClient client, GqlQueryBuilder queryBuilder)
     : this(client, queryBuilder, JsonSerializer.CreateDefault())
 {
 }