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

Commit

Permalink
fix: change order of arguments to align with graphql
Browse files Browse the repository at this point in the history
BREAKING CHANGE:  Its now schema, query instead of query, schema, so the
inputs in all projects need to change

Closes #4
  • Loading branch information
Daniel Schmidt authored and DanielMSchmidt committed Jan 22, 2019
1 parent 77a4c7b commit 5e5cd09
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
40 changes: 20 additions & 20 deletions src/__tests__/graphqlObservable-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe("graphqlObservable", function() {
a: { data: { launched: expectedData } }
});

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

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

const nameFilter = of("apollo11");
const result = graphql(
query,
schema,
query,
{
query: dataSource
},
Expand Down Expand Up @@ -248,7 +248,7 @@ describe("graphqlObservable", function() {
a: { data: { launched: [expectedData[0]] } }
});

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

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

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

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

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

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

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

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

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

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

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

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

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

Expand All @@ -563,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 = graphql(query, fieldResolverSchema, {});
const result = graphql(fieldResolverSchema, query, {});
m.expect(result.pipe(take(1))).toBeObservable(expected);
}
);
Expand All @@ -582,7 +582,7 @@ describe("graphqlObservable", function() {
const fakeRequest = { name: "RocketShip" };
const commandContext = of(fakeRequest);

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

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

const commandContext = of("a request");

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

Expand Down Expand Up @@ -640,8 +640,8 @@ describe("graphqlObservable", function() {
name: "RocketShip"
};
const result = graphql(
mutation,
schema,
mutation,
{
mutation: commandContext
},
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/reference/starWarsQuery-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const graphql = (
const taggedQuery = gql`
${query}
`;
graphqlObservable(taggedQuery, schema, contextValue, variableValues)
graphqlObservable(schema, taggedQuery, contextValue, variableValues)
.pipe(take(1))
.subscribe(resolve);
});
Expand Down
2 changes: 1 addition & 1 deletion src/reactive-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ function isFieldWithResolver(
}

export default function graphql<T = object>(
doc: DocumentNode,
schema: Schema,
doc: DocumentNode,
context: object = {},
variables: object = {}
): Observable<{ data: T }> {
Expand Down

0 comments on commit 5e5cd09

Please sign in to comment.