public void AddType(GraphType type, TypeCollectionContext context)
        {
            if (type == null)
            {
                return;
            }

            var name = type.CollectTypes(context);

            _types[name] = type;

            type.Fields.Apply(field =>
            {
                var foundType = this[field.Type];
                if (foundType == null)
                {
                    AddType(context.ResolveType(field.Type), context);
                }
            });

            if (type is ObjectGraphType)
            {
                var obj = (ObjectGraphType)type;
                obj.Interfaces.Apply(objectInterface =>
                {
                    var foundType = this[objectInterface];
                    if (foundType == null)
                    {
                        AddType(context.ResolveType(objectInterface), context);
                    }
                });
            }
        }
        private void AddTypeIfNotRegistered(Type type, TypeCollectionContext context)
        {
            var namedType = type.GetNamedType();
            var foundType = FindGraphType(namedType);

            if (foundType == null)
            {
                if (namedType == typeof(PageInfoType))
                {
                    AddType(new PageInfoType(), context);
                }
                else if (namedType.IsGenericType && (namedType.ImplementsGenericType(typeof(EdgeType <>)) || namedType.ImplementsGenericType(typeof(ConnectionType <,>))))
                {
                    AddType((IGraphType)Activator.CreateInstance(namedType), context);
                }
                else if (_builtInCustomScalars.TryGetValue(namedType, out var builtInCustomScalar))
                {
                    AddType(builtInCustomScalar, _context);
                }
                else
                {
                    AddTypeWithLoopCheck(context.ResolveType(namedType), context, namedType);
                }
            }
        }
Beispiel #3
0
        public void AddType <TType>(TypeCollectionContext context)
            where TType : GraphType
        {
            var instance = context.ResolveType(typeof(TType));

            AddType(instance, context);
        }
Beispiel #4
0
        private void AddTypeIfNotRegistered(Type type, TypeCollectionContext context)
        {
            var namedType = type.GetNamedType();
            var foundType = this[namedType];

            if (foundType == null)
            {
                if (namedType == typeof(PageInfoType))
                {
                    AddType(new PageInfoType(), context);
                    return;
                }
                if (namedType.IsGenericType)
                {
                    var genericDefinition = namedType.GetGenericTypeDefinition();
                    if (genericDefinition == typeof(EdgeType <>))
                    {
                        AddType((IGraphType)Activator.CreateInstance(namedType), context);
                        return;
                    }
                    if (genericDefinition == typeof(ConnectionType <>))
                    {
                        AddType((IGraphType)Activator.CreateInstance(namedType), context);
                        return;
                    }
                }
                AddType(context.ResolveType(namedType), context);
            }
        }
        public void AddType <TType>(TypeCollectionContext context)
            where TType : IGraphType
        {
            var type     = typeof(TType).GetNamedType();
            var instance = context.ResolveType(type);

            AddType(instance, context);
        }
Beispiel #6
0
        private void AddTypeIfNotRegistered(Type type, TypeCollectionContext context)
        {
            var foundType = this[type];

            if (foundType == null)
            {
                AddType(context.ResolveType(type), context);
            }
        }
        private void AddTypeIfNotRegistered(IGraphType type, TypeCollectionContext context)
        {
            var(namedType, namedType2) = type.GetNamedTypes();
            namedType ??= context.ResolveType(namedType2);

            var foundType = this[namedType.Name];

            if (foundType == null)
            {
                AddType(namedType, context);
            }
        }
Beispiel #8
0
        private void AddTypeIfNotRegistered(Type type, TypeCollectionContext context)
        {
            var namedType = type.GetNamedType();
            var foundType = this[namedType];

            if (foundType == null)
            {
                if (namedType == typeof(PageInfoType))
                {
                    AddType(new PageInfoType(), context);
                    return;
                }
                if (namedType.IsGenericType)
                {
                    if (namedType.ImplementsGenericType(typeof(EdgeType <>)) ||
                        namedType.ImplementsGenericType(typeof(ConnectionType <,>)))
                    {
                        AddType((IGraphType)Activator.CreateInstance(namedType), context);
                        return;
                    }
                }
                AddTypeWithLoopCheck(context.ResolveType(namedType), context, namedType);
            }
        }