-- 1. Configuration
vim.lsp.config('graphql', {
    cmd = { "graphql-lsp", "server", "-m", "stream" },
    filetypes = { "graphql", "gql", "javascript", "typescript", "typescriptreact", "javascriptreact" },

    -- This ensures GraphQL only starts if it finds a config file
    root_markers = {
        ".graphqlrc",
        ".graphqlrc.json",
        ".graphqlrc.yaml",
        ".graphqlrc.yml",
        "graphql.config.json",
        "graphql.config.yaml",
        "graphql.config.yml"
    },

    capabilities = require("cmp_nvim_lsp").default_capabilities(),
})

-- 2. Enable the server
vim.lsp.enable('graphql')
