graphql / vscode-graphql

MIGRATED: VSCode GraphQL extension (autocompletion, go-to definition, syntax highlighting)
https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql
MIT License
557 stars 71 forks source link

Warning: endpoints missing from graphql config. will try 'schema' value(s) instead #227

Closed Albert-Gao closed 3 years ago

Albert-Gao commented 4 years ago

My config

// graphql.config.js

// for VSCode extension https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql

const jwt = 'fake-jwt'

module.exports = {
  projects: {
    default: {
      schema: ['./schema.graphql'],
      documents: ['./app/**/*.{ts,tsx}'],
      endpoints: {
        default: {
          url: 'http://localhost:4000/graphql',
          headers: { Authorization: jwt },
        },
      },
    },
  },
}

Steps:

  1. click the Execute Mutation image

  2. Found the error image

  3. Error in GraphQL Language Server Warning: endpoints missing from graphql config. will try 'schema' value(s) instead

Specifications

GraphQL for VSCode Extension Version: latest from store Version: 1.49.1 Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf Date: 2020-09-16T23:21:17.533Z Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 19.6.0

thiagodebastos commented 3 years ago

@Albert-Gao Did you ever resolve this? I've been stuck on the same issue for quite some time.

Albert-Gao commented 3 years ago

@thiagodebastos Unfortunately, no :(

thiagodebastos commented 3 years ago

@thiagodebastos Unfortunately, no :(

Setting documents to an empty string seems to have done it. I can now successfully execute queries from within VSCode. If that doesn't do it for you, let me know and I will dig deeper into my changes. I really don't know whats going on, I'm still getting my head around where I am regarding backend vs frontend in NextJS and Apollo, but I am getting there!

// graphql.config.js
module.exports = {
  projects: {
    default: {
      schema: 'http://127.0.0.1:7777/api/graphql',
      documents: [],
      endpoints: {
        default: {
          url: 'http://127.0.0.1:7777/api/graphql',
          headers: { Authorization: `Bearer ${process.env.SQUARE_API_TOKEN}` },
        },
      },
    },
  },
};
acao commented 3 years ago

@Albert-Gao @thiagodebastos close but if you see in the readme, it's nested in extensions like this:

module.exports = {
  projects: {
    default: {
      schema: ['./schema.graphql'],
      documents: ['./app/**/*.{ts,tsx}'],
      extensions: { 
        endpoints: {
            default: {
              url: 'http://localhost:4000/graphql',
              headers: { Authorization: jwt },
            },
          },
        },
      },
  },
}

if the endpoint is the same across all projects, you can do this:

module.exports = {
  projects: {
    default: {
      schema: ['./schema.graphql'],
      documents: ['./app/**/*.{ts,tsx}']
    },
  },
  extensions: { 
    endpoints: {
      default: {
        url: 'http://localhost:4000/graphql',
        headers: { Authorization: jwt },
      },
    },
  },
}

this configuration would be treated the same:

module.exports = {
  schema: ['./schema.graphql'],
  documents: ['./app/**/*.{ts,tsx}'],
  extensions: { 
    endpoints: {
      default: {
        url: 'http://localhost:4000/graphql',
        headers: { Authorization: jwt },
      },
    },
  },
}
acao commented 3 years ago

fixed the readme, sorry y'all!