-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export subscription and schema stuff not from the root package
- Loading branch information
Showing
21 changed files
with
209 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
console.warn( | ||
`@graphql-yoga/common package has been deprecated and will no longer receive updates in the next major.`, | ||
) | ||
console.warn(`Please use 'graphql-yoga' npm package instead!'`) | ||
import './warning.js' | ||
export * from 'graphql-yoga' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './warning.js' | ||
export * from 'graphql-yoga/schema' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './warning.js' | ||
export * from 'graphql-yoga/subscription' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
console.warn( | ||
`@graphql-yoga/common package has been deprecated and will no longer receive updates in the next major.`, | ||
) | ||
console.warn(`Please use 'graphql-yoga' npm package instead!'`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { | ||
IExecutableSchemaDefinition, | ||
makeExecutableSchema, | ||
} from '@graphql-tools/schema' | ||
import { GraphQLSchemaWithContext, YogaInitialContext } from './types.js' | ||
|
||
export function createSchema<TContext = YogaInitialContext>( | ||
opts: IExecutableSchemaDefinition<TContext>, | ||
): GraphQLSchemaWithContext<TContext> { | ||
return makeExecutableSchema<TContext>(opts) | ||
} | ||
|
||
export function getDefaultSchema< | ||
TContext, | ||
>(): GraphQLSchemaWithContext<TContext> { | ||
return createSchema<TContext>({ | ||
typeDefs: /* GraphQL */ ` | ||
""" | ||
Greetings from GraphQL Yoga! | ||
""" | ||
type Query { | ||
greetings: String | ||
} | ||
type Subscription { | ||
""" | ||
Current Time | ||
""" | ||
time: String | ||
} | ||
`, | ||
resolvers: { | ||
Query: { | ||
greetings: () => | ||
'This is the `greetings` field of the root `Query` type', | ||
}, | ||
Subscription: { | ||
time: { | ||
async *subscribe() { | ||
while (true) { | ||
yield { time: new Date().toISOString() } | ||
await new Promise((resolve) => setTimeout(resolve, 1000)) | ||
} | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
} |
Oops, something went wrong.