-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Syntax highlighting for vscode #46
Comments
I usually store my schema in its own My code is usually structured like this:
Where you can see that I breakdown my domain model in their own schema and resolver. I use https://www.npmjs.com/package/schemaglue to assemble the schema and resolver in the root const { transpileSchema } = require('graphql-s2s').graphqls2s
const { graphqlHandler } = require('graphql-serverless')
const express = require('express')
const app = express()
const { makeExecutableSchema } = require('graphql-tools')
const glue = require('schemaglue')
const { schema, resolver } = glue('src/graphql')
const executableSchema = makeExecutableSchema({
typeDefs: [transpileSchema(schema)],
resolvers: resolver
})
const graphqlOptions = {
schema: executableSchema,
graphiql: { // If you do not want to host any GraphiQl web interface, leave this property undefined.
endpoint: '/graphiql'
}
}
// Host a GraphQl API on 2 endpoints: '/' and '/graphiql'. '/graphiql' is used to host the GraphiQL web interface.
// If you're not interested in the GraphiQl web interface, leave the above 'graphqlOptions.graphiql' undefined and
// replace the path following ['/', '/graphiql'] with '/'.
app.all(['/', '/graphiql'], graphqlHandler(graphqlOptions))
// Starting the server
app.listen(4000, () => console.log('Server start. Go to http://localhost:4000/graphiql')) Annex
// src/graphql/variant/resolver.js
const { graphqlError } = require('graphql-serverless')
const variantMocks = [{ id: 1, name: 'Variant A', shortDescription: 'First variant.' }, { id: 2, name: 'Variant B', shortDescription: 'Second variant.' }]
exports.resolver = {
Query: {
variants(root, { id }, context) {
const results = id ? variantMocks.filter(p => p.id == id) : variantMocks
if (results.length > 0)
return results
else
throw graphqlError(404, `Variant with id ${id} does not exist.`)
}
}
} |
Is anyone doing syntax highlight for the raw string with vscode?
So far I've got it working by doing a hacky apolloserver
gql
subtitutionexample
This will highlight the standard queries but obviously omits the extensions. Anyone get further with this?
The text was updated successfully, but these errors were encountered: