Esempio n. 1
0
        protected override void Configure(IObjectTypeDescriptor <ISchema> descriptor)
        {
            descriptor.Name("__Schema");

            descriptor.Description(TypeResources.Schema_Description);

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field("description")
            .Type <StringType>()
            .Resolver(c => c.Schema.Description);

            descriptor.Field("types")
            .Description(TypeResources.Schema_Types)
            .Type <NonNullType <ListType <NonNullType <__Type> > > >()
            .Resolver(c => c.Schema.Types);

            descriptor.Field(t => t.QueryType)
            .Description(TypeResources.Schema_QueryType)
            .Type <NonNullType <__Type> >();

            descriptor.Field(t => t.MutationType)
            .Description(TypeResources.Schema_MutationType)
            .Type <__Type>();

            descriptor.Field(t => t.SubscriptionType)
            .Description(TypeResources.Schema_SubscriptionType)
            .Type <__Type>();

            descriptor.Field("directives")
            .Description(TypeResources.Schema_Directives)
            .Type <NonNullType <ListType <NonNullType <__Directive> > > >()
            .Resolver(c => c.Schema.DirectiveTypes);
        }
Esempio n. 2
0
        protected override void Configure(
            IObjectTypeDescriptor <IPageInfo> descriptor)
        {
            descriptor.Name("PageInfo");
            descriptor.Description(
                "Information about pagination in a connection.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.HasNextPage)
            .Type <NonNullType <BooleanType> >()
            .Name("hasNextPage")
            .Description(
                "Indicates whether more edges exist following " +
                "the set defined by the clients arguments.");

            descriptor.Field(t => t.HasPreviousPage)
            .Type <NonNullType <BooleanType> >()
            .Name("hasPreviousPage")
            .Description(
                "Indicates whether more edges exist prior " +
                "the set defined by the clients arguments.");

            descriptor.Field(t => t.StartCursor)
            .Type <StringType>()
            .Name("startCursor")
            .Description(
                "When paginating backwards, the cursor to continue.");

            descriptor.Field(t => t.EndCursor)
            .Type <StringType>()
            .Name("endCursor")
            .Description(
                "When paginating forwards, the cursor to continue.");
        }
Esempio n. 3
0
        protected override void Configure(
            IObjectTypeDescriptor <IOutputField> descriptor)
        {
            descriptor.Name("__Field");

            descriptor.Description(TypeResources.Field_Description);

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(t => t.Description);

            descriptor.Field(t => t.Arguments)
            .Name("args")
            .Type <NonNullType <ListType <NonNullType <__InputValue> > > >()
            .Resolver(c => c.Parent <IOutputField>().Arguments);

            descriptor.Field(t => t.Type)
            .Type <NonNullType <__Type> >();

            descriptor.Field(t => t.IsDeprecated)
            .Type <NonNullType <BooleanType> >();

            descriptor.Field(t => t.DeprecationReason);
        }
Esempio n. 4
0
        protected override void Configure(IObjectTypeDescriptor <ISchema> descriptor)
        {
            descriptor.Name("__Schema");

            descriptor.Description(
                "A GraphQL Schema defines the capabilities of a GraphQL server. It " +
                "exposes all available types and directives on the server, as well as " +
                "the entry points for query, mutation, and subscription operations.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field("types")
            .Description("A list of all types supported by this server.")
            .Type <NonNullType <ListType <NonNullType <__Type> > > >()
            .Resolver(c => c.Schema.Types);

            descriptor.Field(t => t.QueryType)
            .Description("The type that query operations will be rooted at.")
            .Type <NonNullType <__Type> >();

            descriptor.Field(t => t.MutationType)
            .Description("If this server supports mutation, the type that " +
                         "mutation operations will be rooted at.")
            .Type <__Type>();

            descriptor.Field(t => t.SubscriptionType)
            .Description("If this server support subscription, the type that " +
                         "subscription operations will be rooted at.")
            .Type <__Type>();

            descriptor.Field("directives")
            .Description("A list of all directives supported by this server.")
            .Type <NonNullType <ListType <NonNullType <__Directive> > > >()
            .Resolver(c => c.Schema.DirectiveTypes);
        }
Esempio n. 5
0
        protected new static void Configure(
            IObjectTypeDescriptor <IConnection> descriptor)
        {
            descriptor.Name(dependency => dependency.Name + "Connection")
            .DependsOn <T>();

            descriptor.Description("A connection to a list of items.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.PageInfo)
            .Name("pageInfo")
            .Description("Information to aid in pagination.")
            .Type <NonNullType <PageInfoType> >();

            descriptor.Field(t => t.Edges)
            .Name("edges")
            .Description("A list of edges.")
            .Type <ListType <NonNullType <EdgeType <T> > > >();

            descriptor.Field("nodes")
            .Description("A flattened list of the nodes.")
            .Type <ListType <T> >()
            .Resolver(ctx =>
                      ctx.Parent <IConnection>().Edges.Select(t => t.Node));
        }
Esempio n. 6
0
        protected override void Configure(
            IObjectTypeDescriptor <IEdge> descriptor)
        {
            if (!NamedTypeInfoFactory.Default.TryExtractName(
                    typeof(T), out NameString name))
            {
                throw new InvalidOperationException(
                          $"Unable to extract a name from {typeof(T).FullName}.");
            }

            descriptor.Name(name + "Edge");
            descriptor.Description("An edge in a connection.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.Cursor)
            .Name("cursor")
            .Description("A cursor for use in pagination.")
            .Type <NonNullType <StringType> >();

            descriptor.Field(t => t.Node)
            .Name("node")
            .Description("The item at the end of the edge.")
            .Type <T>();
        }
Esempio n. 7
0
        protected override void Configure(
            IObjectTypeDescriptor <IOutputField> descriptor)
        {
            descriptor.Name("__Field");

            descriptor.Description(
                "Object and Interface types are described by a " +
                "list of Fields, each of which has a name, " +
                "potentially a list of arguments, and a return type.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(t => t.Description);

            descriptor.Field(t => t.Arguments)
            .Name("args")
            .Type <NonNullType <ListType <NonNullType <__InputValue> > > >()
            .Resolver(c => c.Parent <IOutputField>().Arguments);

            descriptor.Field(t => t.Type)
            .Type <NonNullType <__Type> >();

            descriptor.Field(t => t.IsDeprecated)
            .Type <NonNullType <BooleanType> >();

            descriptor.Field(t => t.DeprecationReason);
        }
        protected override void Configure(IObjectTypeDescriptor <IPageInfo> descriptor)
        {
            descriptor.Description("Information about pagination in a connection.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.Limit)
            .Type <NonNullType <IntType> >()
            .Name("limit")
            .Description(
                "Number of records per page.");

            descriptor.Field(t => t.PageNumber)
            .Type <NonNullType <IntType> >()
            .Name("pageNumber")
            .Description("Page number.");

            descriptor.Field(t => t.TotalCount)
            .Type <LongType>()
            .Name("totalCount")
            .Description("Total number of records.");

            descriptor.Field(t => t.HasNextPage)
            .Type <BooleanType>()
            .Name("hasNextPage")
            .Description("Is the next page available.");

            descriptor.Field(t => t.HasPreviousPage)
            .Type <BooleanType>()
            .Name("hasPreviousPage")
            .Description("Is the previous page available.");
        }
Esempio n. 9
0
 protected override void Configure(IObjectTypeDescriptor <Product> descriptor)
 {
     descriptor.Name("Product");
     descriptor.Description("A product for a webshop");
     descriptor.BindFields(BindingBehavior.Explicit);
     descriptor.Include <Resolvers.ProductResolver>();
 }
Esempio n. 10
0
        protected new static void Configure(
            IObjectTypeDescriptor <IConnection> descriptor)
        {
            if (!NamedTypeInfoFactory.Default.TryExtractName(
                    typeof(T), out NameString name))
            {
                throw new InvalidOperationException(
                          $"Unable to extract a name from {typeof(T).FullName}.");
            }

            descriptor.Name(name + "Connection");
            descriptor.Description("A connection to a list of items.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.PageInfo)
            .Name("pageInfo")
            .Description("Information to aid in pagination.")
            .Type <NonNullType <PageInfoType> >();

            descriptor.Field(t => t.Edges)
            .Name("edges")
            .Description("A list of edges.")
            .Type <ListType <NonNullType <EdgeType <T> > > >();
        }
Esempio n. 11
0
        protected override void Configure(
            IObjectTypeDescriptor <Query> descriptor)
        {
            descriptor.Name("Query");
            descriptor.BindFields(BindingBehavior.Implicit);

            descriptor.Field(q => q.GetGame(default, default, default))
Esempio n. 12
0
        protected override void Configure(IObjectTypeDescriptor <Query> descriptor)
        {
            descriptor.Name("Query");
            descriptor.Description("Provides access to queries");

            descriptor.BindFields(BindingBehavior.Explicit);
            descriptor.Include <Resolvers.QueryResolver>();
        }
        protected override void Configure(
            IObjectTypeDescriptor <Mutation> descriptor)
        {
            descriptor.Name("Mutation");
            descriptor.BindFields(BindingBehavior.Implicit);

            descriptor
            .Field(m => m.CreateGame(default, default))
Esempio n. 14
0
        protected override void Configure(IObjectTypeDescriptor <Catalog> descriptor)
        {
            descriptor.Name("Catalog");
            descriptor.Description("A named collection of products");

            descriptor.BindFields(BindingBehavior.Explicit);
            descriptor.Include <API.Resolvers.CatalogResolver>();
        }
Esempio n. 15
0
        protected override void Configure(IObjectTypeDescriptor <IType> descriptor)
        {
            descriptor.Name("__Type");

            descriptor.Description(
                "The fundamental unit of any GraphQL Schema is the type. There are " +
                "many kinds of types in GraphQL as represented by the `__TypeKind` enum." +
                "\n\nDepending on the kind of a type, certain fields describe " +
                "information about that type. Scalar types provide no information " +
                "beyond a name and description, while Enum types provide their values. " +
                "Object and Interface types provide the fields they describe. Abstract " +
                "types, Union and Interface, provide the Object types possible " +
                "at runtime. List and NonNull types compose other types.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field("kind")
            .Type <NonNullType <__TypeKind> >()
            .Resolver(c => c.Parent <IType>().Kind);

            descriptor.Field("name")
            .Type <StringType>()
            .Resolver(c => GetName(c.Parent <IType>()));

            descriptor.Field("description")
            .Type <StringType>()
            .Resolver(c => GetDescription(c.Parent <IType>()));

            descriptor.Field("fields")
            .Type <ListType <NonNullType <__Field> > >()
            .Argument("includeDeprecated",
                      a => a.Type <BooleanType>().DefaultValue(false))
            .Resolver(c => GetFields(c.Parent <IType>(),
                                     c.Argument <bool>("includeDeprecated")));

            descriptor.Field("interfaces")
            .Type <ListType <NonNullType <__Type> > >()
            .Resolver(c => GetInterfaces(c.Parent <IType>()));

            descriptor.Field("possibleTypes")
            .Type <ListType <NonNullType <__Type> > >()
            .Resolver(c => GetPossibleTypes(c.Schema, c.Parent <INamedType>()));

            descriptor.Field("enumValues")
            .Type <ListType <NonNullType <__EnumValue> > >()
            .Argument("includeDeprecated",
                      a => a.Type <BooleanType>().DefaultValue(false))
            .Resolver(c => GetEnumValues(c.Parent <IType>(),
                                         c.Argument <bool>("includeDeprecated")));

            descriptor.Field("inputFields")
            .Type <ListType <NonNullType <__InputValue> > >()
            .Resolver(c => GetInputFields(c.Parent <IType>()));

            descriptor.Field("ofType")
            .Type <__Type>()
            .Resolver(c => GetOfType(c.Parent <IType>()));
        }
Esempio n. 16
0
        protected override void Configure(
            IObjectTypeDescriptor <MessageRecord> descriptor)
        {
            descriptor
            .BindFields(BindingBehavior.Explicit);

            descriptor
            .Field(d => d.Id)
            .Type <NonNullType <IdType> >();

            descriptor
            .Field(d => d.ReceivedAt);

            descriptor
            .Field(d => d.Type)
            .Type <NonNullType <StringType> >();

            descriptor
            .Field(d => d.From)
            .Type <NonNullType <StringType> >();


            descriptor
            .Field(d => d.Body)
            .Type <StringType>();

            descriptor
            .Field(d => d.To)
            .Type <ListType <StringType> >();

            descriptor
            .Field("primaryReceipient")
            .Type <NonNullType <StringType> >()
            .Resolver((ctx) =>
            {
                return(ctx.Parent <MessageRecord>().To.Single());
            });

            descriptor
            .Field(d => d.ReceivedLog);

            descriptor
            .Field(d => d.Provider)
            .Type <NonNullType <StringType> >();

            descriptor
            .Field(d => d.Properties);

            descriptor
            .Field("title")
            .Type <NonNullType <StringType> >()
            .Resolver((ctx) =>
            {
                return(ctx.Parent <MessageRecord>().GetTitle());
            });
        }
Esempio n. 17
0
        protected override void Configure(IObjectTypeDescriptor <Country> descriptor)
        {
            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(a => a.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(a => a.Iso)
            .Type <NonNullType <StringType> >();
        }
Esempio n. 18
0
        protected override void Configure(IObjectTypeDescriptor <User> descriptor)
        {
            descriptor.Name("User");
            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(x => x.Id);
            descriptor.Field(x => x.Nickname);
            descriptor.Field(x => x.RegisteredOn);
            descriptor.Field(x => x.Articles);
            descriptor.Field(x => x.Posts);
        }
Esempio n. 19
0
        protected override void Configure(IObjectTypeDescriptor <Tag> descriptor)
        {
            descriptor.Name("Tag");
            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(x => x.Id);
            descriptor.Field(x => x.Name);
            descriptor.Field(x => x.CreatedOn);
            descriptor.Field(x => x.UpdatedOn);
            descriptor.Field(x => x.Articles);
            descriptor.Field(x => x.Posts);
        }
Esempio n. 20
0
        protected override void Configure(IObjectTypeDescriptor <IType> descriptor)
        {
            descriptor.Name("__Type");

            descriptor.Description(TypeResources.Type_Description);

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field("kind")
            .Type <NonNullType <__TypeKind> >()
            .Resolver(c => c.Parent <IType>().Kind);

            descriptor.Field("name")
            .Type <StringType>()
            .Resolver(c => GetName(c.Parent <IType>()));

            descriptor.Field("description")
            .Type <StringType>()
            .Resolver(c => GetDescription(c.Parent <IType>()));

            descriptor.Field("fields")
            .Type <ListType <NonNullType <__Field> > >()
            .Argument("includeDeprecated",
                      a => a.Type <BooleanType>().DefaultValue(false))
            .Resolver(c => GetFields(c.Parent <IType>(),
                                     c.ArgumentValue <bool>("includeDeprecated")));

            descriptor.Field("interfaces")
            .Type <ListType <NonNullType <__Type> > >()
            .Resolver(c => GetInterfaces(c.Parent <IType>()));

            descriptor.Field("possibleTypes")
            .Type <ListType <NonNullType <__Type> > >()
            .Resolver(c => GetPossibleTypes(c.Schema, c.Parent <INamedType>()));

            descriptor.Field("enumValues")
            .Type <ListType <NonNullType <__EnumValue> > >()
            .Argument("includeDeprecated",
                      a => a.Type <BooleanType>().DefaultValue(false))
            .Resolver(c => GetEnumValues(c.Parent <IType>(),
                                         c.ArgumentValue <bool>("includeDeprecated")));

            descriptor.Field("inputFields")
            .Type <ListType <NonNullType <__InputValue> > >()
            .Resolver(c => GetInputFields(c.Parent <IType>()));

            descriptor.Field("ofType")
            .Type <__Type>()
            .Resolver(c => GetOfType(c.Parent <IType>()));
        }
Esempio n. 21
0
        protected override void Configure(IObjectTypeDescriptor <Post> descriptor)
        {
            descriptor.Name("Post");
            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(x => x.Id);
            descriptor.Field(x => x.User);
            descriptor.Field(x => x.UserId);
            descriptor.Field(x => x.Category);
            descriptor.Field(x => x.CategoryId);
            descriptor.Field(x => x.Title);
            descriptor.Field(x => x.Content);
            descriptor.Field(x => x.CreatedOn);
            descriptor.Field(x => x.UpdatedOn);
            descriptor.Field(x => x.Tags);
        }
Esempio n. 22
0
        protected override void Configure(IObjectTypeDescriptor <Casting> descriptor)
        {
            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(c => c.Id)
            .Type <NonNullType <UuidType> >();

            descriptor.Field(c => c.Actor)
            .Type <NonNullType <ActorType> >();

            descriptor.Field(c => c.Film)
            .Type <NonNullType <FilmType> >();

            descriptor.Field(c => c.Role)
            .Type <NonNullType <RoleType> >();
        }
Esempio n. 23
0
        protected override void Configure(IObjectTypeDescriptor <InputField> descriptor)
        {
            descriptor.Name("__InputValue");

            descriptor.Description(
                "Arguments provided to Fields or Directives and the input fields of an " +
                "InputObject are represented as Input Values which describe their type " +
                "and optionally a default value.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(t => t.Description);

            descriptor.Field(t => t.Type)
            .Type <NonNullType <__Type> >();

            descriptor.Field(t => t.DefaultValue)
            .Description(
                "A GraphQL-formatted string representing the default value for this " +
                "input value.")
            .Type <StringType>()
            .Resolver(c =>
            {
                InputField field = c.Parent <InputField>();
                if (field.Type.IsNonNullType() &&
                    field.DefaultValue is NullValueNode)
                {
                    return(null);
                }

                if (field.DefaultValue != null)
                {
                    object nativeValue = field.Type.ParseLiteral(field.DefaultValue);
                    if (field.Type is ISerializableType serializableType)
                    {
                        return(JsonConvert.SerializeObject(
                                   serializableType.Serialize(nativeValue)));
                    }
                }

                return(null);
            });
        }
Esempio n. 24
0
        protected new static void Configure(
            IObjectTypeDescriptor <IConnection> descriptor)
        {
            descriptor.Description("A connection to a list of items.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.PageInfo)
            .Name("pageInfo")
            .Description("Information to aid in pagination.")
            .Type <NonNullType <PageInfoType> >();

            descriptor.Field(t => t.Edges)
            .Name("edges")
            .Description("A list of edges.")
            .Type <ListType <NonNullType <EdgeType <T> > > >();
        }
Esempio n. 25
0
        protected override void Configure(IObjectTypeDescriptor <Actor> descriptor)
        {
            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(a => a.Id)
            .Type <NonNullType <UuidType> >();

            descriptor.Field(a => a.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(a => a.DateOfBirth)
            .Type <NonNullType <DateType> >();

            descriptor.Field(a => a.Nationality)
            .Type <NonNullType <CountryType> >()
            .Name("nationality");

            descriptor.Field <CastingResolver>(r => r.GetPlays(default, default))
Esempio n. 26
0
        protected override void Configure(IObjectTypeDescriptor <Film> descriptor)
        {
            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(a => a.Id)
            .Type <NonNullType <UuidType> >();

            descriptor.Field(a => a.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(a => a.ReleaseYear)
            .Type <NonNullType <IntType> >();

            descriptor.Field(a => a.Country)
            .Type <NonNullType <CountryType> >()
            .Name("country");

            descriptor.Field <CastingResolver>(r => r.GetCast(default, default))
Esempio n. 27
0
        protected override void Configure(
            IObjectTypeDescriptor <InputField> descriptor)
        {
            descriptor.Name("__InputValue");

            descriptor.Description(
                "Arguments provided to Fields or Directives and the input " +
                "fields of an InputObject are represented as Input Values " +
                "which describe their type and optionally a default value.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(t => t.Description);

            descriptor.Field(t => t.Type)
            .Type <NonNullType <__Type> >();

            descriptor.Field(t => t.DefaultValue)
            .Description(
                "A GraphQL-formatted string representing the default " +
                "value for this input value.")
            .Type <StringType>()
            .Resolver(c =>
            {
                InputField field = c.Parent <InputField>();
                if (field.DefaultValue.IsNull())
                {
                    return(null);
                }

                if (field.DefaultValue != null)
                {
                    return(QuerySyntaxSerializer
                           .Serialize(field.DefaultValue));
                }

                return(null);
            });
        }
Esempio n. 28
0
        protected override void Configure(
            IObjectTypeDescriptor <IEdge> descriptor)
        {
            descriptor.Name(dependency => dependency.Name + "Edge")
            .DependsOn <T>();

            descriptor.Description("An edge in a connection.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(t => t.Cursor)
            .Name("cursor")
            .Description("A cursor for use in pagination.")
            .Type <NonNullType <StringType> >();

            descriptor.Field(t => t.Node)
            .Name("node")
            .Description("The item at the end of the edge.")
            .Type <T>();
        }
Esempio n. 29
0
        protected override void Configure(
            IObjectTypeDescriptor <EnumValue> descriptor)
        {
            descriptor.Name("__EnumValue");

            descriptor.Description(
                TypeResources.EnumValue_Description);

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(c => c.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(c => c.Description);

            descriptor.Field(c => c.IsDeprecated)
            .Type <NonNullType <BooleanType> >();

            descriptor.Field(c => c.DeprecationReason);
        }
Esempio n. 30
0
        protected override void Configure(IObjectTypeDescriptor <EnumValue> descriptor)
        {
            descriptor.Name("__EnumValue");

            descriptor.Description(
                "One possible value for a given Enum. Enum values are unique values, not " +
                "a placeholder for a string or numeric value. However an Enum value is " +
                "returned in a JSON response as a string.");

            descriptor.BindFields(BindingBehavior.Explicit);

            descriptor.Field(c => c.Name)
            .Type <NonNullType <StringType> >();

            descriptor.Field(c => c.Description);

            descriptor.Field(c => c.IsDeprecated)
            .Type <NonNullType <BooleanType> >();

            descriptor.Field(c => c.DeprecationReason);
        }