This file contains hidden or 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
| const ResultType = new GraphQLObjectType({ | |
| name : 'Result', | |
| fields : { | |
| text : { | |
| type : new GraphQLNonNull(GraphQLString) | |
| }, | |
| id : { | |
| type : new GraphQLNonNull(GraphQLID), | |
| resolve: resolveWithInstrumentation((result) => { | |
| return result.id; |
This file contains hidden or 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
| const query = ` | |
| { | |
| search(text: "cat") { | |
| text | |
| id @instrument(tag: "search.id") | |
| } | |
| } | |
| `; |
This file contains hidden or 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
| import { GraphQLNonNull, GraphQLString } from 'graphql'; | |
| import { DirectiveLocation, GraphQLDirective } from 'graphql/type/directives'; | |
| const InstrumentDirective = new GraphQLDirective({ | |
| name: 'instrument', | |
| description: | |
| 'Instrument the time it takes to resolve the field', | |
| locations: [ | |
| DirectiveLocation.FIELD, | |
| ], |
This file contains hidden or 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
| export default Relay.createContainer(StarWarsApp, { | |
| fragments: { | |
| factions: () => Relay.QL` | |
| fragment on Faction @relay(plural: true) { | |
| id, | |
| factionId, | |
| name, | |
| ships(first: 10) { | |
| edges { | |
| node { |
This file contains hidden or 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
| fragment on User @directiveBehavior { | |
| id | |
| } |
This file contains hidden or 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
| query myQuery($someTest: Boolean) { | |
| experimentalField @skip(if: $someTest) | |
| } |
This file contains hidden or 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
| const UserType = new GraphQLObjectType({ | |
| name : 'User', | |
| interfaces: [SearchableType], | |
| fields : { | |
| // ... | |
| }, | |
| isTypeOf: data => !!data.username; | |
| }); |
This file contains hidden or 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
| const UserType = new GraphQLObjectType({ | |
| name : 'User', | |
| interfaces: [SearchableType], | |
| fields : { | |
| username : { | |
| type : GraphQLString | |
| }, | |
| searchPreviewText : { | |
| type : GraphQLString, | |
| resolve(data) { |
This file contains hidden or 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
| const schema = new GraphQLSchema({ | |
| types: [MovieType, BookType, UserType, SearchableType], | |
| query: new GraphQLObjectType({ | |
| // ... | |
| }) | |
| }); |
This file contains hidden or 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
| const SearchableType = new GraphQLInterfaceType({ | |
| name: 'Searchable', | |
| fields: { | |
| searchPreviewText: { type: GraphQLString } | |
| }, | |
| resolveType: resolveType | |
| }); |