Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import multiple queries on client #20

Closed
micchickenburger opened this issue Oct 24, 2017 · 2 comments
Closed

Import multiple queries on client #20

micchickenburger opened this issue Oct 24, 2017 · 2 comments

Comments

@micchickenburger
Copy link

It doesn't seem that I can rename query on import. For instance, if I try the following:

import testQuery from './test.graphql';

or

import { query as testQuery } from './test.graphql';

I receive the following error:

Exception in defer callback: TypeError: Cannot read property 'kind' of undefined
    at checkDocument (http://localhost:3000/packages/modules.js?hash=401da39174ff7894f4c0f56bdb7e1fd90ca15cb0:1213:13)
    at getQueryDefinition (http://localhost:3000/packages/modules.js?hash=401da39174ff7894f4c0f56bdb7e1fd90ca15cb0:1253:5)
    at QueryManager.watchQuery (http://localhost:3000/packages/modules.js?hash=401da39174ff7894f4c0f56bdb7e1fd90ca15cb0:4215:31)
    at ApolloClient.watchQuery (http://localhost:3000/packages/modules.js?hash=401da39174ff7894f4c0f56bdb7e1fd90ca15cb0:4798:34)
    at Blaze.TemplateInstance.gqlQuery (http://localhost:3000/packages/swydo_blaze-apollo.js?hash=7915f676b5c961fc380b475b07e249564591b4b2:250:28)
    at Blaze.View.<anonymous> (http://localhost:3000/app/app.js?hash=25bc50a15f463632fc27b8e1e3858cb6fb3a4cc0:2277:26)
    at http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1934:20
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:3744:12)
    at http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1932:29
    at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:2271:12)

The consequence of this is that I can only import one query per JavaScript document. I know that I can do comment includes of other graphql files; however, this doesn't help me on the client where each query accepts different variables.

@jamiter
Copy link
Contributor

jamiter commented Oct 27, 2017

Hi! This package leverages the graphql-tag package where they are working on implementing this feature. See apollographql/graphql-tag#122 for more info.

As soon as they added it in a new release, I'll make sure this package will be updated to!

@jamiter
Copy link
Contributor

jamiter commented Dec 19, 2017

@micchickenburger, this is now available in 0.4.0!

You can now import multiple queries like this:

query foo { foo }

query bar { bar }
import { foo, bar } from './your-graphql-file.graphql';

See apollographql/graphql-tag#122

Let me know if you run into any issues!

@jamiter jamiter closed this as completed Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants