protected override ObjectTypeDefinition CreateDefinition(ITypeDiscoveryContext context) { SyntaxTypeReference stringType = Create(ScalarNames.String); SyntaxTypeReference nonNullStringType = Parse($"{ScalarNames.String}!"); SyntaxTypeReference nonNullTypeType = Parse($"{nameof(__Type)}!"); SyntaxTypeReference appDirectiveListType = Parse($"[{nameof(__AppliedDirective)}!]!"); var def = new ObjectTypeDefinition( Names.__InputValue, InputValue_Description, typeof(IInputField)) { Fields = { new(Names.Name, type: nonNullStringType, pureResolver: Resolvers.Name), new(Names.Description, type: stringType, pureResolver: Resolvers.Description), new(Names.Type, type: nonNullTypeType, pureResolver: Resolvers.Type), new(Names.DefaultValue, InputValue_DefaultValue, stringType, pureResolver: Resolvers.DefaultValue), } }; if (context.DescriptorContext.Options.EnableDirectiveIntrospection) { def.Fields.Add(new( Names.AppliedDirectives, type: appDirectiveListType, pureResolver: Resolvers.AppliedDirectives)); } return(def); }
protected override ObjectTypeDefinition CreateDefinition(ITypeDiscoveryContext context) { SyntaxTypeReference stringType = Create(ScalarNames.String); SyntaxTypeReference nonNullStringType = Parse($"{ScalarNames.String}!"); SyntaxTypeReference nonNullBooleanType = Parse($"{ScalarNames.Boolean}!"); SyntaxTypeReference argumentListType = Parse($"[{nameof(__InputValue)}!]!"); SyntaxTypeReference locationListType = Parse($"[{nameof(__DirectiveLocation)}!]!"); return(new ObjectTypeDefinition( Names.__Directive, TypeResources.Directive_Description, typeof(DirectiveType)) { Fields = { new(Names.Name, type: nonNullStringType, pureResolver: Resolvers.Name), new(Names.Description, type: stringType, pureResolver: Resolvers.Description), new(Names.Locations, type: locationListType, pureResolver: Resolvers.Locations), new(Names.Args, type: argumentListType, pureResolver: Resolvers.Arguments), new(Names.IsRepeatable, type: nonNullBooleanType, pureResolver: Resolvers.IsRepeatable), new(Names.OnOperation, type: nonNullBooleanType, pureResolver: Resolvers.OnOperation) { DeprecationReason = TypeResources.Directive_UseLocation },
public DirectiveDefinition(DirectiveNode parsedDirective) { ParsedDirective = parsedDirective ?? throw new ArgumentNullException(nameof(parsedDirective)); Reference = new NameDirectiveReference(parsedDirective.Name.Value); TypeReference = new SyntaxTypeReference( new NamedTypeNode(parsedDirective.Name), TypeContext.None); }
protected override ObjectTypeDefinition CreateDefinition(ITypeDiscoveryContext context) { SyntaxTypeReference nonNullStringType = Parse($"{ScalarNames.String}!"); return(new ObjectTypeDefinition( Names.__DirectiveArgument, TypeResources.___DirectiveArgument_Description, runtimeType: typeof(ArgumentNode)) { Fields = { new(Names.Name, type: nonNullStringType, pureResolver: Resolvers.Name), new(Names.Value, type: nonNullStringType, pureResolver: Resolvers.Value) } });
protected override ObjectTypeDefinition CreateDefinition(ITypeDiscoveryContext context) { SyntaxTypeReference nonNullStringType = Parse($"{ScalarNames.String}!"); SyntaxTypeReference locationListType = Parse($"[{nameof(__DirectiveArgument)}!]!"); return(new ObjectTypeDefinition( Names.__AppliedDirective, TypeResources.___AppliedDirective_Description, typeof(DirectiveNode)) { Fields = { new(Names.Name, type: nonNullStringType, pureResolver: Resolvers.Name), new(Names.Args, type: locationListType, pureResolver: Resolvers.Arguments) } });
protected override ObjectTypeDefinition CreateDefinition(ITypeDiscoveryContext context) { SyntaxTypeReference stringType = Create(ScalarNames.String); SyntaxTypeReference typeListType = Parse($"[{nameof(__Type)}!]!"); SyntaxTypeReference typeType = Create(nameof(__Type)); SyntaxTypeReference nonNullTypeType = Parse($"{nameof(__Type)}!"); SyntaxTypeReference directiveListType = Parse($"[{nameof(__Directive)}!]!"); SyntaxTypeReference appDirectiveListType = Parse($"[{nameof(__AppliedDirective)}!]!"); var def = new ObjectTypeDefinition(Names.__Schema, Schema_Description, typeof(ISchema)) { Fields = { new(Names.Description, type: stringType, pureResolver: Resolvers.Description), new(Names.Types, Schema_Types, typeListType, pureResolver: Resolvers.Types), new(Names.QueryType, Schema_QueryType, nonNullTypeType, pureResolver: Resolvers.QueryType), new(Names.MutationType, Schema_MutationType, typeType, pureResolver: Resolvers.MutationType), new(Names.SubscriptionType, Schema_SubscriptionType, typeType, pureResolver: Resolvers.SubscriptionType), new(Names.Directives, Schema_Directives, directiveListType, pureResolver: Resolvers.Directives), } }; if (context.DescriptorContext.Options.EnableDirectiveIntrospection) { def.Fields.Add(new( Names.AppliedDirectives, type: appDirectiveListType, pureResolver: Resolvers.AppliedDirectives)); } return(def); }
internal ConnectionType( NameString connectionName, ITypeReference nodeType, bool withTotalCount) { if (nodeType is null) { throw new ArgumentNullException(nameof(nodeType)); } ConnectionName = connectionName.EnsureNotEmpty(nameof(connectionName)); NameString edgeTypeName = NameHelper.CreateEdgeName(connectionName); SyntaxTypeReference edgesType = TypeReference.Parse( $"[{edgeTypeName}!]", TypeContext.Output, factory: _ => new EdgeType(connectionName, nodeType)); Definition = CreateTypeDefinition(withTotalCount, edgesType); Definition.Name = NameHelper.CreateConnectionName(connectionName); Definition.Dependencies.Add(new(nodeType)); Definition.Configurations.Add( new CompleteConfiguration( (c, d) => { var definition = (ObjectTypeDefinition)d; ObjectFieldDefinition nodes = definition.Fields.First(IsNodesField); nodes.Type = TypeReference.Parse( $"[{c.GetType<IType>(nodeType).Print()}]", TypeContext.Output); }, Definition, ApplyConfigurationOn.Naming, nodeType, TypeDependencyKind.Named)); Definition.Configurations.Add( new CompleteConfiguration( (c, _) => EdgeType = c.GetType <IEdgeType>(TypeReference.Create(edgeTypeName)), Definition, ApplyConfigurationOn.Completion)); }
protected override ObjectTypeDefinition CreateDefinition(ITypeDiscoveryContext context) { SyntaxTypeReference stringType = Create(ScalarNames.String); SyntaxTypeReference booleanType = Create(ScalarNames.Boolean); SyntaxTypeReference kindType = Parse($"{nameof(__TypeKind)}!"); SyntaxTypeReference typeType = Create(nameof(__Type)); SyntaxTypeReference fieldListType = Parse($"[{nameof(__Field)}!]"); SyntaxTypeReference typeListType = Parse($"[{nameof(__Type)}!]"); SyntaxTypeReference enumValueListType = Parse($"[{nameof(__EnumValue)}!]"); SyntaxTypeReference inputValueListType = Parse($"[{nameof(__InputValue)}!]"); SyntaxTypeReference directiveListType = Parse($"[{nameof(__AppliedDirective)}!]!"); var def = new ObjectTypeDefinition( Names.__Type, TypeResources.Type_Description, typeof(IType)) { Fields = { new(Names.Kind, type: kindType, pureResolver: Resolvers.Kind), new(Names.Name, type: stringType, pureResolver: Resolvers.Name), new(Names.Description, type: stringType, pureResolver: Resolvers.Description), new(Names.Fields, type: fieldListType, pureResolver: Resolvers.Fields) { Arguments = { new(Names.IncludeDeprecated, type: booleanType) { DefaultValue = BooleanValueNode.False, RuntimeDefaultValue = false, } } },
private static void CreateNodesField( IIdSerializer serializer, IList <ObjectFieldDefinition> fields, int index) { SyntaxTypeReference nodes = TypeReference.Parse("[Node]!"); SyntaxTypeReference ids = TypeReference.Parse("[ID!]!"); var field = new ObjectFieldDefinition( Nodes, Relay_NodesField_Description, nodes, ResolveNodeAsync) { Arguments = { new(Ids, Relay_NodesField_Ids_Description, ids) } }; fields.Insert(index, field); ValueTask <object?> ResolveNodeAsync(IResolverContext ctx) => ResolveManyNode(ctx, serializer); }
protected override ObjectTypeDefinition CreateDefinition(ITypeDiscoveryContext context) { SyntaxTypeReference stringType = Create(ScalarNames.String); SyntaxTypeReference nonNullStringType = Parse($"{ScalarNames.String}!"); SyntaxTypeReference nonNullTypeType = Parse($"{nameof(__Type)}!"); SyntaxTypeReference nonNullBooleanType = Parse($"{ScalarNames.Boolean}!"); SyntaxTypeReference argumentListType = Parse($"[{nameof(__InputValue)}!]!"); SyntaxTypeReference directiveListType = Parse($"[{nameof(__AppliedDirective)}!]!"); var def = new ObjectTypeDefinition( Names.__Field, TypeResources.Field_Description, typeof(IOutputField)) { Fields = { new(Names.Name, type: nonNullStringType, pureResolver: Resolvers.Name), new(Names.Description, type: stringType, pureResolver: Resolvers.Description), new(Names.Args, type: argumentListType, pureResolver: Resolvers.Arguments), new(Names.Type, type: nonNullTypeType, pureResolver: Resolvers.Type), new(Names.IsDeprecated, type: nonNullBooleanType, pureResolver: Resolvers.IsDeprecated), new(Names.DeprecationReason, type: stringType, pureResolver: Resolvers.DeprecationReason), } }; if (context.DescriptorContext.Options.EnableDirectiveIntrospection) { def.Fields.Add(new(Names.AppliedDirectives, type: directiveListType, pureResolver: Resolvers.AppliedDirectives)); } return(def); }