Beispiel #1
0
        public DroidType()
        {
            var data = new StarWarsData();

            Name   = "Droid";
            Fields = new List <FieldType>
            {
                new FieldType
                {
                    Name        = "id",
                    Description = "The id of the droid.",
                    Type        = new NonNullGraphType(new StringGraphType())
                },
                new FieldType
                {
                    Name        = "name",
                    Description = "The name of the droid.",
                    Type        = new NonNullGraphType(new StringGraphType())
                },
                new FieldType
                {
                    Name    = "friends",
                    Type    = new ListGraphType(typeof(CharacterInterface)),
                    Resolve = (context) =>
                    {
                        return(data.GetFriends(context.Source as StarWarsCharacter));
                    }
                }
            };
            Interfaces = new List <InterfaceGraphType>
            {
                new CharacterInterface()
            };
        }
Beispiel #2
0
        public StarWarsQuery()
        {
            var data = new StarWarsData();

            Name = "Query";

            Field<CharacterInterface>("hero", resolve: context => data.GetDroidById("3"));
            Field<HumanType>(
                "human",
                arguments: new QueryArguments(
                    new []
                    {
                        new QueryArgument { Name = "id", Type = NonNullGraphType.String}
                    }),
                resolve: context => data.GetHumanById((string)context.Arguments["id"])
            );
            Field<DroidType>(
                "droid",
                arguments: new QueryArguments(
                    new []
                    {
                        new QueryArgument { Name = "id", Type = NonNullGraphType.String}
                    }),
                resolve: context => data.GetDroidById((string)context.Arguments["id"])
            );
        }
        public StarWarsQuery(StarWarsData data)
        {
            Name = "Query";

            Field <CharacterInterface>("hero", resolve: context => data.GetDroidByIdAsync("3"));
            Field <HumanType>(
                "human",
                arguments: new QueryArguments(
                    new []
            {
                new QueryArgument <NonNullGraphType <StringGraphType> > {
                    Name = "id", Description = "id of the human"
                }
            }),
                resolve: context => data.GetHumanByIdAsync((string)context.Arguments["id"])
                );
            Field <DroidType>(
                "droid",
                arguments: new QueryArguments(
                    new []
            {
                new QueryArgument <NonNullGraphType <StringGraphType> > {
                    Name = "id", Description = "id of the droid"
                }
            }),
                resolve: context => data.GetDroidByIdAsync((string)context.Arguments["id"])
                );
        }
        public StarWarsQuery()
        {
            var data = new StarWarsData();

            Fields = new List<FieldType>
            {
                new FieldType
                {
                    Name = "hero",
                    Type = new CharacterInterface(),
                    Resolve = (obj) => data.GetDroidById("3")
                },
                new FieldType
                {
                    Name = "human",
                    Type = new HumanType(),
                    Arguments = new QueryArguments(new List<QueryArgument>
                    {
                        new QueryArgument { Name = "id", Type = new NonNullGraphType(new StringGraphType())}
                    }),
                    Resolve = (context) => data.GetHumanById((string)context.Arguments["id"])
                },
                new FieldType
                {
                    Name = "droid",
                    Type = new DroidType(),
                    Arguments = new QueryArguments(new List<QueryArgument>
                    {
                        new QueryArgument { Name = "id", Type = new NonNullGraphType(new StringGraphType())}
                    }),
                    Resolve = (context) => data.GetDroidById((string)context.Arguments["id"])
                }
            };
        }
        public DroidType()
        {
            var data = new StarWarsData();

            Name = "Droid";
            Fields = new List<FieldType>
            {
                new FieldType
                {
                    Name = "id",
                    Description = "The id of the droid.",
                    Type = new NonNullGraphType(new StringGraphType())
                },
                new FieldType
                {
                    Name = "name",
                    Description = "The name of the droid.",
                    Type = new NonNullGraphType(new StringGraphType())
                },
                new FieldType
                {
                    Name = "friends",
                    Type = new ListGraphType(typeof(CharacterInterface)),
                    Resolve = (context) =>
                    {
                        return data.GetFriends(context.Source as StarWarsCharacter);
                    }
                }
            };
            Interfaces = new List<InterfaceGraphType>
            {
                new CharacterInterface()
            };
        }
        public StarWarsQuery()
        {
            var data = new StarWarsData();

            Name = "Query";

            Field<CharacterInterface>("hero", resolve: context => data.GetDroidByIdAsync("3"));
            Field<HumanType>(
                "human",
                arguments: new QueryArguments(
                    new []
                    {
                        new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "id", Description = "id of the human" }
                    }),
                resolve: context => data.GetHumanByIdAsync((string)context.Arguments["id"])
            );
            Field<DroidType>(
                "droid",
                arguments: new QueryArguments(
                    new []
                    {
                        new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "id", Description = "id of the droid" }
                    }),
                resolve: context => data.GetDroidByIdAsync((string)context.Arguments["id"])
            );
        }
        public HumanType(StarWarsData data)
        {
            Name = "Human";

            Field <NonNullGraphType <StringGraphType> >("id", "The id of the human.");
            Field <StringGraphType>("name", "The name of the human.");
            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
                );
            Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");
            Field <StringGraphType>("homePlanet", "The home planet of the human.");

            Interface <CharacterInterface>();
        }
        public HumanType(StarWarsData data)
        {
            Name = "Human";

            Field<NonNullGraphType<StringGraphType>>("id", "The id of the human.");
            Field<StringGraphType>("name", "The name of the human.");
            Field<ListGraphType<CharacterInterface>>(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
            );
            Field<ListGraphType<EpisodeEnum>>("appearsIn", "Which movie they appear in.");
            Field<StringGraphType>("homePlanet", "The home planet of the human.");

            Interface<CharacterInterface>();
        }
Beispiel #9
0
        public DroidType(StarWarsData data)
        {
            Name        = "Droid";
            Description = "A mechanical creature in the Star Wars universe.";

            Field <NonNullGraphType <StringGraphType> >("id", "The id of the droid.");
            Field <StringGraphType>("name", "The name of the droid.");
            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
                );
            Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");
            Field <StringGraphType>("primaryFunction", "The primary function of the droid.");

            Interface <CharacterInterface>();
        }
Beispiel #10
0
        public DroidType(StarWarsData data)
        {
            Name = "Droid";
            Description = "A mechanical creature in the Star Wars universe.";

            Field<NonNullGraphType<StringGraphType>>("id", "The id of the droid.");
            Field<StringGraphType>("name", "The name of the droid.");
            Field<ListGraphType<CharacterInterface>>(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
            );
            Field<ListGraphType<EpisodeEnum>>("appearsIn", "Which movie they appear in.");
            Field<StringGraphType>("primaryFunction", "The primary function of the droid.");

            Interface<CharacterInterface>();
        }
Beispiel #11
0
        public HumanType()
        {
            var data = new StarWarsData();

            Name = "Human";

            Field("id", "The id of the human.", NonNullGraphType.String);
            Field("name", "The name of the human.", ScalarGraphType.String);
            Field<ListGraphType<CharacterInterface>>(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
            );
            Field("appearsIn", "Which movie they appear in.", new ListGraphType<EpisodeEnum>());
            Field("homePlanet", "The home planet of the human.", ScalarGraphType.String);

            Interface<CharacterInterface>();
        }
Beispiel #12
0
        public MatterType(StarWarsData data)
        {
            Name        = "Matter";
            Description = "A legal thingy";

            Field <NonNullGraphType <StringGraphType> >("reference", "The reference of the matter.");
            Field <StringGraphType>("description", "The description of the matter.");
            //Field<ListGraphType<CharacterInterface>>(
            //    "friends",
            //    resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
            //);
            //Field<ListGraphType<EpisodeEnum>>("appearsIn", "Which movie they appear in.");
            //Field<StringGraphType>("primaryFunction", "The primary function of the droid.");

            //Interface<CharacterInterface>();

            IsTypeOf = value => value is Matter;
        }
        public StarWarsQuery()
        {
            var data = new StarWarsData();

            Fields = new List <FieldType>
            {
                new FieldType
                {
                    Name    = "hero",
                    Type    = new CharacterInterface(),
                    Resolve = (obj) => data.GetDroidById("3")
                },
                new FieldType
                {
                    Name      = "human",
                    Type      = new HumanType(),
                    Arguments = new QueryArguments(new List <QueryArgument>
                    {
                        new QueryArgument {
                            Name = "id", Type = new NonNullGraphType(new StringGraphType())
                        }
                    }),
                    Resolve = (context) => data.GetHumanById((string)context.Arguments["id"])
                },
                new FieldType
                {
                    Name      = "droid",
                    Type      = new DroidType(),
                    Arguments = new QueryArguments(new List <QueryArgument>
                    {
                        new QueryArgument {
                            Name = "id", Type = new NonNullGraphType(new StringGraphType())
                        }
                    }),
                    Resolve = (context) => data.GetDroidById((string)context.Arguments["id"])
                }
            };
        }