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

Add docs URL to error message #181

Merged
merged 3 commits into from
May 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Expect active development and potentially significant breaking changes in the `0

### vNEXT

- Improve error message when a dev forgets `gql` to link to docs. [PR #181](https://github.com/apollostack/apollo-client/pull/181)
- ...


Expand Down
9 changes: 6 additions & 3 deletions src/queries/getFromAST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {

export function getMutationDefinition(doc: Document): OperationDefinition {
if (doc.kind !== 'Document') {
throw new Error('Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag?');
throw new Error(`Expecting a parsed GraphQL document. Perhaps you need to wrap the query \
string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql`);
}

if (doc.definitions.length > 1) {
Expand All @@ -24,7 +25,8 @@ export function getMutationDefinition(doc: Document): OperationDefinition {

export function getQueryDefinition(doc: Document): OperationDefinition {
if (doc.kind !== 'Document') {
throw new Error('Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag?');
throw new Error(`Expecting a parsed GraphQL document. Perhaps you need to wrap the query \
string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql`);
}

if (doc.definitions.length > 1) {
Expand All @@ -42,7 +44,8 @@ export function getQueryDefinition(doc: Document): OperationDefinition {

export function getFragmentDefinition(doc: Document): FragmentDefinition {
if (doc.kind !== 'Document') {
throw new Error('Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag?');
throw new Error(`Expecting a parsed GraphQL document. Perhaps you need to wrap the query \
string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql`);
}

if (doc.definitions.length > 1) {
Expand Down