Giter Site home page Giter Site logo

graphcool-lib's People

Contributors

schickling avatar sorenbs avatar timsuchanek 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphcool-lib's Issues

Doesn't work with project alias

const client = new Graphcool(projectAlias, {
  pat: token,
}).api('simple/v1');

doesn't work, results in error message:

'Project not found: '''

even if <alias> is a valid project alias.

Add `getSubscriptionEndpoint` function

Because subscription endpoint addresses are dynamic based on region, it would be helpful if you could expose a method to retrieve it. I will add a FR to the graphcool repo to add it to the System API, although it could also be constructed from just getting the project region from the System API.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

graphcool-lib module is not resolved in TypeScript

The module resolution log shows is following:

======== Resolving module 'grapcool-lib' from '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/src/hello.ts'. ========
Explicitly specified module resolution kind: 'NodeJs'.
'baseUrl' option is set to '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability', using this value to resolve non-relative module name 'grapcool-lib'.
'paths' option is specified, looking for a pattern to match module name 'grapcool-lib'.
Module name 'grapcool-lib', matched pattern ''.
Trying substitution 'node_modules/
', candidate module location: 'node_modules/grapcool-lib'.
Loading module as file / folder, candidate module location '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib', target file type 'TypeScript'.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.ts' does not exist.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.tsx' does not exist.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.d.ts' does not exist.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib' does not exist, skipping all lookups in it.
Trying substitution 'src/types/', candidate module location: 'src/types/grapcool-lib'.
Loading module as file / folder, candidate module location '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/src/types/grapcool-lib', target file type 'TypeScript'.
Loading module 'grapcool-lib' from 'node_modules' folder, target file type 'TypeScript'.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/src/node_modules' does not exist, skipping all lookups in it.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.ts' does not exist.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.tsx' does not exist.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.d.ts' does not exist.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/@types/grapcool-lib.d.ts' does not exist.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/some_directory/sandbox/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/some_directory/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
'baseUrl' option is set to '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability', using this value to resolve non-relative module name 'grapcool-lib'.
'paths' option is specified, looking for a pattern to match module name 'grapcool-lib'.
Module name 'grapcool-lib', matched pattern '
'.
Trying substitution 'node_modules/', candidate module location: 'node_modules/grapcool-lib'.
Loading module as file / folder, candidate module location '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib', target file type 'JavaScript'.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.js' does not exist.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.jsx' does not exist.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib' does not exist, skipping all lookups in it.
Trying substitution 'src/types/
', candidate module location: 'src/types/grapcool-lib'.
Loading module as file / folder, candidate module location '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/src/types/grapcool-lib', target file type 'JavaScript'.
Loading module 'grapcool-lib' from 'node_modules' folder, target file type 'JavaScript'.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/src/node_modules' does not exist, skipping all lookups in it.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.js' does not exist.
File '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/roomsavailability/node_modules/grapcool-lib.jsx' does not exist.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/queries/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/GraphCool/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/some_directory/sandbox/basic ts project structure/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/some_directory/sandbox/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/some_directory/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/Documents/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/omatrot/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name 'grapcool-lib' was not resolved. ========

In my opinion, either the .d.ts file is misplaced in the directory structure or the package.json is incorrect.

Error: The provided pat is not valid for project

import { fromEvent, FunctionEvent } from "graphcool-lib"
const graphcool = fromEvent(event)
const api = graphcool.api("simple/v1")
//This one works only if I open up public permissions
const userId = await createGraphcoolUser(api, email, hash, username, image)
//This one returns error
const token = await graphcool.generateNodeToken(userId, "User")

I wrote more details here:
https://www.graph.cool/forum/t/temp-root-token-in-function-does-not-have-full-permissions/1785/2

0.1.0 New endpoint definition is a breaking change when using outside Graphcool

The new 0.1.0 version assumes, that all endpoint URLs are set in the context by the Graphcool functions. This works well. However, when using graphcool-lib outside Graphcool, to connect to your API, you will now have to specify all endpoints.

Having the possibility to do so is great for working with local etc., but it would be nice if the lib would still contain the default endpoint base urls used by 99% of the projects, otherwise upgrading will mean a lot of changes.

Export FunctionEvent type

It would be great to export the FunctionEvent type in the definition file.
To use it to type event parameter.

import { FunctionEvent } from 'graphcool-lib'

export default async (event: FunctionEvent) => {
  await new Promise(r => setTimeout(r, 50))
  return {
    data: {
      message: `Hello ${event.data.name || 'World'}`
    }
  }
}

Endpoints

In order to support the new docker runtime with graphcool-lib, we need to add endpoint information to the context.

I propose adjusting the GraphcoolContext type to add the endpoint object containing system, simple, relay, subscriptions:

export interface GraphcoolContext {
  token: string
  serviceId: string
  alias: string
  // new endpoints:
  endpoints: {
    system: string
    simple: string
    relay: string
    subscriptions: string
  }
}

As soon as we have the new URL scheme specced out, we should revisit this.

Update:

All endpoints in one subobject

Update 2:

Exact values for the shared cluster:

  • system: https://api.graph.cool/system
  • simple: https://api.graph.cool/simple/v1/cj8sxy1hu009i0103j0vujxhn
  • relay: https://api.graph.cool/relay/v1/cj8sxy1hu009i0103j0vujxhn
  • subscriptions: wss://subscriptions.graph.cool/v1/cj8t01lxf04ke0141a2fr124z

Exact values for the local cluster:

  • system: http://localhost:60000/system
  • simple: http://localhost:60000/simple/v1/cj8sxy1hu009i0103j0vujxhn
  • relay: http://localhost:60000/relay/v1/cj8sxy1hu009i0103j0vujxhn
  • subscriptions: ws://http://localhost:60000/subscriptions/v1/cj8t01lxf04ke0141a2fr124z

can't read property 'graphcool' of undefined

event.context is undefined when graphcool-lib is used in the lambda function (see this line)

I was able to find context property in the event.body JSON.parse(event.body).context

Am I doing something wrong?

True variables support

Adding variables as strings in JS template strings is error-prone because of escaping issues...can we get some true GraphQL variable support?

Problem with Graphcool initialization

Hi there,

I try to use graphcool-lib in the following way:

const client = Graphcool(gcProjectId, { token: gcToken })
const api = client.api('simple/v1')
api.request(` some graphql query`)

But I get following error: TypeError: Cannot set property 'endpoints' of undefined.

PS. I don't use fromEvent function because I try to connect to my GraphCool db from Lambda function.

What am I doing wrong?

Rename `fromEvent` to something more expressive

I think the fromEvent function should be renamed to something that expresses what it does. A few suggestions:

  • graphcoolProjectContext (or getGraphcoolProjectContext)
  • graphcoolProject (or getGraphcoolProject)
  • graphcoolAPI (or getGraphcoolAPI)
  • ...

FR: Expose Express middleware function

Many usecases for graphcool-lib use the library in an Express webtask. It would be nice if the library could expose an Express middleware function (like bodyParser.json()) to easily use it in Express. I now use this middleware function to make the api available directly from the req object:

app.use((req, res, next) => {
  if (req.body.context.graphcool) {
    req.api = fromEvent(req.body).api('simple/v1')
  };
  next()
})

With the function exposed from graphcool-lib, this can become:

app.use(graphcool.initApi())

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.