Beispiel #1
0
 public ScalarTypeDefinitionNode WithDescription(
     StringValueNode?description)
 {
     return(new ScalarTypeDefinitionNode(
                Location, Name, description,
                Directives));
 }
        private DirectiveDefinitionNode ParseDirectiveDefinition()
        {
            TokenInfo start = Start();

            StringValueNode?description = ParseDescription();

            ExpectDirectiveKeyword();
            ExpectAt();

            NameNode name = ParseName();
            List <InputValueDefinitionNode> arguments =
                ParseArgumentDefinitions();

            bool isRepeatable = SkipRepeatableKeyword();

            ExpectOnKeyword();

            List <NameNode> locations = ParseDirectiveLocations();

            Location?location = CreateLocation(in start);

            return(new DirectiveDefinitionNode
                   (
                       location,
                       name,
                       description,
                       isRepeatable,
                       arguments,
                       locations
                   ));
        }
Beispiel #3
0
        /// <summary>
        /// Parses input value definitions.
        /// <see cref="InputValueDefinitionNode" />:
        /// Description? Name : Type DefaultValue? Directives[isConstant=true]?
        /// </summary>
        /// <param name="context">The parser context.</param>
        private InputValueDefinitionNode ParseInputValueDefinition()
        {
            TokenInfo start = Start();

            StringValueNode?description = ParseDescription();
            NameNode        name        = ParseName();

            ExpectColon();
            ITypeNode  type         = ParseTypeReference();
            IValueNode?defaultValue = SkipEqual()
                ? ParseValueLiteral(true)
                : null;
            List <DirectiveNode> directives =
                ParseDirectives(true);

            Location?location = CreateLocation(in start);

            return(new InputValueDefinitionNode
                   (
                       location,
                       name,
                       description,
                       type,
                       defaultValue,
                       directives
                   ));
        }
        private StringValueNode?TakeDescription()
        {
            StringValueNode?description = _description;

            _description = null;
            return(description);
        }
Beispiel #5
0
 public InputValueDefinitionNode WithDescription(
     StringValueNode?description)
 {
     return(new InputValueDefinitionNode(
                Location, Name, description,
                Type, DefaultValue, Directives));
 }
Beispiel #6
0
 public FieldDefinitionNode WithDescription(
     StringValueNode?description)
 {
     return(new FieldDefinitionNode(
                Location, Name, description,
                Arguments, Type, Directives));
 }
        private DirectiveDefinitionNode ParseDirectiveDefinition()
        {
            ISyntaxToken start = _reader.Token;

            StringValueNode?description = ParseDescription();

            ExpectDirectiveKeyword();
            ExpectAt();

            NameNode name = ParseName();
            List <InputValueDefinitionNode> arguments = ParseArgumentDefinitions();

            bool isRepeatable = SkipRepeatableKeyword();

            ExpectOnKeyword();

            List <NameNode> locations = ParseDirectiveLocations();

            var location = new Location(start, _reader.Token);

            return(new DirectiveDefinitionNode
                   (
                       location,
                       name,
                       description,
                       isRepeatable,
                       arguments,
                       locations
                   ));
        }
Beispiel #8
0
 public ObjectTypeDefinitionNode WithDescription(
     StringValueNode?description)
 {
     return(new ObjectTypeDefinitionNode(
                Location, Name, description,
                Directives, Interfaces, Fields));
 }
Beispiel #9
0
        /// <summary>
        /// Parses input value definitions.
        /// <see cref="InputValueDefinitionNode" />:
        /// Description? Name : Type DefaultValue? Directives[isConstant=true]?
        /// </summary>
        /// <param name="context">The parser context.</param>
        private InputValueDefinitionNode ParseInputValueDefinition()
        {
            ISyntaxToken start = _reader.Token;

            StringValueNode?description = ParseDescription();
            NameNode        name        = ParseName();

            ExpectColon();
            ITypeNode  type         = ParseTypeReference();
            IValueNode?defaultValue = SkipEqual()
                ? ParseValueLiteral(true)
                : null;
            List <DirectiveNode> directives = ParseDirectives(true);

            var location = new Location(start, _reader.Token);

            return(new InputValueDefinitionNode
                   (
                       location,
                       name,
                       description,
                       type,
                       defaultValue,
                       directives
                   ));
        }
Beispiel #10
0
        /// <summary>
        /// Parses a interface type or object type field definition.
        /// <see cref="FieldDefinitionNode" />:
        /// Description?
        /// Name ArgumentsDefinition? : Type Directives[isConstant=true]?
        /// </summary>
        /// <param name="context">The parser context.</param>
        private FieldDefinitionNode ParseFieldDefinition()
        {
            TokenInfo start = Start();

            StringValueNode?description = ParseDescription();
            NameNode        name        = ParseName();
            List <InputValueDefinitionNode> arguments =
                ParseArgumentDefinitions();

            ExpectColon();
            ITypeNode            type       = ParseTypeReference();
            List <DirectiveNode> directives = ParseDirectives(true);

            Location?location = CreateLocation(in start);

            return(new FieldDefinitionNode
                   (
                       location,
                       name,
                       description,
                       arguments,
                       type,
                       directives
                   ));
        }
Beispiel #11
0
 public SchemaDefinitionNode(
     Location?location,
     StringValueNode?description,
     IReadOnlyList <DirectiveNode> directives,
     IReadOnlyList <OperationTypeDefinitionNode> operationTypes)
     : base(location, directives, operationTypes)
 {
     Description = description;
 }
 public EnumValueDefinitionNode(
     Location?location,
     NameNode name,
     StringValueNode?description,
     IReadOnlyList <DirectiveNode> directives)
     : base(location, name, directives)
 {
     Description = description;
 }
 public UnionTypeDefinitionNode(
     Location location,
     NameNode name,
     StringValueNode?description,
     IReadOnlyList <DirectiveNode> directives,
     IReadOnlyList <NamedTypeNode> types)
     : base(location, name, directives, types)
 {
     Description = description;
 }
Beispiel #14
0
 public InterfaceTypeDefinitionNode(
     Location location,
     NameNode name,
     StringValueNode?description,
     IReadOnlyList <DirectiveNode> directives,
     IReadOnlyList <FieldDefinitionNode> fields)
     : base(location, name, directives, fields)
 {
     Description = description;
 }
Beispiel #15
0
 public InputObjectTypeDefinitionNode(
     Location?location,
     NameNode name,
     StringValueNode?description,
     IReadOnlyList <DirectiveNode> directives,
     IReadOnlyList <InputValueDefinitionNode> fields)
     : base(location, name, directives, fields)
 {
     Description = description;
 }
        public StringGraphQLParser(ReadOnlySpan <char> graphQLData)
        {
            if (graphQLData.Length == 0)
            {
                throw new ArgumentException(
                          LangResources.GraphQLData_Empty,
                          nameof(graphQLData));
            }

            _reader      = new StringGraphQLReader(graphQLData);
            _description = null;
        }
        internal StringGraphQLParser(StringGraphQLReader reader)
        {
            if (reader.Kind == TokenKind.EndOfFile)
            {
                throw new ArgumentException(
                          LangResources.GraphQLData_Empty,
                          nameof(reader));
            }

            _reader      = reader;
            _description = null;
        }
Beispiel #18
0
 public InputValueDefinitionNode(
     Location?location,
     NameNode name,
     StringValueNode?description,
     ITypeNode type,
     IValueNode?defaultValue,
     IReadOnlyList <DirectiveNode> directives)
     : base(location, name, directives)
 {
     Description  = description;
     Type         = type ?? throw new ArgumentNullException(nameof(type));
     DefaultValue = defaultValue;
 }
 public DirectiveDefinitionNode WithDescription(
     StringValueNode?description)
 {
     return(new DirectiveDefinitionNode
            (
                Location,
                Name,
                description,
                IsRepeatable,
                Arguments,
                Locations
            ));
 }
Beispiel #20
0
        /// <summary>
        /// Determines whether the specified <see cref="StringValueNode"/>
        /// is equal to the current <see cref="StringValueNode"/>.
        /// </summary>
        /// <param name="other">
        /// The <see cref="StringValueNode"/> to compare with the current
        /// <see cref="StringValueNode"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="StringValueNode"/> is equal
        /// to the current <see cref="StringValueNode"/>;
        /// otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(StringValueNode?other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(other, this))
            {
                return(true);
            }

            return(other.Value.Equals(Value, StringComparison.Ordinal));
        }
 public FieldDefinitionNode(
     Location?location,
     NameNode name,
     StringValueNode?description,
     IReadOnlyList <InputValueDefinitionNode> arguments,
     ITypeNode type,
     IReadOnlyList <DirectiveNode> directives)
     : base(location, name, directives)
 {
     Description = description;
     Arguments   = arguments
                   ?? throw new ArgumentNullException(nameof(arguments));
     Type = type
            ?? throw new ArgumentNullException(nameof(type));
 }
        public Utf8GraphQLParser(
            ReadOnlySpan <byte> graphQLData,
            ParserOptions?options = null)
        {
            if (graphQLData.Length == 0)
            {
                throw new ArgumentException(GraphQLData_Empty, nameof(graphQLData));
            }

            options ??= ParserOptions.Default;
            _createLocation    = !options.NoLocations;
            _allowFragmentVars = options.Experimental.AllowFragmentVariables;
            _reader            = new Utf8GraphQLReader(graphQLData);
            _description       = null;
        }
        internal Utf8GraphQLParser(
            Utf8GraphQLReader reader,
            ParserOptions?options = null)
        {
            if (reader.Kind == TokenKind.EndOfFile)
            {
                throw new ArgumentException(GraphQLData_Empty, nameof(reader));
            }

            options ??= ParserOptions.Default;
            _createLocation    = !options.NoLocations;
            _allowFragmentVars = options.Experimental.AllowFragmentVariables;
            _reader            = reader;
            _description       = null;
        }
Beispiel #24
0
        /// <summary>
        /// Parses an enum value definitions.
        /// <see cref="EnumValueDefinitionNode" />:
        /// Description? EnumValue Directives[isConstant=true]?
        /// </summary>
        /// <param name="context">The parser context.</param>
        private EnumValueDefinitionNode ParseEnumValueDefinition()
        {
            ISyntaxToken start = _reader.Token;

            StringValueNode?     description = ParseDescription();
            NameNode             name        = ParseName();
            List <DirectiveNode> directives  = ParseDirectives(true);

            var location = new Location(start, _reader.Token);

            return(new EnumValueDefinitionNode
                   (
                       location,
                       name,
                       description,
                       directives
                   ));
        }
Beispiel #25
0
 public DirectiveDefinitionNode(
     Location?location,
     NameNode name,
     StringValueNode?description,
     bool isRepeatable,
     IReadOnlyList <InputValueDefinitionNode> arguments,
     IReadOnlyList <NameNode> locations)
 {
     Location = location;
     Name     = name
                ?? throw new ArgumentNullException(nameof(name));
     Description  = description;
     IsRepeatable = isRepeatable;
     Arguments    = arguments
                    ?? throw new ArgumentNullException(nameof(arguments));
     Locations = locations
                 ?? throw new ArgumentNullException(nameof(locations));
 }
Beispiel #26
0
        /// <summary>
        /// Parses an enum value definitions.
        /// <see cref="EnumValueDefinitionNode" />:
        /// Description? EnumValue Directives[isConstant=true]?
        /// </summary>
        /// <param name="context">The parser context.</param>
        private EnumValueDefinitionNode ParseEnumValueDefinition()
        {
            TokenInfo start = Start();

            StringValueNode?     description = ParseDescription();
            NameNode             name        = ParseName();
            List <DirectiveNode> directives  =
                ParseDirectives(true);

            Location?location = CreateLocation(in start);

            return(new EnumValueDefinitionNode
                   (
                       location,
                       name,
                       description,
                       directives
                   ));
        }
        private void WriteDescription(
            StringValueNode?description,
            DocumentWriter writer)
        {
            if (description != null)
            {
                writer.WriteStringValue(description);

                if (_indent)
                {
                    writer.WriteLine();
                }
                else
                {
                    writer.WriteSpace();
                }

                WriteIndentation(writer);
            }
        }
Beispiel #28
0
        public Utf8GraphQLParser(
            ReadOnlySpan <byte> graphQLData,
            ParserOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (graphQLData.Length == 0)
            {
                throw new ArgumentException(
                          LangResources.GraphQLData_Empty,
                          nameof(graphQLData));
            }

            _options           = options;
            _createLocation    = !options.NoLocations;
            _allowFragmentVars = options.Experimental.AllowFragmentVariables;
            _reader            = new Utf8GraphQLReader(graphQLData);
            _description       = null;
        }
Beispiel #29
0
        internal Utf8GraphQLParser(
            Utf8GraphQLReader reader,
            ParserOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (reader.Kind == TokenKind.EndOfFile)
            {
                throw new ArgumentException(
                          LangResources.GraphQLData_Empty,
                          nameof(reader));
            }

            _options           = options;
            _createLocation    = !options.NoLocations;
            _allowFragmentVars = options.Experimental.AllowFragmentVariables;
            _reader            = reader;
            _description       = null;
        }
Beispiel #30
0
        /// <summary>
        /// Parses a interface type or object type field definition.
        /// <see cref="FieldDefinitionNode" />:
        /// Description?
        /// Name ArgumentsDefinition? : Type Directives[isConstant=true]?
        /// </summary>
        /// <param name="context">The parser context.</param>
        private FieldDefinitionNode ParseFieldDefinition()
        {
            ISyntaxToken start = _reader.Token;

            StringValueNode?description = ParseDescription();
            NameNode        name        = ParseName();
            List <InputValueDefinitionNode> arguments = ParseArgumentDefinitions();

            ExpectColon();
            ITypeNode            type       = ParseTypeReference();
            List <DirectiveNode> directives = ParseDirectives(true);

            var location = new Location(start, _reader.Token);

            return(new FieldDefinitionNode
                   (
                       location,
                       name,
                       description,
                       arguments,
                       type,
                       directives
                   ));
        }