-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff8d27e
commit f6daf11
Showing
33 changed files
with
187 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,5 @@ export class VC { | |
} | ||
} | ||
|
||
/** @gqlContext */ | ||
export type Ctx = YogaInitialContext & { vc: VC }; |
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
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
1 change: 1 addition & 0 deletions
1
src/tests/fixtures/resolver_context/ClassMethodWithContextValue.ts
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,3 +1,4 @@ | ||
/** @gqlContext */ | ||
type GratsContext = { | ||
greeting: string; | ||
}; | ||
|
1 change: 1 addition & 0 deletions
1
src/tests/fixtures/resolver_context/ClassMethodWithContextValue.ts.expected
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,6 +1,7 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlContext */ | ||
type GratsContext = { | ||
greeting: string; | ||
}; | ||
|
1 change: 1 addition & 0 deletions
1
src/tests/fixtures/resolver_context/ClassMethodWithContextValueExported.ts
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,3 +1,4 @@ | ||
/** @gqlContext */ | ||
export type GratsContext = { | ||
greeting: string; | ||
}; | ||
|
1 change: 1 addition & 0 deletions
1
src/tests/fixtures/resolver_context/ClassMethodWithContextValueExported.ts.expected
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,6 +1,7 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlContext */ | ||
export type GratsContext = { | ||
greeting: string; | ||
}; | ||
|
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,12 +1,13 @@ | ||
/** @gqlType */ | ||
export class SomeType { | ||
/** @gqlField */ | ||
greeting(args: unknown, ctx?: SomeType): string { | ||
greeting(args: unknown, ctx?: SomeCtx): string { | ||
// This is fine since Grats will always pass ctx. It's fine for | ||
// the resolver to _also_ work _without_ ctx, as long as it's | ||
// safe for Grats to pass ctx. | ||
return ctx?.greeting ?? "Hello, World!"; | ||
} | ||
} | ||
|
||
type SomeType = { greeting: string }; | ||
/** @gqlContext */ | ||
type SomeCtx = { greeting: string }; |
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
1 change: 1 addition & 0 deletions
1
src/tests/fixtures/resolver_context/FunctionWithContextValue.ts
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,3 +1,4 @@ | ||
/** @gqlContext */ | ||
type GratsContext = { | ||
greeting: string; | ||
}; | ||
|
1 change: 1 addition & 0 deletions
1
src/tests/fixtures/resolver_context/FunctionWithContextValue.ts.expected
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,6 +1,7 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlContext */ | ||
type GratsContext = { | ||
greeting: string; | ||
}; | ||
|
1 change: 1 addition & 0 deletions
1
src/tests/fixtures/resolver_context/MultipleClassMethodsReferencingContextValue.ts
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,3 +1,4 @@ | ||
/** @gqlContext */ | ||
type GratsContext = { | ||
greeting: string; | ||
}; | ||
|
1 change: 1 addition & 0 deletions
1
src/tests/fixtures/resolver_context/MultipleClassMethodsReferencingContextValue.ts.expected
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,6 +1,7 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlContext */ | ||
type GratsContext = { | ||
greeting: string; | ||
}; | ||
|
2 changes: 2 additions & 0 deletions
2
src/tests/fixtures/resolver_context/MultipleContextValuesUsed.invalid.ts
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,2 @@ | ||
/** @gqlContext */ | ||
type Context = {}; |
18 changes: 18 additions & 0 deletions
18
src/tests/fixtures/resolver_context/contextTag.ts.expected
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,18 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlContext */ | ||
type Context = {}; | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
-- SDL -- | ||
|
||
-- TypeScript -- | ||
import { GraphQLSchema } from "graphql"; | ||
export function getSchema(): GraphQLSchema { | ||
return new GraphQLSchema({ | ||
types: [] | ||
}); | ||
} |
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,9 @@ | ||
type Ctx = {}; | ||
|
||
/** @gqlType */ | ||
class User { | ||
/** @gqlField */ | ||
greeting(_args: unknown, _ctx: Ctx): string { | ||
return "Hello"; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/tests/fixtures/resolver_context/contextTypeNotTagged.ts.expected
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,34 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
type Ctx = {}; | ||
|
||
/** @gqlType */ | ||
class User { | ||
/** @gqlField */ | ||
greeting(_args: unknown, _ctx: Ctx): string { | ||
return "Hello"; | ||
} | ||
} | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
-- Error Report -- | ||
src/tests/fixtures/resolver_context/contextTypeNotTagged.ts:6:34 - error: Add a @gqlContext tag | ||
|
||
6 greeting(_args: unknown, _ctx: Ctx): string { | ||
~~~ | ||
|
||
src/tests/fixtures/resolver_context/contextTypeNotTagged.ts:1:1 | ||
1 type Ctx = {}; | ||
~~~~~~~~~~~~~~ | ||
This is the type declaration | ||
|
||
-- Code Action: "Tag context declaration with @gqlContext" (add-context-tag) -- | ||
- Original | ||
+ Fixed | ||
|
||
@@ -1,1 +1,2 @@ | ||
+ /** @gqlContext */ | ||
type Ctx = {}; |
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
Oops, something went wrong.