Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 2dd28d9

Browse files
authored
Merge pull request #394 from michaeldgraham/master
Translating fragments on interface types
2 parents 8c2bf8c + b370f69 commit 2dd28d9

11 files changed

+3420
-959
lines changed

example/apollo-server/movies-schema.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type Actor {
4646
id: ID!
4747
name: String
4848
movies: [Movie] @relation(name: "ACTED_IN", direction: "OUT")
49+
knows: [Person] @relation(name: "KNOWS", direction: "OUT")
4950
}
5051
5152
type User implements Person {
@@ -87,6 +88,8 @@ interface Camera {
8788
type: String
8889
make: String
8990
weight: Int
91+
operators: [Person] @relation(name: "cameras", direction: IN)
92+
computedOperators(name: String): [Person] @cypher(statement: "MATCH (this)<-[:cameras]-(p:Person) RETURN p")
9093
}
9194
9295
type OldCamera implements Camera {
@@ -95,6 +98,8 @@ type OldCamera implements Camera {
9598
make: String
9699
weight: Int
97100
smell: String
101+
operators: [Person] @relation(name: "cameras", direction: IN)
102+
computedOperators(name: String): [Person] @cypher(statement: "MATCH (this)<-[:cameras]-(p:Person) RETURN p")
98103
}
99104
100105
type NewCamera implements Camera {
@@ -103,6 +108,8 @@ type NewCamera implements Camera {
103108
make: String
104109
weight: Int
105110
features: [String]
111+
operators: [Person] @relation(name: "cameras", direction: IN)
112+
computedOperators(name: String): [Person] @cypher(statement: "MATCH (this)<-[:cameras]-(p:Person) RETURN p")
106113
}
107114
108115
type CameraMan implements Person {
@@ -115,11 +122,19 @@ type CameraMan implements Person {
115122
}
116123
117124
type Query {
118-
Movie(movieId: ID, title: String, year: Int, plot: String, poster: String, imdbRating: Float): [Movie] MoviesByYear(year: Int, first: Int = 10, offset: Int = 0): [Movie]
125+
Movie(movieId: ID, title: String, year: Int, plot: String, poster: String, imdbRating: Float): [Movie]
126+
MoviesByYear(year: Int, first: Int = 10, offset: Int = 0): [Movie]
119127
AllMovies: [Movie]
120128
MovieById(movieId: ID!): Movie
121129
GenresBySubstring(substring: String): [Genre] @cypher(statement: "MATCH (g:Genre) WHERE toLower(g.name) CONTAINS toLower($substring) RETURN g")
122130
Books: [Book]
131+
CustomCameras: [Camera] @cypher(statement: "MATCH (c:Camera) RETURN c")
132+
CustomCamera: Camera @cypher(statement: "MATCH (c:Camera) RETURN c")
133+
}
134+
135+
type Mutation {
136+
CustomCamera: Camera @cypher(statement: "CREATE (newCamera:Camera:NewCamera {id: apoc.create.uuid(), type: 'macro'}) RETURN newCamera")
137+
CustomCameras: [Camera] @cypher(statement: "CREATE (newCamera:Camera:NewCamera {id: apoc.create.uuid(), type: 'macro', features: ['selfie', 'zoom']}) CREATE (oldCamera:Camera:OldCamera {id: apoc.create.uuid(), type: 'floating', smell: 'rusty' }) RETURN [newCamera, oldCamera]")
123138
}
124139
`;
125140

@@ -146,15 +161,3 @@ export const resolvers = {
146161
}
147162
}
148163
};
149-
150-
// Mutation: {
151-
// CreateGenre(object, params, ctx, resolveInfo) {
152-
// return neo4jgraphql(object, params, ctx, resolveInfo, true);
153-
// },
154-
// CreateMovie(object, params, ctx, resolveInfo) {
155-
// return neo4jgraphql(object, params, ctx, resolveInfo, true);
156-
// },
157-
// AddMovieGenre(object, params, ctx, resolveInfo) {
158-
// return neo4jgraphql(object, params, ctx, resolveInfo, true);
159-
// }
160-
// }

src/augment/fields.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ export const Neo4jSystemIDField = `_id`;
2020
* See: https://neo4j.com/docs/cypher-manual/current/syntax/values/#property-types
2121
*/
2222
export const isPropertyTypeField = ({ kind, type }) =>
23+
isScalarField({ kind, type }) ||
24+
isTemporalField({ type }) ||
25+
isSpatialField({ type }) ||
26+
isNeo4jPropertyType({ type });
27+
28+
export const isScalarField = ({ kind, type }) =>
2329
isIntegerField({ type }) ||
2430
isFloatField({ type }) ||
2531
isStringField({ kind, type }) ||
2632
isBooleanField({ type }) ||
27-
isCustomScalarField({ kind }) ||
28-
isTemporalField({ type }) ||
29-
isSpatialField({ type }) ||
30-
isNeo4jPropertyType({ type });
33+
isCustomScalarField({ kind });
3134

3235
export const isIntegerField = ({ type }) =>
3336
Neo4jDataType.PROPERTY[type] === 'Integer';

0 commit comments

Comments
 (0)