Hi, I'm trying to generate types for my queries using this command (tried some other variations as well), But its only generating types based on my schema and not the queries I make in my react components (output here)
I expect to also see some types matching the allPeople query inside allPeople.graphql. What am I doing wrong? Thanks!
I have the same problem. I am running this command:
.\node_modules\.bin\gql-gen --file .\schema.json --template typescript "*.graphql"
and I am getting following output on console:
Loading GraphQL Introspection from file: .\schema.json...
WARNING: It seems like you provided a GraphQL schema instead of GraphQL document:
{ kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'Test', loc: { start: 6, end: 10 } },
variableDefinitions:
[ { kind: 'VariableDefinition',
variable: [Object],
type: [Object],
defaultValue: undefined,
loc: [Object] } ],
directives: [],
selectionSet:
{ kind: 'SelectionSet',
selections: [ [Object] ],
loc: { start: 25, end: 133 } },
loc: { start: 0, end: 133 } }
Generated file written to XXXXX\types.d.ts
Output file is successfully generated but it doesn't contain anything from my *.graphql file.
This "It seems like you provided a GraphQL schema instead of GraphQL document" warning happened to me too, when I upgraded graphql package version from 0.12.3 to 0.13.0
I have just installed it now, and I am using
"apollo-server-express": "^1.3.2",
I am getting the same issues, server-side generation of schema types works great but the client side generation of *.graphql file, does not.
I am using the following command
gql-gen --url http://localhost:3000/graphql --template ts --out ./src/typings \"./**/*.graphql\"
Same issue here. Warning seems to throw on "graphql": "^0.13.1", not on 0.12.3.
See https://github.com/dotansimha/graphql-code-generator/issues/181#issuecomment-368255835
Should be fairly simple to fix. Till then just use 0.12
Please update to the latest version of the codegen, it should work now with 0.13 :)
I'm missing types for queries, too! 馃槩
Could somebody tell me whats wrong?
export const booksQuery = gql`
query BookList {
books {
isbn
title
description,
rating
thumbnails {
url
}
}
}
`;
my package.json
"graphql": "^0.13.2",
"graphql-code-generator": "^0.9.2",
"graphql-codegen-typescript-template": "^0.9.2",
Full demo here: https://github.com/angular-schule/demo-api-codegen
__Any help is highly appreciated!__ 馃憤
@JohannesHoppe try to wrap your glob selector with "...", your command should be something like that:
gql-gen --schema https://api.angular.schule/graphql --template graphql-codegen-typescript-template --out ./src/app/graphql-types.ts "./src/**/*.ts"
(and your probably need to escape it if you are putting it inside package.json). It happens because your file system resolves the * before glob gets it, and it does not support features like ** (for recursive lookup)
Many thanks. You saved my day (or better: night)! 馃槄
馃憤 馃憤 馃憤
Most helpful comment
This "It seems like you provided a GraphQL schema instead of GraphQL document" warning happened to me too, when I upgraded graphql package version from 0.12.3 to 0.13.0