
import { ITextFileOnFileStatFragment, TextFileOnFileStatFragmentDoc } from '@files-stack/core';
import { ApolloClient } from 'apollo-client';


export function createFileService(apolloClient: ApolloClient<any>) {
    // TODO this should be from server side
    function resolveFile(resource: string) {

        const textFile = apolloClient.readFragment<ITextFileOnFileStatFragment>({
            id: `IFileStat:${resource}`,
            fragment: TextFileOnFileStatFragmentDoc,
        });

        return textFile;
    }

    return {
        resolveFile,
    };
}

