Coder Social home page Coder Social logo

elysia-apollo's People

Contributors

bogeychan avatar runyasak avatar saltyaom avatar

Stargazers

 avatar  avatar

Watchers

 avatar

elysia-apollo's Issues

Error with batched http requests

Getting the below error when attempting batched http requests:

Invalid body, 'type': Expected object

Expected: {
  "query": ""
}

Assuming the guard needs updating to accept an array if allowBatchedHttpRequests: true

File Incorrectly Being Picked Up by TS

When I run tsc this file is incorrectly picked up even after explicitly setting skipLibCheck and exclude options on tsconfig.json.

node_modules/@elysiajs/apollo/src/index.ts:65:41 - error TS2345: Argument of type 'string | (() => Promise<string>)' is not assignable to parameter of type 'ReadableStream<any> | BlobPart | BlobPart[] | FormData | URLSearchParams | null | undefined'.
  Type '() => Promise<string>' is not assignable to type 'ReadableStream<any> | BlobPart | BlobPart[] | FormData | URLSearchParams | null | undefined'.

65                     return new Response(landingPage, {
                                           ~~~~~~~~~~~


Found 1 error in node_modules/@elysiajs/apollo/src/index.ts:65

Even vscode picks it up!

Screenshot_20230918_012650

[Feature Request] Apollo Sandbox

Overview

Due to GraphQL Playground that has been not supported in Apollo Server 4, Apollo Sandbox is the new default landing page for the moment.

Expected Result

There should has an option to enable Apollo Sandbox for elysia-sandbox.

Example Screenshot

image

Sometimes this plugin fails to work after inactivity

Issue with timeouts after long periods of inactivity

Not sure if this is an Elysia issue, bun or a plugin issue, but sometimes this plugin just stops working
I am currently using bun 1.0.15 and if I don't hit any graphql endpoint for a while, say 20 minutes, I have to restart the server all over again

The issue is on the /graphql endpoint which I am hitting like this

const app = new Elysia() .use(cors()) .use( apollo({ schema, path: "/graphql", enablePlayground: true, context: async ({ request }) => { return { db: queryClient }; }, } as ElysiaApolloConfig) ) .listen(8080);

Error when using Apollo plugins.

Trying to disable the disbale the Apollo playground.

Setting
enablePlayground: false
weirdly disables the playground but enables the Apollo Sandbox.

Looking into how to disable sandbox i found that Apollo just accepts plugins to disable or change the behavior of the Sandbox.

When I try

new Elysia()
	.use(
		apollo({
			path: "/test",
			enablePlayground: false,
			typeDefs,
			resolvers,
			plugins: [
				// Install a landing page plugin based on NODE_ENV
				process.env.NODE_ENV === "production"
					? ApolloServerPluginLandingPageProductionDefault({
							graphRef: "my-graph-id@my-graph-variant",
							footer: false,
					  })
					: ApolloServerPluginLandingPageLocalDefault({ footer: false }),
			],
		})
	)
	.listen(3000)

I get error

Type 'import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").ApolloServerPlugin<import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/context").BaseContext>' is not assignable to type 'import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").ApolloServerPlugin<import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/context").BaseContext>'.
  Types of property 'serverWillStart' are incompatible.
    Type '((service: import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerContext) => Promise<void | import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerListener>) | undefined' is not assignable to type '((service: import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerContext) => Promise<...>) | undefined'.
      Type '(service: import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerContext) => Promise<void | import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerListener>' is not assignable to type '(service: import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerContext) => Promise<...>'.
        Type 'Promise<void | import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerListener>' is not assignable to type 'Promise<void | import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerListener>'.
          Type 'void | import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerListener' is not assignable to type 'void | import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerListener'.
            Type 'GraphQLServerListener' is not assignable to type 'void | GraphQLServerListener'.
              Type 'import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerListener' is not assignable to type 'import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").GraphQLServerListener'.
                Types of property 'renderLandingPage' are incompatible.
                  Type '(() => Promise<import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").LandingPage>) | undefined' is not assignable to type '(() => Promise<import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").LandingPage>) | undefined'.
                    Type '() => Promise<import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").LandingPage>' is not assignable to type '() => Promise<import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").LandingPage>'.
                      Type 'Promise<import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").LandingPage>' is not assignable to type 'Promise<import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").LandingPage>'.
                        Type 'import("/home/user/Desktop/BunElysiaApollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").LandingPage' is not assignable to type 'import("/home/user/Desktop/BunElysiaApollo/node_modules/@elysiajs/apollo/node_modules/@apollo/server/dist/esm/externalTypes/plugins").LandingPage'.
                          Types of property 'html' are incompatible.
                            Type 'string | (() => Promise<string>)' is not assignable to type 'string'.
                              Type '() => Promise<string>' is not assignable to type 'string'.

No request in apollo context (context is an empty object)

When I set the context in the Apollo Server Plugin, it doesn't get the request object. I believe this is because of the way Apollo Server 4 changed their context object.

My code:

// Apollo Server Plugin for Elysia
app.use(
  apollo({
      path: '/graphql',
      enablePlayground: true, // Default is disabled in production
      typeDefs, // Import schema from .graphql file
      resolvers, // Import resolvers from resolvers.js,
      context: async (foo) => {

        console.log('foo', foo); // {}

        return {
          dataSources: {

          }
        }
      }
  }),
);

In this case, any request I make the foo object is empty {} with no request information.

https://www.apollographql.com/docs/apollo-server/migration/#context-initialization-function
image

Could this be done in a similar way to how the express middleware for Apollo Server 4 handles the change?

Or maybe I'm missing something obvious to capture the request object in my context, if so, sorry!

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.