protected override void Configure( IEnumTypeDescriptor <Foo> descriptor) { descriptor.BindValues(BindingBehavior.Explicit); descriptor.Item(Foo.Bar); descriptor.Item(Foo.Baz); }
protected override void Configure(IEnumTypeDescriptor <TypeKind> descriptor) { descriptor.Name("__TypeKind"); descriptor.Description(TypeResources.TypeKind_Description); descriptor.Item(TypeKind.Scalar) .Description(TypeResources.TypeKind_Scalar); descriptor.Item(TypeKind.Object) .Description(TypeResources.TypeKind_Object); descriptor.Item(TypeKind.Interface) .Description(TypeResources.TypeKind_Interface); descriptor.Item(TypeKind.Union) .Description(TypeResources.TypeKind_Union); descriptor.Item(TypeKind.Enum) .Description(TypeResources.TypeKind_Enum); descriptor.Item(TypeKind.InputObject) .Name("INPUT_OBJECT") .Description(TypeResources.TypeKind_InputObject); descriptor.Item(TypeKind.List) .Description(TypeResources.TypeKind_List); descriptor.Item(TypeKind.NonNull) .Name("NON_NULL") .Description(TypeResources.TypeKind_NonNull); }
public void SpecifyOneValueInferTheOthers() { // arrange var descriptor = EnumTypeDescriptor.New(Context, typeof(FooEnum)); // act IEnumTypeDescriptor desc = descriptor; desc.Item(FooEnum.Bar1).Name("FOOBAR"); // assert EnumTypeDefinition description = descriptor.CreateDefinition(); Assert.Collection(description.Values, t => { Assert.Equal("FOOBAR", t.Name); Assert.Equal(FooEnum.Bar1, t.Value); }, t => { Assert.Equal("BAR2", t.Name); Assert.Equal(FooEnum.Bar2, t.Value); }); }
private void DeclareValues( IEnumTypeDescriptor typeDescriptor, IReadOnlyCollection <EnumValueDefinitionNode> values) { foreach (EnumValueDefinitionNode value in values) { typeDescriptor.Item(value.Name.Value); } }
protected override void Configure(IEnumTypeDescriptor <TypeKind> descriptor) { descriptor .Name(Names.__TypeKind) .Description(TypeResources.TypeKind_Description) // Introspection types must always be bound explicitly so that we // do not get any interference with conventions. .BindItems(BindingBehavior.Explicit); descriptor .Item(TypeKind.Scalar) .Name(Names.Scalar) .Description(TypeResources.TypeKind_Scalar); descriptor .Item(TypeKind.Object) .Name(Names.Object) .Description(TypeResources.TypeKind_Object); descriptor .Item(TypeKind.Interface) .Name(Names.Interface) .Description(TypeResources.TypeKind_Interface); descriptor .Item(TypeKind.Union) .Name(Names.Union) .Description(TypeResources.TypeKind_Union); descriptor .Item(TypeKind.Enum) .Name(Names.Enum) .Description(TypeResources.TypeKind_Enum); descriptor .Item(TypeKind.InputObject) .Name(Names.InputObject) .Description(TypeResources.TypeKind_InputObject); descriptor .Item(TypeKind.List) .Name(Names.List) .Description(TypeResources.TypeKind_List); descriptor .Item(TypeKind.NonNull) .Name(Names.NonNull) .Description(TypeResources.TypeKind_NonNull); }
public static IEnumTypeDescriptor <TEnum> UseNamesAsValues <TEnum>(this IEnumTypeDescriptor <TEnum> descriptor) { var enumType = typeof(TEnum); foreach (var field in typeof(TEnum).GetFields()) { if (field.Name == EnumDefaultFieldName) { continue; } descriptor.Item((TEnum)Enum.ToObject(enumType, field.GetRawConstantValue())).Name(field.Name); } return(descriptor); }
protected override void Configure(IEnumTypeDescriptor <TypeKind> descriptor) { descriptor.Name("__TypeKind"); descriptor.Description( "An enum describing what kind of type a given `__Type` is."); descriptor.Item(TypeKind.Scalar) .Description("Indicates this type is a scalar."); descriptor.Item(TypeKind.Object) .Description("Indicates this type is an object. " + "`fields` and `interfaces` are valid fields."); descriptor.Item(TypeKind.Interface) .Description("Indicates this type is an interface. " + "`fields` and `possibleTypes` are valid fields."); descriptor.Item(TypeKind.Union) .Description("Indicates this type is a union. " + "`possibleTypes` is a valid field."); descriptor.Item(TypeKind.Enum) .Description("Indicates this type is an enum. " + "`enumValues` is a valid field."); descriptor.Item(TypeKind.InputObject) .Name("INPUT_OBJECT") .Description("Indicates this type is an input object. " + "`inputFields` is a valid field."); descriptor.Item(TypeKind.List) .Description("Indicates this type is a list. " + "`ofType` is a valid field."); descriptor.Item(TypeKind.NonNull) .Name("NON_NULL") .Description("Indicates this type is a non-null. " + "`ofType` is a valid field."); }
protected override void Configure(IEnumTypeDescriptor <DirectiveLocation> descriptor) { descriptor.Name("__DirectiveLocation"); descriptor.Description( "A Directive can be adjacent to many parts of the GraphQL language, a " + "__DirectiveLocation describes one such possible adjacencies."); descriptor.Item(DirectiveLocation.Query) .Description("Location adjacent to a query operation."); descriptor.Item(DirectiveLocation.Mutation) .Description("Location adjacent to a mutation operation."); descriptor.Item(DirectiveLocation.Subscription) .Description("Location adjacent to a subscription operation."); descriptor.Item(DirectiveLocation.Field) .Description("Location adjacent to a field."); descriptor.Item(DirectiveLocation.FragmentDefinition) .Name("FRAGMENT_DEFINITION") .Description("Location adjacent to a fragment definition."); descriptor.Item(DirectiveLocation.FragmentSpread) .Name("FRAGMENT_SPREAD") .Description("Location adjacent to a fragment spread."); descriptor.Item(DirectiveLocation.InlineFragment) .Name("INLINE_FRAGMENT") .Description("Location adjacent to an inline fragment."); descriptor.Item(DirectiveLocation.Schema) .Description("Location adjacent to a schema definition."); descriptor.Item(DirectiveLocation.Scalar) .Description("Location adjacent to a scalar definition."); descriptor.Item(DirectiveLocation.Object) .Description("Location adjacent to an object type definition."); descriptor.Item(DirectiveLocation.FieldDefinition) .Name("FIELD_DEFINITION") .Description("Location adjacent to a field definition."); descriptor.Item(DirectiveLocation.ArgumentDefinition) .Name("ARGUMENT_DEFINITION") .Description("Location adjacent to an argument definition"); descriptor.Item(DirectiveLocation.Interface) .Description("Location adjacent to an interface definition."); descriptor.Item(DirectiveLocation.Union) .Description("Location adjacent to a union definition."); descriptor.Item(DirectiveLocation.Enum) .Description("Location adjacent to an enum definition."); descriptor.Item(DirectiveLocation.EnumValue) .Name("ENUM_VALUE") .Description("Location adjacent to an enum value definition."); descriptor.Item(DirectiveLocation.InputObject) .Name("INPUT_OBJECT") .Description("Location adjacent to an input object type definition."); descriptor.Item(DirectiveLocation.InputFieldDefinition) .Name("INPUT_FIELD_DEFINITION") .Description("Location adjacent to an input object field definition."); }
protected override void Configure(IEnumTypeDescriptor descriptor) { descriptor.Name("Foo"); descriptor.Item(Foo.Quox).Name("_QUOX"); }
protected override void Configure(IEnumTypeDescriptor <DirectiveLocation> descriptor) { descriptor .Name(Names.__DirectiveLocation) .Description(TypeResources.DirectiveLocation_Description) // Introspection types must always be bound explicitly so that we // do not get any interference with conventions. .BindItems(BindingBehavior.Explicit); descriptor .Item(DirectiveLocation.Query) .Name(Lang.Query.Value) .Description(TypeResources.DirectiveLocation_Query); descriptor .Item(DirectiveLocation.Mutation) .Name(Lang.Mutation.Value) .Description(TypeResources.DirectiveLocation_Mutation); descriptor .Item(DirectiveLocation.Subscription) .Name(Lang.Subscription.Value) .Description(TypeResources.DirectiveLocation_Subscription); descriptor .Item(DirectiveLocation.Field) .Name(Lang.Field.Value) .Description(TypeResources.DirectiveLocation_Field); descriptor .Item(DirectiveLocation.FragmentDefinition) .Name(Lang.FragmentDefinition.Value) .Description(TypeResources.DirectiveLocation_FragmentDefinition); descriptor .Item(DirectiveLocation.FragmentSpread) .Name(Lang.FragmentSpread.Value) .Description(TypeResources.DirectiveLocation_FragmentSpread); descriptor .Item(DirectiveLocation.InlineFragment) .Name(Lang.InlineFragment.Value) .Description(TypeResources.DirectiveLocation_InlineFragment); descriptor .Item(DirectiveLocation.VariableDefinition) .Name(Lang.VariableDefinition.Value) .Description("Location adjacent to a variable definition."); descriptor .Item(DirectiveLocation.Schema) .Name(Lang.Schema.Value) .Description(TypeResources.DirectiveLocation_Schema); descriptor .Item(DirectiveLocation.Scalar) .Name(Lang.Scalar.Value) .Description(TypeResources.DirectiveLocation_Scalar); descriptor .Item(DirectiveLocation.Object) .Name(Lang.Object.Value) .Description(TypeResources.DirectiveLocation_Object); descriptor .Item(DirectiveLocation.FieldDefinition) .Name(Lang.FieldDefinition.Value) .Description(TypeResources.DirectiveLocation_FieldDefinition); descriptor .Item(DirectiveLocation.ArgumentDefinition) .Name(Lang.ArgumentDefinition.Value) .Description(TypeResources.DirectiveLocation_ArgumentDefinition); descriptor .Item(DirectiveLocation.Interface) .Name(Lang.Interface.Value) .Description(TypeResources.DirectiveLocation_Interface); descriptor .Item(DirectiveLocation.Union) .Name(Lang.Union.Value) .Description(TypeResources.DirectiveLocation_Union); descriptor .Item(DirectiveLocation.Enum) .Name(Lang.Enum.Value) .Description(TypeResources.DirectiveLocation_Enum); descriptor .Item(DirectiveLocation.EnumValue) .Name(Lang.EnumValue.Value) .Description(TypeResources.DirectiveLocation_EnumValue); descriptor .Item(DirectiveLocation.InputObject) .Name(Lang.InputObject.Value) .Description(TypeResources.DirectiveLocation_InputObject); descriptor .Item(DirectiveLocation.InputFieldDefinition) .Name(Lang.InputFieldDefinition.Value) .Description(TypeResources.DirectiveLocation_InputFieldDefinition); }
protected override void Configure(IEnumTypeDescriptor <DirectiveLocation> descriptor) { descriptor.Name("__DirectiveLocation"); descriptor.Description( TypeResources.DirectiveLocation_Description); descriptor.Item(DirectiveLocation.Query) .Description(TypeResources.DirectiveLocation_Query); descriptor.Item(DirectiveLocation.Mutation) .Description(TypeResources.DirectiveLocation_Mutation); descriptor.Item(DirectiveLocation.Subscription) .Description(TypeResources.DirectiveLocation_Subscription); descriptor.Item(DirectiveLocation.Field) .Description(TypeResources.DirectiveLocation_Field); descriptor.Item(DirectiveLocation.FragmentDefinition) .Name("FRAGMENT_DEFINITION") .Description(TypeResources.DirectiveLocation_FragmentDefinition); descriptor.Item(DirectiveLocation.FragmentSpread) .Name("FRAGMENT_SPREAD") .Description(TypeResources.DirectiveLocation_FragmentSpread); descriptor.Item(DirectiveLocation.InlineFragment) .Name("INLINE_FRAGMENT") .Description(TypeResources.DirectiveLocation_InlineFragment); descriptor.Item(DirectiveLocation.Schema) .Description(TypeResources.DirectiveLocation_Schema); descriptor.Item(DirectiveLocation.Scalar) .Description(TypeResources.DirectiveLocation_Scalar); descriptor.Item(DirectiveLocation.Object) .Description(TypeResources.DirectiveLocation_Object); descriptor.Item(DirectiveLocation.FieldDefinition) .Name("FIELD_DEFINITION") .Description(TypeResources.DirectiveLocation_FieldDefinition); descriptor.Item(DirectiveLocation.ArgumentDefinition) .Name("ARGUMENT_DEFINITION") .Description(TypeResources.DirectiveLocation_ArgumentDefinition); descriptor.Item(DirectiveLocation.Interface) .Description(TypeResources.DirectiveLocation_Interface); descriptor.Item(DirectiveLocation.Union) .Description(TypeResources.DirectiveLocation_Union); descriptor.Item(DirectiveLocation.Enum) .Description(TypeResources.DirectiveLocation_Enum); descriptor.Item(DirectiveLocation.EnumValue) .Name("ENUM_VALUE") .Description(TypeResources.DirectiveLocation_EnumValue); descriptor.Item(DirectiveLocation.InputObject) .Name("INPUT_OBJECT") .Description(TypeResources.DirectiveLocation_InputObject); descriptor.Item(DirectiveLocation.InputFieldDefinition) .Name("INPUT_FIELD_DEFINITION") .Description(TypeResources.DirectiveLocation_InputFieldDefinition); }