Exemplo n.º 1
0
        public Task <IReadOnlyList <SchemaVersion> > GetSchemaVersionsByIdAsync(
            [GraphQLType(typeof(NonNullType <ListType <NonNullType <IdType> > >))] string[] ids,
            [Service] IIdSerializer idSerializer,
            [DataLoader] SchemaVersionByIdDataLoader dataLoader,
            CancellationToken cancellationToken)
        {
            if (ids.Length == 0)
            {
                throw new GraphQLException("No ids where provided.");
            }

            var deserializedIds = new Guid[ids.Length];

            for (int i = 0; i < ids.Length; i++)
            {
                IdValue deserializedId = idSerializer.Deserialize(ids[i]);

                if (!deserializedId.TypeName.Equals(nameof(SchemaVersion), StringComparison.Ordinal))
                {
                    throw new GraphQLException("The specified id type is invalid.");
                }

                deserializedIds[i] = (Guid)deserializedId.Value;
            }

            return(dataLoader.LoadAsync(deserializedIds, cancellationToken));
        }
Exemplo n.º 2
0
        public Task <SchemaVersion> GetSchemaVersionByIdAsync(
            [GraphQLType(typeof(NonNullType <IdType>))] string id,
            [Service] IIdSerializer idSerializer,
            [DataLoader] SchemaVersionByIdDataLoader dataLoader,
            CancellationToken cancellationToken)
        {
            IdValue deserializedId = idSerializer.Deserialize(id);

            if (!deserializedId.TypeName.Equals(nameof(SchemaVersion), StringComparison.Ordinal))
            {
                throw new GraphQLException("The specified id type is invalid.");
            }

            return(dataLoader.LoadAsync((Guid)deserializedId.Value, cancellationToken));
        }
 public Task <SchemaVersion> GetSchemaVersionAsync(
     [Parent] SchemaPublishReport report,
     [DataLoader] SchemaVersionByIdDataLoader dataLoader,
     CancellationToken cancellationToken) =>
 dataLoader.LoadAsync(report.SchemaVersionId, cancellationToken);