Comments (4)
I was able solve my use case by making ApolloServer lazy load:
import { ApolloServer } from 'apollo-server-express'
import { ApolloServerPluginDrainHttpServer } from 'apollo-server-core'
function graphql_plugin_(path) {
/** @type {import('vite').ServerHook} */
const configureServer = async server=>{
/** @type {Promise<import('express').Router>} */
let router_promise
server
.middlewares
.use(async (req, res, next)=>{
if (!router_promise) {
router_promise = new Promise(async resolve=>{
const { typeDefs, resolvers } = await server.ssrLoadModule('@app/service-domain')
const apollo = new ApolloServer({
typeDefs,
resolvers,
plugins: [ApolloServerPluginDrainHttpServer({
httpServer: server.httpServer
})],
})
await apollo.start()
resolve(
apollo.getMiddleware({
path
})
)
})
}
const router = await router_promise
router(req, res, next)
})
}
return { configureServer }
}
from solid-start.
The issue with something like this is that now you have to figure out how to integrate this into the adapters since they don't use vite middleware to build their server.. so doing stuff with the vite server creates a split where u need to setup the build step and dev step separately. Maybe we can brainstorm how to do this from within entry-server itself without involving vite.
from solid-start.
In the case of Apollo, there's a different adapter for each platform. I don't know if having to support the dev & prod adapters separately can be avoided in all cases. Making it easier to manage each adapter by creating the right abstractions seems doable & will form a base layer if a universal api is created.
Perhaps it would make sense to start with the most complicated api, probably being node/express, as a base for a universal abstraction. I'm not very familiar with the other platform apis other than Lambda, but if there is any use case unique to the other platform, then it can be added to the universal abstraction.
I like the idea of handling as many use cases with solid-start (entry-server, api routes, etc), since the logic will be usable across all adapters. But I do think it should also allow full usage of the adapter's platform, as solid-start apps will be used in many different circumstances.
from solid-start.
We do want to enable you to use platform specific primitives where you want, and you would be consciously opting out of universal deployment for that app. I see Cloudflare workers KV or Durable Object beings examples of this. But I don't think the vite config is the correct place for this since that's working in dev only. In prod your entry-server is the main place to initialize these things. including lazy loading via dynamic imports..
Could you try what this might look like via a dynamic import in entry-server
. We do support middleware in there so this might work.
Closing this for now, but you can open it again if things don't work as you want!
from solid-start.
Related Issues (20)
- [Bug?]: SolidStart fails to start with Daisyui and tailwindcss HOT 20
- [Bug?]: resolve type fail on `moduleResolution: "Bundler"` HOT 2
- [Bug?]: rename the index.tsx file to the name of the folder always gives a 404 HOT 5
- [Bug?]: bun create solid error on windows 11 HOT 1
- [Bug?]: Server functions that throw or return redirects when called in an action do not redirect HOT 10
- [Bug?]: Vite field in the app config has wrong types HOT 1
- [Bug?]: server function that contain await prisma function will throws error HOT 3
- [Bug?]: dup signIn import from @solid-mediaket/auth -> build error HOT 5
- [Bug?]: `Button type attribute has not been set.` in templates
- [Bug?]: createResource fails if using SSR and an exception is thrown in the wrapped function HOT 4
- [ssr]: Spreading `readOnly: false` on input applies `readonly` HOT 2
- [Bug?]: Middleware returning Response is not working properly
- [Bug?]: SolidStart aws_lambda preset unable to serve JS and CSS artifacts when deployed to AWS Lambda HOT 4
- [Bug?]: Client bundle including imports from "use server" functions HOT 2
- [Bug?]: 404 page doesn't work in cloudflare pages HOT 2
- [Feature?]: Allow `init` of projects with both `vitest` and `tailwindcss` HOT 2
- [Bug?]: Deno downloading error - npm package 'uWebSockets.js' does not exist HOT 3
- [Bug]: `bun create solid@latest` doesn't work HOT 1
- [Bug?]: Session "spreads" the userId string into session.data HOT 3
- [Bug?]: `📜 Docs / 📜 Deploy Docs (push) Failing after 38s`
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 solid-start.