Comments (17)
I'm satisfied with this:
I call schema with require('./schema')
.
from express-graphql.
I've updated an example for better understanding.
from express-graphql.
Thanks for sharing! While throwing everything in a single schema.js
file is a great way to get started, it's true that it becomes unwieldy as the schema grows. You example definitely goes a long way towards imposing order.
Have you tried discussing this with other people on the Slack channel? I expect that others are probably exploring this question just like you are, and it would be interesting to share opinions.
from express-graphql.
@wincent I did not discuss this on the Slack, but it's good idea. Thank you.
from express-graphql.
I found this quite natural: https://github.com/mrblueblue/graphql-express-sqlite/tree/master/schema
from express-graphql.
@sulliwane what if you have more complex schema?
from express-graphql.
For example you have next query, which can grow up in future. Will you write all queries in one query file?
query {
viewer {
users (first: 10) {
name,
address {
street,
building,
neighbors {
firstName,
lastName
}
}
}
}
}
from express-graphql.
@mikhail-riabokon I create a file for each query that queries the database.
from express-graphql.
@xpepermint your variant is better than mine. Thank you. But I use not only one file for queries.
-- mutations
----- .......
-- types
----- ....
-- queries
----- root.js
----- queries
--------- queryField
------------ index.js
------------ ....
--------- ......
It make's queries more structured, and it's really help me with "queries mess".
from express-graphql.
Sorry for my misunderstanding, is there a question or issue raised here? I'm not sure what you would like from me or this repo.
from express-graphql.
My personal opinion is that splitting large schema up across many files is a good idea and something I would encourage.
The reason the example in this repo builds a schema in a single file is because it is quite small and I wanted to keep the example simple.
from express-graphql.
@leebyron Actually I have asked about folder structure because it's hard to keep everything in one file. That's why we have discussed that, and @xpepermint gave good example and I have updated my, with more than "one level" of queries. So for now, I think this question can be closed, if you do not have any suggestions. Thank you.
from express-graphql.
Okay great.
from express-graphql.
@xpepermint hello how do you do to join the queries in a single object "GraphQLObjectType"
from express-graphql.
@ahelord Just use the usual require
commands and make sure you set fields: () => ({})
(a method that returns fields object).
from express-graphql.
@xpepermint I'm sorry, do not ask well.
How do you assemble all the graphql query files in another file to parse the object GraphQLObjectType
from express-graphql.
you could have this project
https://github.com/mykhailo-riabokon/express_graphql_folder_structure
run with Express
from express-graphql.
Related Issues (20)
- depth-limit HOT 1
- Is there a way to customize a logger HOT 1
- Unhandled errors does not provide mutation or query name HOT 1
- Graphiql playground not displayed in the browser HOT 1
- UnhandledPromiseRejectionWarning: Unhandled promise rejection HOT 1
- Why isn't the callback of app.listen() called when using express-graphql middleware? HOT 4
- Build when installed from GitHub HOT 1
- throw new MiddlewareError(`Type ${type} exists in middleware but is missing in Schema.`);
- TypeScript - merge declarations for request and response types
- Cannot install with graphql 16.0.1 HOT 10
- Update GraphQL Schema at runtime HOT 4
- Graphql 16.2.0 support HOT 9
- Processing timeout HOT 1
- About compatible version for an old graphql and node
- Swallow GraphQL errors by Express HOT 6
- Peer dependency error on new installation of graphql HOT 8
- Unmet Peer version, need to update supported dependencies HOT 9
- revert revert "Allow custom handling of runtime query errors" HOT 1
- Unable to find Prisma Client in GraphQL context. Please provide it under the `context[\"prisma\"]` key. HOT 1
- Support for running method on every call
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-graphql.