コード例 #1
0
        private static string GetTypeName(GraphQLIntrospectionTypeRef type)
        {
            switch (type.Kind)
            {
            case GraphQLTypeKind.NonNull:
                return($"{GetTypeName(type.OfType)}!");

            case GraphQLTypeKind.List:
                return($"[{GetTypeName(type.OfType)}]");

            default:
                return(type.Name);
            }
        }
コード例 #2
0
        private static bool IsNonNull(GraphQLIntrospectionTypeRef type)
        {
            if (type is null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (IsListType(type))
            {
                return(IsNonNull(type.OfType));
            }
            else
            {
                return(type.Kind == GraphQLTypeKind.NonNull);
            }
        }
コード例 #3
0
        private static bool IsListType(GraphQLIntrospectionTypeRef type)
        {
            if (type is null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (type.Kind == GraphQLTypeKind.List)
            {
                return(true);
            }

            if (HasSubtype(type.Kind))
            {
                return(IsListType(type.OfType));
            }

            return(false);
        }
コード例 #4
0
        private static GraphQLIntrospectionFullType GetSubtype(GraphQLIntrospectionSchema graphQLIntrospectionSchema, GraphQLIntrospectionTypeRef graphQLIntrospectionTypeRef)
        {
            if (graphQLIntrospectionSchema is null)
            {
                throw new ArgumentNullException(nameof(graphQLIntrospectionSchema));
            }

            if (graphQLIntrospectionTypeRef is null)
            {
                throw new ArgumentNullException(nameof(graphQLIntrospectionTypeRef));
            }

            if (HasSubtype(graphQLIntrospectionTypeRef.Kind))
            {
                return(GetSubtype(graphQLIntrospectionSchema, graphQLIntrospectionTypeRef.OfType));
            }

            return(GetTypeByName(graphQLIntrospectionSchema, graphQLIntrospectionTypeRef.Name));
        }