Open adamalfredsson opened 5 years ago
Can you share an example repo where you’re following this structure?
I guess this would be a valid example repo: https://github.com/benawad/graphql-ts-server-boilerplate
@nomadoda we're using (prototyping) graphqlgen
with a patched graphql-import
that I believe would support your structure with schema: ./src/modules/
:
https://github.com/prisma/graphql-import/pull/246
The trailing /
on ./src/modules/
tells the patched graphql-import
to just recursively scan for *.graphql
files and concatenate them together.
@schickling @stephenh is the above working?
I tried running graphqlgen with the following .yml file and I keep getting:
Error occurred while reading schema: Syntax Error: Cannot parse the unexpected character ".".
GraphQL request (1:1)
1: ./src/modules/
^
My graphqlgen.yml is as follows:
language: typescript
schema: ./src/modules/
context: ./src/model.ts:Context
models:
files:
- ./src/modules/feeds/model.ts
- ./src/modules/user/model.ts
output: ./src/generated/graphqlgen.ts
resolver-scaffolding:
output: ./src/generated/tmp-resolvers/
layout: file-per-type
Lastly, are there any graphqlgen api's that I can call from a script to generate the resolver types (i.e. graphqlgen.ts
) and their bolierplate for each of these modules separately rather having to constantly go and edit the graphqlgen.yml. This would be quite useful for build time.
@sidroopdaska the above is not working, except you using the patched version from @stephenh of the graphql-import
lib. Problem currently is, graphql-import
only accepts .graphql
files. If you merge your schemas with graphql-tools
and want to import i.E .ts
file. the error you described appears.
Simple sulotion for schema stitching would be to allow also other file extensions in the graphql-import
lib.
I keep my graphql schemas and models in a modular file structure:
src/ —modules/ ——user/ ———user.graphql ———user.model.ts ——post/ ———post.graphql ———post.model.ts
My graphqlgen.yml
throws: 'The schema file ./src/modules/*/.graphql does not exist'