Created
January 27, 2020 11:00
-
-
Save Stradivario/d62d837981abee8bcb6a4b7faba1cbd5 to your computer and use it in GitHub Desktop.
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
import { CoreModule, Module, Controller, Query, Type, GraphQLObjectType, GraphQLString, GraphQLFloat, GraphQLInt } from "@gapi/core"; | |
import { VoyagerModule } from "@gapi/voyager"; | |
import { Neo4JModule, graphRequest } from "@rxdi/neo4j"; | |
import { makeAugmentedSchema } from "neo4j-graphql-js"; | |
import { mergeSchemas } from "graphql-tools"; | |
const typeDefs = ` | |
type Movie { | |
title: String | |
year: Int | |
imdbRating: Float | |
genres: [Genre] @relation(name: "IN_GENRE", direction: "OUT") | |
} | |
type Genre { | |
name: String | |
movies: [Movie] @relation(name: "IN_GENRE", direction: "IN") | |
} | |
`; | |
const Movie = new GraphQLObjectType({ | |
name: 'Movie', | |
fields: () => ({ | |
title: { | |
type: GraphQLString | |
}, | |
year: { | |
type: GraphQLInt | |
}, | |
imdbRating: { | |
type: GraphQLFloat | |
}, | |
}) | |
}); | |
@Controller() | |
export class TestController { | |
@Type(Movie) | |
@Query() | |
Movie(root, params, ctx, resolveInfo) { | |
console.log('aaa') | |
return graphRequest(root, params, ctx, resolveInfo) | |
} | |
} | |
@Module({ | |
controllers: [TestController], | |
imports: [ | |
CoreModule.forRoot(), | |
Neo4JModule.forRoot({ | |
types: [Movie], | |
// schemaOverride: schema => | |
// mergeSchemas({ | |
// schemas: [ | |
// schema, | |
// makeAugmentedSchema({ | |
// typeDefs | |
// }) | |
// ] | |
// }), | |
username: "graphql-server", | |
password: "b.OqCSpTlwCaw7.bz7G5rHnsSoEt9h1", | |
address: "bolt://hobby-hfdmjfhdcajkgbkemenhfhel.dbs.graphenedb.com:24787" | |
}), | |
VoyagerModule.forRoot() | |
] | |
}) | |
export class AppModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment