Executable Document

Tanka GraphQL splits the GraphQL document into two parts: executable document and type system document. Executable document is the part of the document that is executed by the GraphQL server. Type system document is the part of the document that is used to define the GraphQL schema.

Here's the definition of executable document:

using System;
using System.Text;

namespace Tanka.GraphQL.Language.Nodes;

public sealed class ExecutableDocument : INode
{
    public readonly FragmentDefinitions? FragmentDefinitions;
    public readonly OperationDefinitions? OperationDefinitions;

    public ExecutableDocument(
        OperationDefinitions? operationDefinitions,
        FragmentDefinitions? fragmentDefinitions)
    {
        OperationDefinitions = operationDefinitions;
        FragmentDefinitions = fragmentDefinitions;
    }

    public NodeKind Kind => NodeKind.ExecutableDocument;
    public Location? Location => null;

    public static implicit operator ExecutableDocument(string value)
    {
        var parser = Parser.Create(Encoding.UTF8.GetBytes(value));
        return parser.ParseExecutableDocument();
    }

    public static implicit operator ExecutableDocument(ReadOnlySpan<byte> value)
    {
        var parser = Parser.Create(value);
        return parser.ParseExecutableDocument();
    }

    public override string ToString()
    {
        return Printer.Print(this);
    }
}