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.

Types are not generated for introspection query

See original GitHub issue

Describe the bug I have a query like this which reads introspection in runtime to figure user permissions. Unfortunately, the generated types do not include the GUserPermissions type at all. But if I add something else to that query, it appears there, but without the introspection part.

export const UserPermissionsQuery = gql`
  query GUserPermissions {
    __schema {
      queryType { fields { name } }
      mutationType { fields { name } }
    }
  }
`

To Reproduce I am using API approach and call it like this. Full introspection is generated in JSON file. I’ve checked and it includes types for __schema, so that should be a problem.

  generate({
    schema: jsonPath,
    out: './src/graph/types.ts',
    template: 'graphql-codegen-typescript-template',
    args: ['./src/**/*graphql.ts'],
    skipSchema: true,
    overwrite: true,
  })

Expected behavior To have TypeScript types based on introspection query.

Environment:

  • OS: Windows 10 x64
  • Codegen: 0.9.2
  • Node: 10.11.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:28 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
danielkczcommented, May 9, 2019

@Jonatthu Well, ask the Microsoft, they have deprecated namespaces from TypeScript. For the same reason, they are not supported by Babel TypeScript implementation, so it’s a kinda wrong path to follow altogether.

3reactions
dotansimhacommented, Mar 1, 2019

Fixed in 0.18.0 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introspection query without generated types - Discuss Dgraph
I'm trying to use a tool to visualize my GraphQL schema. The problem is that it comes with too much garbage. I wanted...
Read more >
Why You Should Disable GraphQL Introspection In Production
GraphQL introspection enables you to query a GraphQL server for information about the underlying schema. This includes data like types, ...
Read more >
Introspection - GraphQL
We designed the type system, so we know what types are available, but if we didn't, we can ask GraphQL, by querying the...
Read more >
How to generate typescript from graphQL typeDefs, not by ...
I have many files with type definitions of different queries, like this: const typeDefs = gql` type Query { hello: String } `...
Read more >
Introspection - Hot Chocolate - ChilliCream GraphQL Platform
Every GraphQL server exposes a __schema and __type field on the query type as well as an __typename field on each type.
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