import { CreateUntitledFileDocument, ICreateUntitledFileMutationVariables } from '@files-stack/core';
import { ApolloClient } from 'apollo-client';
import { URI } from '@vscode/monaco-editor/esm/vs/base/common/uri';


export function createUntitledEditorService(apolloClient: ApolloClient<any>) {


    function loadOrCreate(resource?: URI, hasAssociatedFilePath?: boolean, mode?: string, initialValue?: string, encoding?: string) {
        return apolloClient.mutate<any, ICreateUntitledFileMutationVariables>({
            mutation: CreateUntitledFileDocument,
            variables: {
                encoding,
                hasAssociatedFilePath,
                initialValue,
                mode,
                resource,
            },
        });
    }

    return {
        loadOrCreate,
    };
}
