Giter Site home page Giter Site logo

gql's People

Contributors

michaelfedora avatar talentlessguy avatar tylercheswickcarvana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gql's Issues

Oak server example not working

Issue

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?

Dependencies

{
    "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

Logs

☁  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)

Documentation Example Failing

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)

405 and CORS

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
  • CORS

How could I fix this? Thanks for your time.

Context is an empty object with Oak

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>({

Some issue with xss dependency hash in deno.lock

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

Headers are not getting set

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

`validationRules` support

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.

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.