mattkrick / cashay

:moneybag: Relay for the rest of us :moneybag:
MIT License
453 stars 28 forks source link

tests and docs for cashay-loader #54

Closed jordanh closed 8 years ago

jordanh commented 8 years ago

Now it's official! 💯

mattkrick commented 8 years ago

Call me crazy, but i think we should word it so the webpack method is the default & the CLI is the back-up, almost footnote-ish ("opinionated software" and whatnot :wink:). I don't really see them as equals, since if you take the webpack route you'll never have to worry about a stale schema. That alone would be enough to make me use webpack in my project.

mattkrick commented 8 years ago

i'll merge for now & we can wordsmith later.

simenbrekken commented 8 years ago

I'm getting Module build failed: ReferenceError: regeneratorRuntime is not defined when implementing the loader from the docs, and as far as I can see regeneratorRuntime isn't actually included anywhere in lib. This might be because you're both running node v6

mattkrick commented 8 years ago

hmmm, must be missing a babel-polyfill somewhere

simenbrekken commented 8 years ago

@jordanh I can't get the loader working after adding babel-polyfill to cashay/src/index.js

import { transformSchema } from 'cashay'
import schema from './index'

// Side-step 'Error: Schema must be an instance of GraphQLSchema.'
const graphql = require('graphql').graphql

export default async () => await transformSchema(schema, graphql)

It just keeps complaining Module build failed: TypeError: doc.then is not a function. I'm a bit confused since the async/await should return a promise no matter what. Could it be something related to the babel-polyfill?

My ./index contains the following:

import mocks from './mocks'
import resolvers from './resolvers'
import createSchema from './createSchema'

export default createSchema({ resolvers, mocks })
mattkrick commented 8 years ago

can confirm, var doc = this.exec(content, this.resource); is returned an object, not a promise, which isn't supposed to happen...

jordanh commented 8 years ago

This is my getCashaySchema.babel.js:

require('babel-register');
require('babel-polyfill');
module.exports = require('./getCashaySchema')();
jordanh commented 8 years ago

@simenbrekken: @mattkrick and I talk about this this morning, I clarified the docs and example for this.

See #58 !