예제 #1
0
        protected override void Configure(IObjectTypeDescriptor <IGame> descriptor)
        {
            descriptor.ExtendGame();

            descriptor.Field("files")
            .Type <GameFileExtensionType>()
            .Description("Provides access to the game's files.")
            .Resolve(context => context.Parent <IGame>().WithFiles());
        }
예제 #2
0
        protected override void Configure(IObjectTypeDescriptor <IGame> descriptor)
        {
            descriptor.ExtendGame();
            descriptor.Interface <NodeType>();
            descriptor.Field("id")
            .Type <IdType>()
            .Resolver(ctx => ctx.Parent <IGame>().Record.RecordID);

            descriptor.AsNode()
            .NodeResolver <Guid>(async(ctx, id) => await ctx.SnowflakeService <IGameLibrary>().GetGameAsync(id));
        }
예제 #3
0
        protected override void Configure(IObjectTypeDescriptor <IGame> descriptor)
        {
            descriptor.ExtendGame();
            descriptor.Field("orchestration")
            .Description("Provides access to game orchestration information for orchestrators that support this game.")
            .Resolve(ctx =>
            {
                var orchestrators = ctx.SnowflakeService <IPluginManager>()
                                    .GetCollection <IEmulatorOrchestrator>();
                var game = ctx.Parent <IGame>();

                return(orchestrators
                       .Where(o => o.CheckCompatibility(game) != EmulatorCompatibility.Unsupported)
                       .Select(orchestrator => (game, orchestrator)));
            })
            .Type <NonNullType <ListType <NonNullType <GameOrchestratorType> > > >();
        }
예제 #4
0
        protected override void Configure(IObjectTypeDescriptor <IGame> descriptor)
        {
            descriptor.ExtendGame();

            descriptor.Field("saves")
            .Argument("saveType", arg =>
                      arg.Description("A string that identifies all save profiles with the same format.")
                      .Type <StringType>())
            .Argument("profileId", arg =>
                      arg.Description("The GUID of a specific profile.")
                      .Type <UuidType>())
            .Description("The save profiles associated with this game.")
            .Resolve(ctx =>
            {
                var profileId = ctx.ArgumentValue <Guid>("profileId");
                var saveType  = ctx.ArgumentValue <string>("saveType");
                var saves     = ctx.Parent <IGame>().WithFiles().WithSaves();
                if (profileId != default)
                {
                    var profile = saves.GetProfile(profileId);

                    // Check for save type, to maintain consistent behaviour if both arguments are provided.
                    if (saveType != null)
                    {
                        return profile?.SaveType == saveType ?
                        new[] { profile }
                    }
                    : Enumerable.Empty <ISaveProfile>();

                    // saveType has no value.
                    return(profile != null
                            ? new[] { profile }
                            : Enumerable.Empty <ISaveProfile>());
                }

                if (saveType != null)
                {
                    return(saves.GetProfiles(saveType));
                }

                return(saves.GetProfiles());
            })
            .Type <NonNullType <ListType <SaveProfileType> > >();
        }