-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only emit ternary if there are no args
- Loading branch information
1 parent
ef40f6a
commit 7f3266e
Showing
3 changed files
with
71 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @gqlType */ | ||
export default class SomeType { | ||
/** @gqlField greetz */ | ||
hello(args: { greeting: string }): string { | ||
return `${args.greeting} world!`; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/tests/fixtures/field_definitions/RenamedFieldWithArgs.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,45 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlType */ | ||
export default class SomeType { | ||
/** @gqlField greetz */ | ||
hello(args: { greeting: string }): string { | ||
return `${args.greeting} world!`; | ||
} | ||
} | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
-- SDL -- | ||
type SomeType { | ||
greetz(greeting: String!): String @propertyName(name: "hello") | ||
} | ||
-- TypeScript -- | ||
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull } from "graphql"; | ||
export function getSchema(): GraphQLSchema { | ||
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({ | ||
name: "SomeType", | ||
fields() { | ||
return { | ||
greetz: { | ||
name: "greetz", | ||
type: GraphQLString, | ||
args: { | ||
greeting: { | ||
name: "greeting", | ||
type: new GraphQLNonNull(GraphQLString) | ||
} | ||
}, | ||
resolve(source, args, context, info) { | ||
return source.hello(source, args, context, info); | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
return new GraphQLSchema({ | ||
types: [SomeTypeType] | ||
}); | ||
} |