question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow generate types from `gql` with typescript-server plugin

See original GitHub issue

Describe the feature Allow generate types from gql with typescript-server plugin. Currently you can generate them from ‘String’ types but it could be interesting to allow generate them from gql function (import { gql } from ‘graphql-tag’), in this case you might take advantage of plugins for highlighting, linting & prettifying .

Current: (It works!)

const typeDefs = `
  extend type Query {
    capsules(): [Capsule]
    capsule(capsule_serial: String!, id: Boolean): Capsule
  }
`

Proposal: (It doesn’t work)

const typeDefs = gql`
  extend type Query {
    capsules(): [Capsule]
    capsule(capsule_serial: String!, id: Boolean): Capsule
  }
`

This throws The Query definition is not executable.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kamilkisielacommented, Dec 28, 2018

@swcarlosrj Why do you have documents? Do you use typescript-client package or related?

documents are basically operations and fragments, so something client-side. schema should point to a schema or typeDefs

I guess you use typeDefs, so replace documents with schema and put the glob there.

0reactions
kamilkisielacommented, Dec 28, 2018

@swcarlosrj You’re not alone that uses documents this way. @dotansimha maybe we could improve docs or something?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating types from a GraphQL schema
The typescript-resolvers plugin creates a Resolvers type that you can use to add a type to your resolver map, ensuring your resolvers return...
Read more >
typescript - GraphQL Code Generator
This plugin generates the base TypeScript types, based on your GraphQL schema. The types generated by this plugin are simple, and refers to ......
Read more >
Automatically generate Typescript types for your GraphQL ...
graphql-codegen is a tool that automatically generates Typescript types from GraphQL types and resolvers definition. What are we going to build.
Read more >
Generate TypeScript Types from a GraphQL Schema - YouTube
Automatically generate types for your local or remote GraphQL schema, and operations for better type -safety.Learn more about #GraphQL ...
Read more >
How to Generate Typescript Types for GraphQL in React Project
-codegen/cli: core command line file · -codegen/typescript: plugin to generate typescript types · -codegen/typescript-react-apollo: plugin to generate react ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found