コード例 #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()
            };
        }
コード例 #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"])
            );
        }
コード例 #3
0
        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"])
                );
        }
コード例 #4
0
        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"])
                }
            };
        }
コード例 #5
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()
            };
        }
コード例 #6
0
        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"])
            );
        }
コード例 #7
0
        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>();
        }
コード例 #8
0
        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>();
        }
コード例 #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>();
        }
コード例 #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>();
        }
コード例 #11
0
ファイル: HumanType.cs プロジェクト: noikiy/graphql-dotnet
        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>();
        }
コード例 #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;
        }
コード例 #13
0
        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"])
                }
            };
        }