Search code examples
node.jsvisual-studio-codegraphqlapollo

Using apollo client (or some alternative) server-side to get autocompletion and syntax highlighting


I am currently using standard fetch in my server to query my graphql api. This works, but there is no graphql syntax highlighting / autocomplete and I am unable to use tools such as https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo

My immediate idea was to use apollo-client on the server, however I am unable to figure out if it is possible to set it up without cache and in a lightweight manner.

Perhaps there are some other alternatives for this besides apollo client, that enhance developer experience from just using normal fetch() ?


Solution

  • You may want to use the GraphQL extension by Prisma instead. In addition to supporting .graphql files and gql tag detection, it allows you to add syntax highlighting to any string by just appending a comment:

    const query = /* GraphQL */ `
      query {
        hello
      }
    `