Code Monkey home page Code Monkey logo

Comments (17)

xpepermint avatar xpepermint commented on May 5, 2024 14

I'm satisfied with this:
screen shot 2015-11-15 at 6 38 45 pm
I call schema with require('./schema').

from express-graphql.

mykhailo-riabokon avatar mykhailo-riabokon commented on May 5, 2024 5

I've updated an example for better understanding.

from express-graphql.

wincent avatar wincent commented on May 5, 2024

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.

mykhailo-riabokon avatar mykhailo-riabokon commented on May 5, 2024

@wincent I did not discuss this on the Slack, but it's good idea. Thank you.

from express-graphql.

sulliwane avatar sulliwane commented on May 5, 2024

I found this quite natural: https://github.com/mrblueblue/graphql-express-sqlite/tree/master/schema

from express-graphql.

mykhailo-riabokon avatar mykhailo-riabokon commented on May 5, 2024

@sulliwane what if you have more complex schema?

from express-graphql.

mykhailo-riabokon avatar mykhailo-riabokon commented on May 5, 2024

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.

xpepermint avatar xpepermint commented on May 5, 2024

@mikhail-riabokon I create a file for each query that queries the database.

from express-graphql.

mykhailo-riabokon avatar mykhailo-riabokon commented on May 5, 2024

@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.

leebyron avatar leebyron commented on May 5, 2024

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.

leebyron avatar leebyron commented on May 5, 2024

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.

mykhailo-riabokon avatar mykhailo-riabokon commented on May 5, 2024

@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.

leebyron avatar leebyron commented on May 5, 2024

Okay great.

from express-graphql.

ahelord avatar ahelord commented on May 5, 2024

@xpepermint hello how do you do to join the queries in a single object "GraphQLObjectType"

from express-graphql.

xpepermint avatar xpepermint commented on May 5, 2024

@ahelord Just use the usual require commands and make sure you set fields: () => ({}) (a method that returns fields object).

from express-graphql.

ahelord avatar ahelord commented on May 5, 2024

@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.

ahelord avatar ahelord commented on May 5, 2024

@mykhailo-riabokon hi

you could have this project

https://github.com/mykhailo-riabokon/express_graphql_folder_structure

run with Express

from express-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.