Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
fix: align export with graphql convention
Browse files Browse the repository at this point in the history
BREAKING CHANGE: All imports need to be `import {graphql}` instead of
`import graphql` from now on

Closes #4
  • Loading branch information
Daniel Schmidt authored and DanielMSchmidt committed Jan 22, 2019
1 parent b2dcaa3 commit 77a4c7b
Show file tree
Hide file tree
Showing 5 changed files with 433 additions and 404 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/fieldNotFoundMessageForType-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLObjectType, GraphQLString, GraphQLScalarType } from "graphql";
import { fieldNotFoundMessageForType } from "..";
import { fieldNotFoundMessageForType } from "../reactive-graphql";

describe("fieldNotFoundMessageForType", () => {
it("returns a helpful message for null", () => {
Expand Down
64 changes: 37 additions & 27 deletions src/__tests__/graphqlObservable-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { marbles } from "rxjs-marbles/jest";
import { makeExecutableSchema } from "graphql-tools";
import gql from "graphql-tag";

import graphqlObservable from "../";
import { graphql } from "../";

const typeDefs = `
type Shuttle {
Expand Down Expand Up @@ -196,7 +196,7 @@ describe("graphqlObservable", function() {
a: { data: { launched: expectedData } }
});

const result = graphqlObservable(query, schema, { query: dataSource });
const result = graphql(query, schema, { query: dataSource });

m.expect(result.pipe(take(1))).toBeObservable(expected);
});
Expand All @@ -218,11 +218,16 @@ describe("graphqlObservable", function() {
});

const nameFilter = of("apollo11");
const result = graphqlObservable(query, schema, {
query: dataSource
}, {
nameFilter
});
const result = graphql(
query,
schema,
{
query: dataSource
},
{
nameFilter
}
);

m.expect(result.pipe(take(1))).toBeObservable(expected);
});
Expand All @@ -243,7 +248,7 @@ describe("graphqlObservable", function() {
a: { data: { launched: [expectedData[0]] } }
});

const result = graphqlObservable(query, schema, {
const result = graphql(query, schema, {
query: dataSource
});

Expand All @@ -265,7 +270,7 @@ describe("graphqlObservable", function() {
a: { data: { launched: [{ name: "discovery" }] } }
});

const result = graphqlObservable(query, schema, {
const result = graphql(query, schema, {
query: dataSource
});

Expand All @@ -287,7 +292,7 @@ describe("graphqlObservable", function() {
a: { data: { launched: [{ title: "challenger" }] } }
});

const result = graphqlObservable(query, schema, {
const result = graphql(query, schema, {
query: dataSource
});

Expand All @@ -307,7 +312,7 @@ describe("graphqlObservable", function() {
const expected = m.cold("(a|)", {
a: { data: { plain: { noFieldResolver: "Yes" } } }
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});

Expand All @@ -322,7 +327,7 @@ describe("graphqlObservable", function() {
const expected = m.cold("(a|)", {
a: { data: { plain: { fieldResolver: "I am a field resolver" } } }
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});

Expand All @@ -345,7 +350,7 @@ describe("graphqlObservable", function() {
}
}
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});

Expand All @@ -368,7 +373,7 @@ describe("graphqlObservable", function() {
}
}
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});

Expand All @@ -389,7 +394,7 @@ describe("graphqlObservable", function() {
}
}
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});
});
Expand All @@ -414,7 +419,7 @@ describe("graphqlObservable", function() {
}
}
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});

Expand All @@ -441,7 +446,7 @@ describe("graphqlObservable", function() {
}
}
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});

Expand All @@ -468,7 +473,7 @@ describe("graphqlObservable", function() {
}
}
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});

Expand All @@ -491,7 +496,7 @@ describe("graphqlObservable", function() {
}
}
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});
});
Expand Down Expand Up @@ -521,7 +526,7 @@ describe("graphqlObservable", function() {
}
}
});
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});
});
Expand All @@ -539,7 +544,7 @@ describe("graphqlObservable", function() {
"reactive-graphql: resolver 'throwingResolver' throws this error: 'Error: my personal error'"
)
);
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
});

Expand All @@ -558,7 +563,7 @@ describe("graphqlObservable", function() {
"reactive-graphql: field 'youDontKnowMe' was not found on type 'Query'. The only fields found in this Object are: plain,item,nested,throwingResolver."
)
);
const result = graphqlObservable(query, fieldResolverSchema, {});
const result = graphql(query, fieldResolverSchema, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
}
);
Expand All @@ -577,7 +582,7 @@ describe("graphqlObservable", function() {
const fakeRequest = { name: "RocketShip" };
const commandContext = of(fakeRequest);

const result = graphqlObservable(mutation, schema, {
const result = graphql(mutation, schema, {
mutation: commandContext
});

Expand All @@ -601,7 +606,7 @@ describe("graphqlObservable", function() {

const commandContext = of("a request");

const result = graphqlObservable(mutation, schema, {
const result = graphql(mutation, schema, {
mutation: commandContext
});

Expand Down Expand Up @@ -634,9 +639,14 @@ describe("graphqlObservable", function() {
const variables = {
name: "RocketShip"
};
const result = graphqlObservable(mutation, schema, {
mutation: commandContext,
}, variables);
const result = graphql(
mutation,
schema,
{
mutation: commandContext
},
variables
);

const expected = m.cold("(a|)", {
a: { data: { shut: { name: "RocketShip" } } }
Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/reference/starWarsQuery-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import gql from "graphql-tag";
import { take } from "rxjs/operators";

import StarWarsSchema from "./starWarsSchema";
import graphqlObservable from "../../";
import { graphql as graphqlObservable } from "../../";

const graphql = (schema, query, _rootValue?, contextValue?, variableValues?) => {
const graphql = (
schema,
query,
_rootValue?,
contextValue?,
variableValues?
) => {
return new Promise(resolve => {
const taggedQuery = gql`
${query}
Expand Down
Loading

0 comments on commit 77a4c7b

Please sign in to comment.