Skip to content

Commit 5e734ba

Browse files
committed
Task_6_Start
1 parent be3cc55 commit 5e734ba

File tree

3 files changed

+8
-34
lines changed

3 files changed

+8
-34
lines changed

src/gateway/index.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ const { ApolloServer } = require('apollo-server');
33

44
const gateway = new ApolloGateway({
55
serviceList: [
6-
{
7-
name: 'cms',
8-
url: 'http://localhost:8000/graphql',
9-
},
10-
{
11-
name: 'weather',
12-
url: 'http://localhost:8100/graphql',
13-
},
6+
// TODO (5) list locally running services
147
],
158
});
169

src/server/gqlSchema.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const { gql } = require('apollo-server');
22

33
const { getHello, resolveQuery } = require('./fetcher');
44

5+
// TODO (3) update the user entity with the weather field and add an external reference
6+
// to the Weather entity
57
const typeDefs = gql`
68
enum OrderDirection {
79
asc
@@ -26,17 +28,12 @@ const typeDefs = gql`
2628
direction: OrderDirection
2729
}
2830
29-
type User @key(fields: "id"){
31+
type User {
3032
id: ID
3133
name: String
3234
username: String
3335
email: String
3436
location: String
35-
weather: Weather
36-
}
37-
38-
extend type Weather @key(fields: "location") {
39-
location: String! @external
4037
}
4138
4239
type UserEdge {
@@ -87,12 +84,9 @@ const typeDefs = gql`
8784
}
8885
`;
8986

87+
// TODO (4) define the new root level entry for the User entity and resolve weather there with the
88+
// parameters from the weather schema
9089
const resolvers = {
91-
User: {
92-
weather(user) {
93-
return { __typename: 'Weather', location: user.location };
94-
},
95-
},
9690
Query: {
9791
hello: () => getHello(),
9892
users: (args) => resolveQuery({ table: 'users', args: args || {} }),

src/weatherServer/gqlSchema.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@ const { gql } = require('apollo-server');
22

33
const { getWeather } = require('./fetcher');
44

5+
// TODO (1) write the new weather schema
56
const typeDefs = gql`
6-
type Weather @key(fields: "location"){
7-
lat: String!
8-
lon: String!
9-
temp: String!
10-
humidity: String!
11-
pressure: String!
12-
location: String!
13-
}
14-
157
extend type Query {
168
weather(location: String!): Weather
179
}
@@ -23,12 +15,7 @@ const resolvers = {
2315
return getWeather(args);
2416
},
2517
},
26-
Weather: {
27-
/* eslint-disable-next-line no-underscore-dangle */
28-
__resolveReference(weather) {
29-
return getWeather({ location: weather.location });
30-
},
31-
},
18+
// TODO (2) resolve reference on the root level
3219
};
3320

3421
module.exports = {

0 commit comments

Comments
 (0)