src/Language/Parser.php
public static function parse($source, array $options = [])
    {
        $sourceObj = $source instanceof Source ? $source : new Source($source);
        $parser    = new self($sourceObj, $options);

        return $parser->parseDocument();
    }
public static function parse($source, array $options = [])
    {
        $sourceObj = $source instanceof Source ? $source : new Source($source);
        $parser    = new self($sourceObj, $options);

        return $parser->parseDocument();
    }
Given a GraphQL source, parses it into a `GraphQL\Language\AST\DocumentNode`.
Throws `GraphQL\Error\SyntaxError` if a syntax error is encountered.

Available options:

noLocation: boolean,
(By default, the parser creates AST nodes that know the location
in the source that they correspond to. This configuration flag
disables that behavior for performance or testing.)

allowLegacySDLEmptyFields: boolean
If enabled, the parser will parse empty fields sets in the Schema
Definition Language. Otherwise, the parser will follow the current
specification.

This option is provided to ease adoption of the final SDL specification
and will be removed in a future major release.

allowLegacySDLImplementsInterfaces: boolean
If enabled, the parser will parse implemented interfaces with no `&`
character between each interface. Otherwise, the parser will follow the
current specification.

This option is provided to ease adoption of the final SDL specification
and will be removed in a future major release.

experimentalFragmentVariables: boolean,
(If enabled, the parser will understand and parse variable definitions
contained in a fragment definition. They'll be represented in the
`variableDefinitions` field of the FragmentDefinitionNode.

The syntax is identical to normal, query-defined variables. For example:

fragment A($var: Boolean = false) on T  {
...
}

Note: this feature is experimental and may change or be removed in the
future.)

@param Source|string $source
@param bool[]        $options

@return DocumentNode

@throws SyntaxError

@api