Skip to content

Commit

Permalink
Merge pull request #5 from stackables/fix-type1
Browse files Browse the repository at this point in the history
fix: Return MeshInstance not of any
  • Loading branch information
aarne committed May 27, 2024
2 parents 4fa0f49 + 8697d09 commit faa5e74
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ const subgraphs: SubgraphService[] = [

```typescript
import { buildSubgraphSchema } from "@graphql-tools/federation";
import { createYoga } from "graphql-yoga";

export const localSchema = buildSubgraphSchema({
const schema = buildSubgraphSchema({
typeDefs: /* GraphQL */ `
type Query {
hello: String
Expand All @@ -68,6 +69,8 @@ export const localSchema = buildSubgraphSchema({
},
},
});

export const localSchema = createYoga({ schema });
```

#### Build supergraph definition
Expand Down Expand Up @@ -99,7 +102,7 @@ import { createYoga } from "graphql-yoga";

const config = await createMeshInstance({
supergraphSDL,
localSchema: harness.localSchema,
localSchema: localSchema,
onRemoteRequestHeaders: ({ endpoint }) => {
return {
Authorization: `Bearer ${await getToken(endpoint)}`,
Expand Down
4 changes: 2 additions & 2 deletions src/createMeshInstance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import LocalforageCache from "@graphql-mesh/cache-localforage";
import BareMerger from "@graphql-mesh/merger-bare";
import { getMesh } from "@graphql-mesh/runtime";
import { getMesh, type MeshInstance } from "@graphql-mesh/runtime";
import { InMemoryStoreStorageAdapter, MeshStore } from "@graphql-mesh/store";
import { DefaultLogger, PubSub } from "@graphql-mesh/utils";
import type { YogaServerInstance } from "graphql-yoga";
Expand All @@ -15,7 +15,7 @@ export interface CreateMeshInstanceOptions<T = unknown> {

export async function createMeshInstance<T = unknown>(
opts: CreateMeshInstanceOptions<T>
): Promise<any> {
): Promise<MeshInstance> {
const store = new MeshStore("main", new InMemoryStoreStorageAdapter(), {
readonly: true,
validate: false,
Expand Down
4 changes: 3 additions & 1 deletion src/createSupergraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export interface CreateSupergraphOptions<T = unknown> {
onRemoteRequestHeaders?: OnRemoteRequestHeadersCallback<T>;
}

export async function createSupergraph(opts: CreateSupergraphOptions) {
export async function createSupergraph(
opts: CreateSupergraphOptions
): Promise<string> {
const subgraphs = [...opts.subgraphs];

// insert local to list
Expand Down

0 comments on commit faa5e74

Please sign in to comment.