Commit b45d5f12 authored by Christoph Häfner's avatar Christoph Häfner

Add movieCollections query type

parent 8869c7c6
Pipeline #449 passed with stages
in 20 minutes and 25 seconds
......@@ -44,6 +44,7 @@
"test:unit": "jest --coverage --config ./jest.config.json",
"test:build": "next build",
"test:unit:watch": "jest --watch --config ./jest.config.json",
"testApi": "curl -XPOST -H \"Content-Type:application/graphql\" -d 'query { movies { title } }' http://localhost:3000/graphql"
"testMoviesApi": "curl -XPOST -H \"Content-Type:application/graphql\" -d 'query { movies { title } }' http://localhost:3000/graphql",
"testMovieCollectionsApi": "curl -XPOST -H \"Content-Type:application/graphql\" -d 'query { movieCollections { name } }' http://localhost:3000/graphql"
}
}
......@@ -3,21 +3,8 @@ const {
GraphQLList
} = require('graphql')
const MovieType = require('./types/movieType')
const MOVIES = [{
id: '1381220',
title: 'Best Exotic Marigold Hotel 2 (2015)'
}, {
id: '2133893742',
title: 'Riddick - Überleben ist seine Rache (2013)'
}, {
id: '2144846395',
title: 'Hostage - Entführt'
}, {
id: '2043226252',
title: 'Baymax - Riesiges Robowabohu (2014)'
}]
const { MovieType, MOVIES } = require('./types/movieType')
const { MovieCollectionType, MOVIECOLLECTIONS } = require('./types/movieCollection')
module.exports = new GraphQLObjectType({
name: 'Query',
......@@ -28,6 +15,12 @@ module.exports = new GraphQLObjectType({
resolve: () => {
return MOVIES;
}
},
movieCollections: {
type: new GraphQLList(MovieCollectionType),
resolve: () => {
return MOVIECOLLECTIONS;
}
}
}
}
......
......@@ -6,9 +6,9 @@ const {
GraphQLList
} = require('graphql')
const Movie = require('./movieType');
const { MovieType, MOVIES } = require('./movieType')
module.exports = new GraphQLObjectType({
module.exports = {MovieCollectionType: new GraphQLObjectType({
name: 'movieCollection',
fields: () => {
return {
......@@ -25,9 +25,17 @@ module.exports = new GraphQLObjectType({
type: GraphQLString
},
movies: {
type: new GraphQLList(Movie)
type: new GraphQLList(MovieType)
}
}
}
});
}),
MOVIECOLLECTIONS: [{
id: '673655561',
name: 'Hugo Blurays',
isLoading: false,
sort: "title",
movies: MOVIES
}]
};
......@@ -4,7 +4,7 @@ const {
GraphQLID
} = require('graphql')
module.exports = new GraphQLObjectType({
module.exports = { MovieType: new GraphQLObjectType({
name: 'movie',
fields: () => {
return {
......@@ -16,4 +16,18 @@ module.exports = new GraphQLObjectType({
}
}
}
});
}),
MOVIES: [{
id: '1381220',
title: 'Best Exotic Marigold Hotel 2 (2015)'
}, {
id: '2133893742',
title: 'Riddick - Überleben ist seine Rache (2013)'
}, {
id: '2144846395',
title: 'Hostage - Entführt'
}, {
id: '2043226252',
title: 'Baymax - Riesiges Robowabohu (2014)'
}]};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment