Exemple #1
0
 public EnumValue(string description, IEnumerable <DirectiveInstance> directives = null,
                  string deprecationReason = null)
 {
     Description       = description ?? string.Empty;
     DeprecationReason = deprecationReason;
     _directives       = new DirectiveList(directives);
 }
Exemple #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);
 }
Exemple #3
0
 public ScalarType(
     string name,
     IValueConverter converter,
     string description = null,
     IEnumerable <DirectiveInstance> directives = null)
 {
     Name        = name;
     Converter   = converter;
     Description = description ?? string.Empty;
     _directives = new DirectiveList(directives);
 }
        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);
        }
Exemple #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;
            }
        }
Exemple #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;
            }
        }
Exemple #7
0
 public SchemaGraph(
     Dictionary <string, INamedType> types,
     Dictionary <string, Dictionary <string, IField> > fields,
     Dictionary <string, Dictionary <string, InputObjectField> > inputFields,
     Dictionary <string, DirectiveType> directiveTypes,
     Dictionary <string, Dictionary <string, Resolver> > resolvers,
     Dictionary <string, Dictionary <string, Subscriber> > subscribers,
     IEnumerable <DirectiveInstance> directives = null)
 {
     _types          = types;
     _fields         = fields;
     _inputFields    = inputFields;
     _directiveTypes = directiveTypes;
     _resolvers      = resolvers;
     _subscribers    = subscribers;
     Query           = GetNamedType <ObjectType>("Query") ?? throw new ArgumentNullException(
                                 nameof(types),
                                 $"Could not find root type 'Query' from given types");
     Mutation     = GetNamedType <ObjectType>("Mutation");
     Subscription = GetNamedType <ObjectType>("Subscription");
     _directives  = new DirectiveList(directives);
 }
Exemple #8
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;
                }
            }
        }
 public InputObjectType(string name, string description = null, IEnumerable <DirectiveInstance> directives = null)
 {
     Name        = name;
     Description = description ?? string.Empty;
     _directives = new DirectiveList(directives);
 }
Exemple #10
0
 protected ComplexType(string name, string description, IEnumerable <DirectiveInstance> directives)
 {
     Name        = name;
     Description = description ?? string.Empty;
     _directives = new DirectiveList(directives);
 }