· 6 years ago · Mar 15, 2019, 09:58 AM
1const Films = new GraphQLObjectType({
2 name: 'films',
3 interfaces: () => [MovieStream],
4
5 fields: () => ({
6 movie_id: {
7 type: GraphQLString,
8
9 },
10 id:{
11 type: GraphQLID
12 },
13 name: {
14 type: GraphQLString,
15
16 },
17
18 })
19})
20Films._typeConfig = {
21 sqlTable: "films",
22 uniqueKey: 'id',
23
24 }
25
26 const MovieStream = new GraphQLInterfaceType({
27 name: 'MovieStream',
28
29 fields: () => ({
30 id: {
31 type: GraphQLID,
32
33 },
34
35 movie_id: {
36 type: GraphQLString,
37
38 },
39 })
40
41
42})
43
44 MovieStream._typeConfig = {
45 sqlTable: "movie_streams",
46 uniqueKey: 'id'
47 }
48
49
50 const QueryRoot = new GraphQLObjectType({
51 name: 'Query',
52 fields: () => ({
53 getContentList:{
54 type: new GraphQLList(Films),
55 args: {
56 id: {
57 type: GraphQLInt
58 },
59 permalink: {
60 type: GraphQLString
61 },
62 language: {
63 type: GraphQLString
64 },
65 content_types_id: {
66 type: GraphQLString
67 },
68 oauth_token:{
69 type: GraphQLString
70 }
71
72 },
73
74 resolve: (parent, args, context, resolveInfo) => {
75
76 return joinMonster.default(resolveInfo,{}, sql => {
77 return FilmDb.query(sql).then(function(result) {
78
79 return result[0];
80 });
81 } ,{dialect: 'mysql'});
82 },
83
84 }
85
86 })
87 })
88
89 module.exports = new GraphQLSchema({
90 query: QueryRoot
91 })
92
93{
94 "errors": [
95 {
96 "message": "Unknown column 'getContent.movie_id' in 'field list'",
97 "locations": [
98 {
99 "line": 2,
100 "column": 3
101 }
102 ],
103 "path": [
104 "getContentList"
105 ]
106 }
107 ],
108 "data": {
109 "getContentList": null
110 }
111}