Skip to content

Commit

Permalink
Merge pull request #268 from jamiter/patch-1
Browse files Browse the repository at this point in the history
Document `.graphql` file imports in Meteor
  • Loading branch information
Sashko Stubailo authored Apr 4, 2017
2 parents f9c87b7 + 3118e26 commit cb473aa
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/source/meteor.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,36 @@ createApolloServer(req => ({
});
```

## Importing `.graphql` files

An easy way to work with GraphQL is by importing `.graphql` files directly using the `import` syntax.

```bash
meteor add swydo:graphql
```

Instead of the `/imports/api/schema.js` file, create a `/imports/api/schema.graphql` file with the same content as before:

```graphql
type Query {
say: String
}
```

One of the benefits you'll get right away is good highlighting by GitHub and your IDE!

Now we can import the schema:

```js
import typeDefs from '/imports/api/schema.graphql';
```

Use `typeDefs` as before in the above examples. You can [pass it directly to `makeExecutableSchema`](https://github.com/apollographql/graphql-tools/pull/300) like before.

The import syntax will also work for any other `.graphql` file besides your main schema. So you'll be able to import query, mutation and subscription files without needing to manually parse them with the [graphql-tag](https://github.com/apollographql/graphql-tag).

For more benefits, see the [GrahpQL build plugin README](https://github.com/Swydo/meteor-graphql/blob/master/README.md#benefits).

## Blaze

If you are looking to integrate Apollo with [Blaze](http://blazejs.org/), you can use the [swydo:blaze-apollo](https://github.com/Swydo/blaze-apollo) package:
Expand Down

0 comments on commit cb473aa

Please sign in to comment.