Esempio n. 1
0
        public static void Build(CommandLineApplication download)
        {
            download.Description = "Download the schema as GraphQL SDL";

            CommandArgument uriArg = download.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption fileNameArg = download.Option(
                "-f|--FileName",
                "The file name to store the schema SDL.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = download.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            AuthArguments authArguments = download.AddAuthArguments();

            download.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new DownloadCommandArguments(
                    uriArg,
                    fileNameArg,
                    authArguments);
                DownloadCommandHandler handler =
                    CommandTools.CreateHandler <DownloadCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });
        }
Esempio n. 2
0
        public static CommandLineApplication Create()
        {
            var generate = new CommandLineApplication();

            generate.AddName("compile");
            generate.AddHelp <CompileHelpTextGenerator>();

            CommandOption pathArg = generate.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption searchArg = generate.Option(
                "-s|--search",
                "Search for client directories.",
                CommandOptionType.NoValue);

            CommandOption jsonArg = generate.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            generate.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new CompileCommandArguments(pathArg, searchArg);
                var handler   = CommandTools.CreateHandler <CompileCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(generate);
        }
Esempio n. 3
0
        public static void Build(CommandLineApplication update)
        {
            update.Description = "Update local schema";

            CommandOption pathArg = update.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption urlArg = update.Option(
                "-u|--uri",
                "The URL to the GraphQL endpoint.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = update.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            AuthArguments authArguments = update.AddAuthArguments();

            update.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new UpdateCommandArguments(urlArg, pathArg, authArguments);
                UpdateCommandHandler handler = CommandTools.CreateHandler <UpdateCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });
        }
Esempio n. 4
0
        public static CommandLineApplication Create()
        {
            var init = new CommandLineApplication();

            init.AddName("update");
            init.AddHelp <UpdateHelpTextGenerator>();

            CommandOption pathArg = init.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption urlArg = init.Option(
                "-u|--uri",
                "The URL to the GraphQL endpoint.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = init.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            AuthArguments authArguments = init.AddAuthArguments();

            init.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new UpdateCommandArguments(urlArg, pathArg, authArguments);
                var handler   = CommandTools.CreateHandler <UpdateCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(init);
        }
Esempio n. 5
0
        public static CommandLineApplication Create()
        {
            var generate = new CommandLineApplication();

            generate.AddName("generate");
            generate.AddHelp <GenerateHelpTextGenerator>();

            CommandOption pathArg = generate.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption languageArg = generate.Option(
                "-l|--LanguageVersion",
                "The C# Language Version (7.3 or 8.0).",
                CommandOptionType.SingleValue);

            CommandOption diSupportArg = generate.Option(
                "-d|--DISupport",
                "Generate dependency injection integration for " +
                "Microsoft.Extensions.DependencyInjection.",
                CommandOptionType.NoValue);

            CommandOption namespaceArg = generate.Option(
                "-n|--Namespace",
                "The namespace that shall be used for the generated files.",
                CommandOptionType.SingleValue);

            CommandOption persistedQueriesArg = generate.Option(
                "-q|--PersistedQueryFile",
                "The persisted query file.",
                CommandOptionType.SingleValue);

            CommandOption searchArg = generate.Option(
                "-s|--search",
                "Search for client directories.",
                CommandOptionType.NoValue);

            CommandOption forceArg = generate.Option(
                "-f|--Force",
                "Force code generation even if nothing has changed.",
                CommandOptionType.NoValue);

            CommandOption jsonArg = generate.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            generate.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new GenerateCommandArguments(
                    pathArg, languageArg, diSupportArg, namespaceArg,
                    persistedQueriesArg, searchArg, forceArg);
                var handler = CommandTools.CreateHandler <GenerateCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(generate);
        }
        public static CommandLineApplication Create()
        {
            var publish = new CommandLineApplication();

            publish.AddName("schema");
            //publish.AddHelp<InitHelpTextGenerator>();

            CommandArgument registryArg = publish.Argument(
                "registry",
                "The URL to the GraphQL schema registry.",
                c => c.IsRequired());

            CommandArgument environmentNameArg = publish.Argument(
                "environmentName",
                "The name of the environment.",
                c => c.IsRequired());

            CommandArgument schemaNameArg = publish.Argument(
                "schemaName",
                "The name of the schema.",
                c => c.IsRequired());

            CommandArgument schemaFileNameArg = publish.Argument(
                "schemaFileName",
                "The schema file name.",
                c => c.IsRequired());

            CommandOption tagArg = publish.Option(
                "-t|--tag",
                "A custom tag that can be passed to the schema registry.",
                CommandOptionType.MultipleValue);

            CommandOption jsonArg = publish.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            AuthArguments authArguments = publish.AddAuthArguments();

            publish.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new PublishSchemaCommandArguments(
                    registryArg,
                    schemaNameArg,
                    environmentNameArg,
                    schemaFileNameArg,
                    tagArg,
                    authArguments);
                var handler = CommandTools.CreateHandler <PublishSchemaCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(publish);
        }
Esempio n. 7
0
        public static CommandLineApplication Create()
        {
            var init = new CommandLineApplication();

            init.AddName("init");
            init.AddHelp <InitHelpTextGenerator>();

            CommandArgument uriArg = init.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption pathArg = init.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption schemaArg = init.Option(
                "-n|--SchemaName",
                "The schema name.",
                CommandOptionType.SingleValue);

            CommandOption tokenArg = init.Option(
                "-t|--token",
                "The token that shall be used to autheticate with the GraphQL server.",
                CommandOptionType.SingleValue);

            CommandOption schemeArg = init.Option(
                "-s|--scheme",
                "The token scheme (defaul: bearer).",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = init.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            init.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new InitCommandArguments(
                    uriArg, pathArg, schemaArg, tokenArg, schemeArg);
                var handler = CommandTools.CreateHandler <InitCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(init);
        }
Esempio n. 8
0
        public static void Build(CommandLineApplication init)
        {
            init.Description = "Initialize project and download schema";

            CommandArgument uriArg = init.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption pathArg = init.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption nameArg = init.Option(
                "-n|--clientName",
                "The GraphQL client name.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = init.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            CommandOption headersArg = init.Option(
                "-x|--headers",
                "Custom headers used in request to Graph QL server. " +
                "Can be used mulitple times. Example: --headers key1=value1 --headers key2=value2",
                CommandOptionType.MultipleValue);

            AuthArguments authArguments = init.AddAuthArguments();

            init.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new InitCommandArguments(
                    uriArg,
                    pathArg,
                    nameArg,
                    authArguments,
                    headersArg);
                InitCommandHandler handler =
                    CommandTools.CreateHandler <InitCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });
        }
Esempio n. 9
0
        public static CommandLineApplication Create()
        {
            var init = new CommandLineApplication();

            init.AddName("init");
            init.AddHelp <InitHelpTextGenerator>();

            CommandArgument uriArg = init.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption pathArg = init.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption nameArg = init.Option(
                "-n|--clientName",
                "The GraphQL client name.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = init.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            AuthArguments authArguments = init.AddAuthArguments();

            init.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new InitCommandArguments(
                    uriArg,
                    pathArg,
                    nameArg,
                    authArguments);
                InitCommandHandler handler =
                    CommandTools.CreateHandler <InitCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(init);
        }
Esempio n. 10
0
        public static void Build(CommandLineApplication download)
        {
            download.Description = "Download the schema as GraphQL SDL";

            CommandArgument uriArg = download.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption fileNameArg = download.Option(
                "-f|--FileName",
                "The file name to store the schema SDL.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = download.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            CommandOption headersArg = download.Option(
                "-x|--headers",
                "Custom headers used in request to Graph QL server. " +
                "Can be used mulitple times. Example: --headers key1=value1 --headers key2=value2",
                CommandOptionType.MultipleValue);

            AuthArguments authArguments = download.AddAuthArguments();

            download.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new DownloadCommandArguments(
                    uriArg,
                    fileNameArg,
                    authArguments,
                    headersArg);
                DownloadCommandHandler handler =
                    CommandTools.CreateHandler <DownloadCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });
        }
Esempio n. 11
0
        public static void Build(CommandLineApplication update)
        {
            update.Description = "Update local schema";

            CommandOption pathArg = update.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption urlArg = update.Option(
                "-u|--uri",
                "The URL to the GraphQL endpoint.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = update.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            CommandOption headersArg = update.Option(
                "-x|--headers",
                "Custom headers used in request to Graph QL server. " +
                "Can be used mulitple times. Example: --headers key1=value1 --headers key2=value2",
                CommandOptionType.MultipleValue);

            AuthArguments authArguments = update.AddAuthArguments();

            update.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new UpdateCommandArguments(
                    urlArg,
                    pathArg,
                    authArguments,
                    headersArg);
                UpdateCommandHandler handler = CommandTools.CreateHandler <UpdateCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });
        }
Esempio n. 12
0
        public static CommandLineApplication Create()
        {
            var download = new CommandLineApplication();

            download.AddName("download");
            download.AddHelp <InitHelpTextGenerator>();

            CommandArgument uriArg = download.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption fileNameArg = download.Option(
                "-f|--FileName",
                "The file name to store the schema SDL.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = download.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            AuthArguments authArguments = download.AddAuthArguments();

            download.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new DownloadCommandArguments(
                    uriArg,
                    fileNameArg,
                    authArguments);
                DownloadCommandHandler handler =
                    CommandTools.CreateHandler <DownloadCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(download);
        }
        public static CommandLineApplication Create()
        {
            var publish = new CommandLineApplication();

            publish.AddName("client");
            //publish.AddHelp<InitHelpTextGenerator>();

            CommandArgument registryArg = publish.Argument(
                "registry",
                "The URL to the GraphQL schema registry.",
                c => c.IsRequired());

            CommandArgument environmentNameArg = publish.Argument(
                "environmentName",
                "The name of the environment.",
                c => c.IsRequired());

            CommandArgument schemaNameArg = publish.Argument(
                "schemaName",
                "The name of the schema.",
                c => c.IsRequired());

            CommandArgument clientNameArg = publish.Argument(
                "clientName",
                "The name of the client.",
                c => c.IsRequired());

            CommandArgument externalId = publish.Argument(
                "externalId",
                "An external identifier to track the schema through the publish process.",
                c => c.IsRequired());

            CommandOption searchDirectoryArg = publish.Option(
                "-d|--searchDirectory",
                "Files containing queries.",
                CommandOptionType.MultipleValue);

            CommandOption queryFileNameArg = publish.Option(
                "-f|--queryFileName",
                "Files containing queries.",
                CommandOptionType.MultipleValue);

            CommandOption relayFileFormatArg = publish.Option(
                "-r|--relayFileFormat",
                "Defines that the files are in the relay persisted query file format.",
                CommandOptionType.NoValue);

            CommandOption tagArg = publish.Option(
                "-t|--tag",
                "A custom tag that can be passed to the schema registry.",
                CommandOptionType.MultipleValue);

            CommandOption publishedArg = publish.Option(
                "-p|--published",
                "A custom tag that can be passed to the schema registry.",
                CommandOptionType.NoValue);

            CommandOption jsonArg = publish.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            AuthArguments authArguments = publish.AddAuthArguments();

            publish.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new PublishClientCommandArguments(
                    registryArg,
                    externalId,
                    environmentNameArg,
                    schemaNameArg,
                    clientNameArg,
                    searchDirectoryArg,
                    queryFileNameArg,
                    relayFileFormatArg,
                    tagArg,
                    publishedArg,
                    authArguments);
                var handler = CommandTools.CreateHandler <PublishClientCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(publish);
        }