In my project, I configured .graphqlconfig.yaml li...
# orm-help
k
In my project, I configured .graphqlconfig.yaml like this
Copy code
projects:
  app:
    schemaPath: src/schema.graphql
    extensions:
      endpoints:
        default: '<http://localhost:4000>'
      prepare-bundle: src/generated/app.graphql
      codegen:
        - generator: prisma-binding
          language: typescript
          output:
            binding: src/generated/app.ts
  prisma:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: prisma/prisma.yml
      codegen:
        - generator: prisma-binding
          language: typescript
          output:
            binding: src/generated/prisma.ts
j
Apologies I missed your reply to this. I have a few questions: - What command do I need to run to generate TypeScript definitions using the above? When I run
graphql codegen
I get:
TypeError: Cannot read property 'type' of undefined
- Where does src/generated/app.graphql come from? Is that generated by running
graphql codegen
?
I feel like a proper example would be really useful
j
This only seems to relate to prisma definitions. I’d like to get TypeScript definitions for my
graphql-yoga
server.
n
I see! you have to transfer this configuration to the server part: https://github.com/prismagraphql/prisma/blob/master/examples/hooks/.graphqlconfig.yml#L8-L12
k
What command do I need to run to generate TypeScript definitions using the above?
There are 3 steps. 1. Run
graphql get-schema --project prisma
to generate
src/generated/prisma.graphql
2. Run
graphql prepare
to generate
src/generated/app.graphql
from
src/schema.graphql
3. Run
graphql codegen
to generate
src/generated/app.ts
and
src/generated/prisma.ts
from
src/generated/*.graphql
files.
👍 3
❤️ 1
Where does src/generated/app.graphql come from?
It comes from
src/schema.graphql
file which I configured. Please look up graphql-cli-prepare and graphql-import modules. https://github.com/graphql-cli/graphql-cli-prepare#graphql-config-extensions https://github.com/prismagraphql/graphql-import
j
Sorry for missing this again - thanks so much for your reply. I’ve run the above commands, but
graphql prepare
doesn’t seem to output anything at all. The contents of my
.graphqlconfig.yml
is here: https://gist.github.com/jonlambert/e8db2819d30bacf65d4064d90ab50f6a
k
I found typo in your .graphqlconfig.yml. please try again!
I added a comment to your gist 👍🏻
j
Thanks dude. Good catch! I looked over that completely
Unfortunately I’m still getting the error:
TypeError: Cannot read property 'type' of undefined
I’ve added a full trace in the gist
k
it seems that your
schema.graphql
is not correct.
I don't know the exact cause of the error, but if you use the same schema as the official tutorial, I think it will work.