-
Notifications
You must be signed in to change notification settings - Fork 17
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
808a452
commit ae2a667
Showing
9 changed files
with
120 additions
and
7 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
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,28 @@ | ||
type GraphqlContext = {}; | ||
|
||
/** @gqlType */ | ||
type Query = unknown; | ||
|
||
/** @gqlField */ | ||
export function someType(_: Query): SomeType { | ||
return new SomeType(); | ||
} | ||
|
||
/** @gqlType */ | ||
class SomeType { | ||
/** @gqlField someName */ | ||
async someOtherName( | ||
args: { greeting: string }, | ||
ctx: GraphqlContext, | ||
): Promise<string> { | ||
return `${args.greeting} World!`; | ||
} | ||
} | ||
|
||
export const query = /* GraphQL */ ` | ||
query { | ||
someType { | ||
someName(greeting: "Hello") | ||
} | ||
} | ||
`; |
42 changes: 42 additions & 0 deletions
42
src/tests/integrationFixtures/aliasedMethod/index.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,42 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
type GraphqlContext = {}; | ||
|
||
/** @gqlType */ | ||
type Query = unknown; | ||
|
||
/** @gqlField */ | ||
export function someType(_: Query): SomeType { | ||
return new SomeType(); | ||
} | ||
|
||
/** @gqlType */ | ||
class SomeType { | ||
/** @gqlField someName */ | ||
async someOtherName( | ||
args: { greeting: string }, | ||
ctx: GraphqlContext, | ||
): Promise<string> { | ||
return `${args.greeting} World!`; | ||
} | ||
} | ||
|
||
export const query = /* GraphQL */ ` | ||
query { | ||
someType { | ||
someName(greeting: "Hello") | ||
} | ||
} | ||
`; | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
{ | ||
"data": { | ||
"someType": { | ||
"someName": "Hello World!" | ||
} | ||
} | ||
} |
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,42 @@ | ||
import { someType as querySomeTypeResolver } from "./index"; | ||
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull } from "graphql"; | ||
export function getSchema(): GraphQLSchema { | ||
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({ | ||
name: "SomeType", | ||
fields() { | ||
return { | ||
someName: { | ||
name: "someName", | ||
type: GraphQLString, | ||
args: { | ||
greeting: { | ||
name: "greeting", | ||
type: new GraphQLNonNull(GraphQLString) | ||
} | ||
}, | ||
resolve(source, args, context, info) { | ||
return source.someOtherName(args, context, info); | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
const QueryType: GraphQLObjectType = new GraphQLObjectType({ | ||
name: "Query", | ||
fields() { | ||
return { | ||
someType: { | ||
name: "someType", | ||
type: SomeTypeType, | ||
resolve(source) { | ||
return querySomeTypeResolver(source); | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
return new GraphQLSchema({ | ||
query: QueryType, | ||
types: [QueryType, SomeTypeType] | ||
}); | ||
} |