Comments (2)
CC @Weakky
from graphql-framework-experiment.
Epic ~2-3h call with @Weakky about this (and more). Really good stuff. Will recap. First the outcome:
- We will start with
exported singleton
option. - We will not implement other modes yet, instead getting more feedback
Now, details
-
We came to the conclusion that it is premature to engineer different modes right now.
-
We think there are enough friction points we're addressing, that we do not need to add our own (else engineering effort to compensate) via different modes etc.
-
We noticed a problem that autocomplete for
objectType
enumType
etc. is going to show results fromnexus
package. At least in vscode. A solution is a vscode plugin. For vim, sublime, ... who knows 😬. Our currentapp
singleton approach skirts the issue, for now, but we will have to revisit this. -
We would like to get feedback from users close to the project, like Max S., Matic and a long-time DM'er to Flavian.
-
We considered singleton design like:
import app, { objectType, ... } from 'pumpkins'
where
objectType
is alias toapp.objectType
.We decided against this because the mental model is maybe awkward. named exports that are mutating state of
app
. It is complicated to reason about and api does not help indicate this in any particular way. You just have to "know". -
We considered going with
exported constructor
.Benefit of singleton became clear as to looked at this option.
import { createApp } from 'pumpkins' export const app = createApp() app.server.start()
Now developer has to make
app
available to all schema modules, and import those schema modules back// schema.ts import { app } from './app' app.objectType(...)
+ import './schema' export const app = createApp()
But this is a cyclic dependency which Node/CommonJS modules do not support. And TS compiles down to that. And we're assuming no
.mjs
for now. So this won't work. So we're forced to wrap the schema in a thunk.+ import { App } from 'pumpkins' - import { app } from './app' export default (app: App) => { app.objectType(...) }
All of this starts to make one wonder, what value do I get from just not using the pure approach of native nexus building blocks, e.g.:
import { objectType } from 'nexus' export const Foo = objectType(...)
Developer already knows that api, no cyclic dep headache...
And there are still more issues, going back to our
app.ts
it is not suitable for import because it boots the server (app.server.start()
). More reason to use the native nexus api. Or, user has to add something like as follows to the codebase:// index.ts import { app } from './app' app.server.start()
Overall, the framework experience significantly falls apart.
-
We considered global singleton
It is very interesting, but we don't know enough yet if its going to be the right thing. We think letting users try this as a mode and getting feedback will be great.
from graphql-framework-experiment.
Related Issues (20)
- TS error with inputObjectType default value when using with list=true
- write test for build showing esnext module type works
- nexus:dev reflection failed HOT 8
- Force include directories in build
- Field in interface not get type generated
- Roadmap is empty HOT 3
- @nexus/schema return wrong error object shape
- Empty errors in production environment
- queryField and mutationField not generating types when used in makeSchema HOT 1
- On main page there is broken link to new handbook of typescript
- No source map when debug
- Add connection to ContextAdderLens
- Missing multipart field ‘operations’ (and other related errors) HOT 1
- TypeError: cookieParser is not a function after upgrading to 0.26.1 HOT 1
- Build error using pnpm
- Parallel testing causes multiple servers on the same port, resulting in jest hanging and failing unpredictably
- unhandledRejection
- Announcing the Sunsetting of Nexus Framework and a New Focus on Nexus Schema
- How do You use socket.io
- [email protected] does not support @prisma/[email protected]
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 graphql-framework-experiment.