示例#1
0
        public SchemaGraph(
            IReadOnlyDictionary <string, INamedType> types,
            IReadOnlyDictionary <string, Dictionary <string, IField> > fields,
            IReadOnlyDictionary <string, Dictionary <string, InputObjectField> > inputFields,
            IReadOnlyDictionary <string, DirectiveType> directiveTypes,
            IReadOnlyDictionary <string, Dictionary <string, Resolver> > resolvers,
            IReadOnlyDictionary <string, Dictionary <string, Subscriber> > subscribers,
            IReadOnlyDictionary <string, IValueConverter> scalarSerializers,
            string queryTypeName        = "Query",
            string mutationTypeName     = "Mutation",
            string subscriptionTypeName = "Subscription",
            IEnumerable <DirectiveInstance> directives = null)
        {
            _types             = types;
            _fields            = fields;
            _inputFields       = inputFields;
            _directiveTypes    = directiveTypes;
            _resolvers         = resolvers;
            _subscribers       = subscribers;
            _scalarSerializers = scalarSerializers;
            _directives        = new DirectiveList(directives);

            Query = GetNamedType <ObjectType>(queryTypeName) ?? throw new ArgumentNullException(
                              nameof(types),
                              $"Could not find root type 'Query' from given types");

            Mutation     = GetNamedType <ObjectType>(mutationTypeName);
            Subscription = GetNamedType <ObjectType>(subscriptionTypeName);
        }
示例#2
0
 public Argument(IType type, object defaultValue            = null, string description = null,
                 IEnumerable <DirectiveInstance> directives = null)
 {
     Type         = type ?? throw new ArgumentNullException(nameof(type));
     DefaultValue = defaultValue;
     Description  = description ?? string.Empty;
     _directives  = new DirectiveList(directives);
 }
示例#3
0
 public EnumValue(
     string value,
     string?description = null,
     IEnumerable <DirectiveInstance>?directives = null,
     string?deprecationReason = null)
 {
     Description       = description ?? string.Empty;
     Value             = value;
     DeprecationReason = deprecationReason;
     _directives       = new DirectiveList(directives);
 }
示例#4
0
        public InputObjectField(
            IType type,
            string description  = null,
            object defaultValue = null,
            IEnumerable <DirectiveInstance> directives = null)
        {
            if (!TypeIs.IsInputType(type))
            {
                throw new ArgumentOutOfRangeException(
                          $" Type '{type}' is not valid input type");
            }

            Type         = type;
            Description  = description ?? string.Empty;
            DefaultValue = defaultValue;
            _directives  = new DirectiveList(directives);
        }
示例#5
0
        public UnionType(string name, IEnumerable <ObjectType> possibleTypes, string description = null,
                         IEnumerable <DirectiveInstance> directives = null)
        {
            Name        = name;
            Description = description ?? string.Empty;
            _directives = new DirectiveList(directives);

            foreach (var possibleType in possibleTypes)
            {
                if (PossibleTypes.ContainsKey(possibleType.Name))
                {
                    throw new InvalidOperationException(
                              $"Type {Name} already has possibleType with name {possibleType.Name}");
                }

                PossibleTypes[possibleType.Name] = possibleType;
            }
        }
示例#6
0
        public EnumType(
            string name,
            EnumValues values,
            string description = null,
            IEnumerable <DirectiveInstance> directives = null)
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            Name        = name ?? throw new ArgumentNullException(nameof(name));
            Description = description ?? string.Empty;
            _directives = new DirectiveList(directives);

            foreach (var enumValue in values)
            {
                var value = enumValue.Value ?? new EnumValue(string.Empty);
                _values[enumValue.Key.ToUpperInvariant()] = value;
            }
        }
示例#7
0
        public Field(
            IType type,
            Args?arguments      = null,
            string?description  = null,
            object?defaultValue = null,
            IEnumerable <DirectiveInstance>?directives = null,
            string?deprecationReason = null)
        {
            Type              = type;
            Description       = description ?? string.Empty;
            DefaultValue      = defaultValue;
            DeprecationReason = deprecationReason;
            _directives       = new DirectiveList(directives);

            if (arguments != null)
            {
                foreach (var argument in arguments)
                {
                    _arguments[argument.Key] = argument.Value;
                }
            }
        }
示例#8
0
 public InputObjectType(string name, string description = null, IEnumerable <DirectiveInstance> directives = null)
 {
     Name        = name;
     Description = description ?? string.Empty;
     _directives = new DirectiveList(directives);
 }
示例#9
0
 protected ComplexType(string name, string?description, IEnumerable <DirectiveInstance>?directives)
 {
     Name        = name;
     Description = description ?? string.Empty;
     _directives = new DirectiveList(directives);
 }