public SchemaBuilder Import(ISchema from) { MergeTool.Schema(this, from); return(this); }
public SchemaBuilder Import(params ISchema[] schemas) { MergeTool.Schemas(this, schemas); return(this); }
public async Task Execute_with_StaticLink() { /* Given */ var schemaOneBuilder = new SchemaBuilder() .Sdl( @" type User { id: ID! name: String! } type Query { userById(id: ID!): User } schema { query: Query } "); var schemaTwoBuilder = new SchemaBuilder() .Sdl( @" type Address { city: String! } type User { address: Address! } type Query { } " ); var schemaOne = RemoteSchemaTools.MakeRemoteExecutable( schemaOneBuilder, RemoteLinks.Static(new ExecutionResult { Data = new Dictionary <string, object> { ["userById"] = new Dictionary <string, object> { ["id"] = "1", ["name"] = "name" } } })); var schemaTwo = SchemaTools.MakeExecutableSchema( schemaTwoBuilder, new ResolverMap { ["Address"] = new FieldResolverMap { { "city", context => ResolveSync.As(context.ObjectValue) } }, ["User"] = new FieldResolverMap { { "address", context => ResolveSync.As("Vantaa") } } }); var schema = MergeTool.MergeSchemas(schemaTwo, schemaOne); /* When */ var result = await Executor.ExecuteAsync(new ExecutionOptions { Schema = schema, Document = Parser.ParseDocument(@" { userById(id: ""1"") { id name address { city } } }") }); /* Then */ result.ShouldMatchJson( @" { ""data"": { ""userById"": { ""address"": { ""city"": ""Vantaa"" }, ""name"": ""name"", ""id"": ""1"" } } } "); }
public ToolConfigurationProvider(IRepository repository) { this.repository = repository; editorTool = new Lazy <string>(() => LocateEditor()); diffTool = new Lazy <DiffTool>(() => { DiffTool?tool = default; var toolName = repository.Config.GetValueOrDefault("diff.tool", default(string)); if (!string.IsNullOrEmpty(toolName)) { // NOTE: we only support cmd-specified tools, since we need to do the replacements of // $BASE $LOCAL $REMOTE and $MERGED ourselves and otherwise wouldn't know the order. tool = repository.Config.Read <DiffTool>("difftool", toolName); } if (string.IsNullOrEmpty(tool?.Cmd)) { var toolCmd = LocateCode() ?? throw new ArgumentException("Cannot determine default diff tool to use. Either set 'diff.tool' git config or install VS Code."); if (toolCmd.IndexOf(' ') != -1) { toolCmd = "\"" + toolCmd + "\""; } // TODO: localize toolCmd += " \"$LOCAL\" \"$REMOTE\" --diff"; tool = new DiffTool { Cmd = toolCmd }; } #pragma warning disable CS8603 // Possible null reference return. return(tool); #pragma warning restore CS8603 // Possible null reference return. }); mergeTool = new Lazy <MergeTool>(() => { MergeTool?tool = default; var toolName = repository.Config.GetValueOrDefault("merge.tool", default(string)); if (!string.IsNullOrEmpty(toolName)) { // NOTE: we only support cmd-specified tools, since we need to do the replacements of // $BASE $LOCAL $REMOTE and $MERGED ourselves and otherwise wouldn't know the order. tool = repository.Config.Read <MergeTool>("mergetool", toolName); } if (string.IsNullOrEmpty(tool?.Cmd)) { var toolCmd = LocateDiffMerge(); if (string.IsNullOrEmpty(toolCmd)) { throw new ArgumentException("Cannot determine default merge tool to use. Either set 'merge.tool' git config or install Visual Studio 2017 or later."); } if (toolCmd.IndexOf(' ') != -1) { toolCmd = "\"" + toolCmd + "\""; } // TODO: localize toolCmd += " \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\" /t /m Mine Theirs"; tool = new MergeTool { Cmd = toolCmd }; } #pragma warning disable CS8603 // Possible null reference return. return(tool); #pragma warning restore CS8603 // Possible null reference return. }); }
public OpenCommand(IRepository repository, [Import("core.editor")] string editorTool, DiffTool diffTool, MergeTool mergeTool, MainThread mainThread) { this.repository = repository; this.editorTool = editorTool; this.diffTool = diffTool; this.mergeTool = mergeTool; this.mainThread = mainThread; }
public MergeResult <T> DetectChanges(FindSpecification <T> specification) { var preresult = _dataChangesDetector.DetectChanges(specification); return(MergeTool.Merge(preresult.Difference, preresult.Complement, _identityComparer)); }