private GraphQLType ParseType()
        {
            GraphQLType type;
            int         start = _currentToken.Start;

            if (Skip(TokenKind.BRACKET_L))
            {
                type = ParseType();
                Expect(TokenKind.BRACKET_R);
                type = new GraphQLListType
                {
                    Type     = type,
                    Location = GetLocation(start)
                };
            }
            else
            {
                type = ParseNamedType();
            }

            return(Skip(TokenKind.BANG)
                ? new GraphQLNonNullType
            {
                Type = type,
                Location = GetLocation(start)
            }
                : type);
        }
Example #2
0
        private GraphQLType ParseType()
        {
            GraphQLType type  = null;
            var         start = this.currentToken.Start;

            if (this.Skip(TokenKind.BRACKET_L))
            {
                type = this.ParseType();
                this.Expect(TokenKind.BRACKET_R);
                type = new GraphQLListType()
                {
                    Type     = type,
                    Location = this.GetLocation(start)
                };
            }
            else
            {
                type = this.ParseNamedType();
            }

            if (this.Skip(TokenKind.BANG))
            {
                return(new GraphQLNonNullType()
                {
                    Type = type,
                    Location = this.GetLocation(start)
                });
            }

            return(type);
        }
Example #3
0
        protected TypeSyntax GetCSharpTypeFromGraphQLListType(GraphQLListType type, IEnumerable <ASTNode> allDefinitions)
        {
            var underlyingType = this.GetCSharpTypeFromGraphQLType(type.Type, allDefinitions);

            var argumentList = SyntaxFactory.TypeArgumentList(
                SyntaxFactory.SeparatedList <TypeSyntax>()
                .Add(underlyingType));

            return(SyntaxFactory.GenericName(SyntaxFactory.Identifier(typeof(IEnumerable).Name), argumentList));
        }
Example #4
0
        private string PrintListType(GraphQLListType node)
        {
            var type = Print(node.Type);

            return($"[{type}]");
        }