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

Translating fragments on interface types #394

Merged
merged 13 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions example/apollo-server/movies-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Actor {
id: ID!
name: String
movies: [Movie] @relation(name: "ACTED_IN", direction: "OUT")
knows: [Person] @relation(name: "KNOWS", direction: "OUT")
}

type User implements Person {
Expand Down Expand Up @@ -87,6 +88,8 @@ interface Camera {
type: String
make: String
weight: Int
operators: [Person] @relation(name: "cameras", direction: IN)
computedOperators(name: String): [Person] @cypher(statement: "MATCH (this)<-[:cameras]-(p:Person) RETURN p")
}

type OldCamera implements Camera {
Expand All @@ -95,6 +98,8 @@ type OldCamera implements Camera {
make: String
weight: Int
smell: String
operators: [Person] @relation(name: "cameras", direction: IN)
computedOperators(name: String): [Person] @cypher(statement: "MATCH (this)<-[:cameras]-(p:Person) RETURN p")
}

type NewCamera implements Camera {
Expand All @@ -103,6 +108,8 @@ type NewCamera implements Camera {
make: String
weight: Int
features: [String]
operators: [Person] @relation(name: "cameras", direction: IN)
computedOperators(name: String): [Person] @cypher(statement: "MATCH (this)<-[:cameras]-(p:Person) RETURN p")
}

type CameraMan implements Person {
Expand All @@ -115,11 +122,19 @@ type CameraMan implements Person {
}

type Query {
Movie(movieId: ID, title: String, year: Int, plot: String, poster: String, imdbRating: Float): [Movie] MoviesByYear(year: Int, first: Int = 10, offset: Int = 0): [Movie]
Movie(movieId: ID, title: String, year: Int, plot: String, poster: String, imdbRating: Float): [Movie]
MoviesByYear(year: Int, first: Int = 10, offset: Int = 0): [Movie]
AllMovies: [Movie]
MovieById(movieId: ID!): Movie
GenresBySubstring(substring: String): [Genre] @cypher(statement: "MATCH (g:Genre) WHERE toLower(g.name) CONTAINS toLower($substring) RETURN g")
Books: [Book]
CustomCameras: [Camera] @cypher(statement: "MATCH (c:Camera) RETURN c")
CustomCamera: Camera @cypher(statement: "MATCH (c:Camera) RETURN c")
}

type Mutation {
CustomCamera: Camera @cypher(statement: "CREATE (newCamera:Camera:NewCamera {id: apoc.create.uuid(), type: 'macro'}) RETURN newCamera")
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]")
}
`;

Expand All @@ -146,15 +161,3 @@ export const resolvers = {
}
}
};

// Mutation: {
// CreateGenre(object, params, ctx, resolveInfo) {
// return neo4jgraphql(object, params, ctx, resolveInfo, true);
// },
// CreateMovie(object, params, ctx, resolveInfo) {
// return neo4jgraphql(object, params, ctx, resolveInfo, true);
// },
// AddMovieGenre(object, params, ctx, resolveInfo) {
// return neo4jgraphql(object, params, ctx, resolveInfo, true);
// }
// }
11 changes: 7 additions & 4 deletions src/augment/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ export const Neo4jSystemIDField = `_id`;
* See: https://neo4j.com/docs/cypher-manual/current/syntax/values/#property-types
*/
export const isPropertyTypeField = ({ kind, type }) =>
isScalarField({ kind, type }) ||
isTemporalField({ type }) ||
isSpatialField({ type }) ||
isNeo4jPropertyType({ type });

export const isScalarField = ({ kind, type }) =>
isIntegerField({ type }) ||
isFloatField({ type }) ||
isStringField({ kind, type }) ||
isBooleanField({ type }) ||
isCustomScalarField({ kind }) ||
isTemporalField({ type }) ||
isSpatialField({ type }) ||
isNeo4jPropertyType({ type });
isCustomScalarField({ kind });

export const isIntegerField = ({ type }) =>
Neo4jDataType.PROPERTY[type] === 'Integer';
Expand Down
Loading