deno-libs / gql Goto Github PK
View Code? Open in Web Editor NEW☁ Universal GraphQL HTTP middleware for Deno and Bun
Home Page: https://jsr.io/@deno-libs/gql
License: MIT License
☁ Universal GraphQL HTTP middleware for Deno and Bun
Home Page: https://jsr.io/@deno-libs/gql
License: MIT License
Hello, I use [email protected]
. Type checks on github actions started to fail. Is it related to the gql lib or esh.sh? Would be great to get any help about this.
Download https://esm.sh/xss
Download https://deno.land/x/[email protected]/graphiql/markup.ts
Download https://esm.sh/[email protected]
Download https://esm.sh/v131/[email protected]/deno/cssfilter.mjs
Download https://esm.sh/v131/[email protected]/deno/xss.mjs
Download https://esm.sh/v131/[email protected]/typings/xss.d.ts
error: The source code is invalid, as it does not match the expected hash in the lock file.
Specifier: https://esm.sh/[email protected]
Lock file: /home/runner/work/bromo/bromo/deno.lock
The example on the "deno" page of the repo (https://deno.land/x/[email protected]) doesnt work. The correct version of this is on the deno blog: https://deno.com/blog/build-a-graphql-server-with-deno. The problem is that the addr
parameter in the new Server()
doesnt work anymore and instead just port: 3000
or any other port should be passed.
Pls fix soon as this confuses A LOT of people.
Greetings, Alex
Is it possible to use the https://studio.apollographql.com/sandbox/explorer instead of graphiql
?
I tried to use it from this library, but it seems that the Apollo Server (3) differs because I could not connect to the GraphQL server through the localhost URL.
Does anyone know what it would need to work?
Doc: https://www.apollographql.com/docs/apollo-server/testing/build-run-queries/
Hey there, I was playing around with the oak-example. Unfortunately this isn't working as it shows the following error when I either make a request or attempt to retrieve the schema. Any ideas what the example needs?
{
"x/oak": "https://deno.land/x/[email protected]/mod.ts",
"x/gql": "https://deno.land/x/[email protected]/mod.ts",
"x/graphql_tag": "https://deno.land/x/[email protected]/mod.ts",
"esm/graphql-tools": "https://esm.sh/@graphql-tools/[email protected]",
}
Aligning all versions to what is in the example file also has no effect on the error being displayed
☁ Started on http://localhost:9000
Error: Expected { __validationErrors: undefined, description: undefined, extensions: {}, astNode: { kind: "SchemaDefinition", operationTypes: [Array] }, extensionASTNodes: [], _queryType: Query, _mutationType: undefined, _subscriptionType: undefined, _directives: [@include, @skip, @deprecated, @specifiedBy], _typeMap: { Query: Query, String: String, Boolean: Boolean, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, __Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive, __DirectiveLocation: __DirectiveLocation }, _subTypeMap: {}, _implementationsMap: {} } to be a GraphQL schema.
at Q (https://esm.sh/v117/[email protected]/deno/type/schema.js:2:843)
at W (https://esm.sh/v117/[email protected]/deno/type/validate.js:2:891)
at a (https://esm.sh/v117/[email protected]/deno/graphql.js:2:863)
at https://esm.sh/v117/[email protected]/deno/graphql.js:2:483
at new Promise (<anonymous>)
at R (https://esm.sh/v117/[email protected]/deno/graphql.js:2:466)
at runHttpQuery (https://deno.land/x/[email protected]/common.ts:28:16)
at eventLoopTick (ext:core/01_core.js:165:11)
at async https://deno.land/x/[email protected]/http.ts:91:22
at async handleGraphQL (~/edge/supabase/functions/graphql/index.ts:37:15)
This line is causing the postman software to error, as it sends */*
as the default Accept header.
There should also be a ?raw=true
query parameter check to see if graphiql
should not be served, regardless of option parameter.
Line 24 in 7d78b41
Hi !
Is there any plan to publish this package on jsr too ?
import { Server } from 'https://deno.land/[email protected]/http/server.ts'
import { GraphQLHTTP } from 'https://deno.land/x/gql/mod.ts'
import { makeExecutableSchema } from 'https://esm.sh/@graphql-tools/[email protected]'
import { gql } from 'https://deno.land/x/[email protected]/mod.ts'
const typeDefs = gql`
type Query {
hello: String
}
`
const resolvers = { Query: { hello: () => `Hello World!` } }
const s = new Server({
handler: async (req) => {
const { pathname } = new URL(req.url)
return pathname === '/graphql'
? await GraphQLHTTP<Request>({
schema: makeExecutableSchema({ resolvers, typeDefs }),
graphiql: true
})(req)
: new Response('Not Found', { status: 404 })
},
addr: ':3000'
})
s.listenAndServe()
Output from the terminal:
error: Uncaught SyntaxError: The requested module '/v111/[email protected]/deno/graphql.js' does not provide an export named 'GraphQLError'
at <anonymous> (https://esm.sh/v111/@graphql-tools/[email protected]/deno/utils.js:2:1183)
I am following the updated oak example but trying to inject my own context object, inside the resolver the context is an empty object and there are no errors in the console
import { ServerRequest } from "https://deno.land/x/[email protected]/mod.ts"
interface ResolverContext<T> {
// user is added to context if possible in @auth directive
user?: User;
stripe: StripeClient;
request: T
}
app.use((ctx) => GraphQLHTTP<ServerRequest>({
schema,
graphiql: true,
context: (request): ResolverContext<ServerRequest> => {
return { request, stripe }
}
})(ctx.request.originalRequest as ServerRequest));
i have a simple hello world resolver which logs the context
// TEMP hello world resolver
const helloResolver = {
Query: {
hello: (_args: {}, ctx: ResolverContext<ServerRequest>) => {
console.log({ ctx })
return "world"
}
}
}
{ ctx: {} }
Additionally the typescript typings are incorrect for the GraphQLHTTP<ServerRequest>
. Typescript complains about
error: TS2344 [ERROR]: Type 'ServerRequest' does not satisfy the constraint 'Request<ParamsDictionary, any, any>'.
Type 'ServerRequest' is missing the following properties from type 'Request<ParamsDictionary, any, any>': accepts, acceptsCharsets, acceptsEncodings, acceptsLanguages, and 29 more.
app.use((ctx) => GraphQLHTTP<ServerRequest>({
Hi,
This is great but the oak example does not work.
It appears there is currently no way to set cors headers on the responses. I am using opine middleware and the graphql response is sent immediately, without running the middleware afterwards
Hello,
I have a server configured with http as follows:
const handler = async (req: Request) => {
const { pathname } = new URL(req.url);
return pathname === "/graphql"
? await GraphQLHTTP<Request, Context>({
schema: makeExecutableSchema({
resolvers,
typeDefs: [center, student, instructor, group, scalars],
}),
graphiql: true,
context: () => {
return { request: req };
},
})(req)
: new Response("Not Found", { status: 404 });
};
const server = new Server({ handler });
const listener = Deno.listen({ port: parseInt(PORT) });
console.info("Listening on", listener.addr);
await server.serve(listener);
When I use the graphiql playground it works just fine, but when using from any other client I get 2 erros:
Request Method: OPTIONS Status Code: 405 Method Not Allowed
How could I fix this? Thanks for your time.
Would be awesome!
I see that graphql-http
supports Deno and also validationRules
, but I'm being lazy at the moment and don't feel like changing my GraphQL setup.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.