Пример #1
0
        public async Task GetSchemaVersionsById_Invalid_Id_Type()
        {
            // arrange
            var serializer = new IdSerializer();
            var schema     = new Schema(Guid.NewGuid(), "abc", "def");
            await SchemaRepository.AddSchemaAsync(schema);

            var schemaVersion = new SchemaVersion(
                Guid.NewGuid(), schema.Id, "abc", "def",
                Array.Empty <Tag>(), DateTime.UnixEpoch);
            await SchemaRepository.AddSchemaVersionAsync(schemaVersion);

            string id = serializer.Serialize("Foo", schemaVersion.Id);

            // act
            IExecutionResult result = await Executor.ExecuteAsync(
                QueryRequestBuilder.New()
                .SetQuery(
                    @"query($ids: [ID!]!) {
                            schemaVersionsById(ids: $ids) {
                                id
                                sourceText
                            }
                        }")
                .SetVariableValue("ids", new[] { id })
                .Create());

            // assert
            result.MatchSnapshot();
        }
Пример #2
0
        public async Task GetSchemaVersionById()
        {
            // arrange
            var serializer = new IdSerializer();
            var schema     = new Schema(Guid.NewGuid(), "abc", "def");
            await SchemaRepository.AddSchemaAsync(schema);

            var schemaVersion = new SchemaVersion(
                Guid.NewGuid(), schema.Id, "abc", "def",
                Array.Empty <Tag>(), DateTime.UnixEpoch);
            await SchemaRepository.AddSchemaVersionAsync(schemaVersion);

            string id = serializer.Serialize("SchemaVersion", schemaVersion.Id);

            // act
            IExecutionResult result = await Executor.ExecuteAsync(
                QueryRequestBuilder.New()
                .SetQuery(
                    @"query($id: ID!) {
                            schemaVersionById(id: $id) {
                                id
                                sourceText
                            }
                        }")
                .SetVariableValue("id", id)
                .Create());

            // assert
            result.MatchSnapshot(o =>
                                 o.Assert(fo =>
                                          Assert.Equal(id, fo.Field <string>("Data.schemaVersionById.id"))));
        }
Пример #3
0
        public async Task GetSchemaVersionAsNode()
        {
            // arrange
            var serializer = new IdSerializer();
            var schema     = new Schema(Guid.NewGuid(), "abc", "def");
            await SchemaRepository.AddSchemaAsync(schema);

            var schemaVersion = new SchemaVersion(
                Guid.NewGuid(), schema.Id, "abc", DocumentHash.FromSourceText("def"),
                Array.Empty <Tag>(), DateTime.UnixEpoch);
            await SchemaRepository.AddSchemaVersionAsync(schemaVersion);

            string id = serializer.Serialize("SchemaVersion", schemaVersion.Id);

            IFileContainer container = await Storage.CreateContainerAsync(
                schemaVersion.Id.ToString("N", CultureInfo.InvariantCulture));

            byte[] buffer = Encoding.UTF8.GetBytes("SourceTextAbc");
            await container.CreateFileAsync("schema.graphql", buffer, 0, buffer.Length);

            // act
            IExecutionResult result = await Executor.ExecuteAsync(
                QueryRequestBuilder.New()
                .SetQuery(
                    @"query($id: ID!) {
                            node(id: $id) {
                                id
                                ... on SchemaVersion {
                                    sourceText
                                    hash {
                                        hash
                                    }
                                }
                            }
                        }")
                .SetVariableValue("id", id)
                .Create());

            // assert
            result.MatchSnapshot(o =>
                                 o.Assert(fo =>
                                          Assert.Equal(id, fo.Field <string>("Data.node.id"))));
        }
Пример #4
0
        public async Task GetSchemaVersionsById_Invalid_Id_Type()
        {
            // arrange
            var serializer = new IdSerializer();
            var schema     = new Schema(Guid.NewGuid(), "abc", "def");
            await SchemaRepository.AddSchemaAsync(schema);

            var schemaVersion = new SchemaVersion(
                Guid.NewGuid(), schema.Id, "abc", DocumentHash.FromSourceText("def"),
                Array.Empty <Tag>(), DateTime.UnixEpoch);
            await SchemaRepository.AddSchemaVersionAsync(schemaVersion);

            string id = serializer.Serialize("Foo", schemaVersion.Id);

            IFileContainer container = await Storage.CreateContainerAsync(
                schemaVersion.Id.ToString("N", CultureInfo.InvariantCulture));

            byte[] buffer = Encoding.UTF8.GetBytes("SourceTextAbc");
            await container.CreateFileAsync("schema.graphql", buffer, 0, buffer.Length);

            // act
            IExecutionResult result = await Executor.ExecuteAsync(
                QueryRequestBuilder.New()
                .SetQuery(
                    @"query($ids: [ID!]!) {
                            schemaVersionsById(ids: $ids) {
                                id
                                sourceText
                            }
                        }")
                .SetVariableValue("ids", new[] { id })
                .Create());

            // assert
            result.MatchSnapshot();
        }