private async Task <bool> DownloadSchemaAsync( InitCommandContext context, CancellationToken cancellationToken) { if (context.Uri is null) { return(true); } using IActivity activity = Output.WriteActivity("Download schema"); string schemaFilePath = FileSystem.CombinePath( context.Path, context.SchemaFileName); string schemaExtensionFilePath = FileSystem.CombinePath( context.Path, context.SchemaExtensionFileName); HttpClient client = HttpClientFactory.Create( context.Uri, context.Token, context.Scheme); if (await IntrospectionHelper.DownloadSchemaAsync( client, FileSystem, activity, schemaFilePath, cancellationToken) .ConfigureAwait(false)) { await FileSystem.WriteTextAsync( schemaExtensionFilePath, @"extend schema @key(fields: ""id"")") .ConfigureAwait(false); return(true); } return(false); }
private async Task <bool> DownloadSchemaAsync( DownloadCommandContext context, CancellationToken cancellationToken) { using var activity = Output.WriteActivity("Download schema"); HttpClient client = HttpClientFactory.Create( context.Uri, context.Token, context.Scheme); return(await IntrospectionHelper.DownloadSchemaAsync( client, FileSystem, activity, context.FileName, cancellationToken) .ConfigureAwait(false)); }
private async Task <bool> DownloadSchemaAsync( InitCommandContext context, CancellationToken cancellationToken) { if (context.Uri is null) { return(true); } using IActivity activity = Output.WriteActivity("Download schema"); string schemaFilePath = FileSystem.CombinePath( context.Path, context.SchemaFileName); string schemaExtensionFilePath = FileSystem.CombinePath( context.Path, context.SchemaExtensionFileName); HttpClient client = HttpClientFactory.Create( context.Uri, context.Token, context.Scheme); if (await IntrospectionHelper.DownloadSchemaAsync( client, FileSystem, activity, schemaFilePath, cancellationToken) .ConfigureAwait(false)) { await FileSystem.WriteTextAsync( schemaExtensionFilePath, @"scalar _KeyFieldSet directive @key(fields: _KeyFieldSet!) on SCHEMA | OBJECT directive @serializationType(name: String!) on SCALAR directive @runtimeType(name: String!) on SCALAR directive @enumValue(value: String!) on ENUM_VALUE directive @rename(name: String!) on INPUT_FIELD_DEFINITION | INPUT_OBJECT | ENUM | ENUM_VALUE extend schema @key(fields: ""id"")") .ConfigureAwait(false); return(true); } return(false); }
private async Task <bool> DownloadSchemaAsync( UpdateCommandContext context, Uri serviceUri, string schemaFilePath, CancellationToken cancellationToken) { using IActivity activity = Output.WriteActivity("Download schema"); HttpClient client = HttpClientFactory.Create( context.Uri ?? serviceUri, context.Token, context.Scheme); return(await IntrospectionHelper.DownloadSchemaAsync( client, FileSystem, activity, schemaFilePath, cancellationToken) .ConfigureAwait(false)); }