15
15
using HotChocolate ;
16
16
using HotChocolate . Types ;
17
17
using HotChocolate . Resolvers ;
18
+ using HotChocolate . AspNetCore ;
18
19
using System . Diagnostics ;
19
20
20
21
namespace ConferencePlanner . GraphQL
@@ -40,49 +41,49 @@ public void ConfigureServices(IServiceCollection services)
40
41
// This adds the GraphQL server core service and declares a schema.
41
42
. AddGraphQLServer ( )
42
43
43
- // Next we add the types to our schema.
44
- . AddQueryType ( )
45
- . AddTypeExtension < AttendeeQueries > ( )
46
- . AddTypeExtension < SessionQueries > ( )
47
- . AddTypeExtension < SpeakerQueries > ( )
48
- . AddTypeExtension < TrackQueries > ( )
49
- . AddMutationType ( )
50
- . AddTypeExtension < AttendeeMutations > ( )
51
- . AddTypeExtension < SessionMutations > ( )
52
- . AddTypeExtension < SpeakerMutations > ( )
53
- . AddTypeExtension < TrackMutations > ( )
54
- . AddSubscriptionType ( )
55
- . AddTypeExtension < AttendeeSubscriptions > ( )
56
- . AddTypeExtension < SessionSubscriptions > ( )
57
- . AddType < AttendeeType > ( )
58
- . AddType < SessionType > ( )
59
- . AddType < SpeakerType > ( )
60
- . AddType < TrackType > ( )
44
+ // Next we add the types to our schema.
45
+ . AddQueryType ( )
46
+ . AddTypeExtension < AttendeeQueries > ( )
47
+ . AddTypeExtension < SessionQueries > ( )
48
+ . AddTypeExtension < SpeakerQueries > ( )
49
+ . AddTypeExtension < TrackQueries > ( )
50
+ . AddMutationType ( )
51
+ . AddTypeExtension < AttendeeMutations > ( )
52
+ . AddTypeExtension < SessionMutations > ( )
53
+ . AddTypeExtension < SpeakerMutations > ( )
54
+ . AddTypeExtension < TrackMutations > ( )
55
+ . AddSubscriptionType ( )
56
+ . AddTypeExtension < AttendeeSubscriptions > ( )
57
+ . AddTypeExtension < SessionSubscriptions > ( )
58
+ . AddType < AttendeeType > ( )
59
+ . AddType < SessionType > ( )
60
+ . AddType < SpeakerType > ( )
61
+ . AddType < TrackType > ( )
61
62
62
- // In this section we are adding extensions like relay helpers,
63
- // filtering and sorting.
64
- . AddFiltering ( )
65
- . AddSorting ( )
66
- . AddGlobalObjectIdentification ( )
63
+ // In this section we are adding extensions like relay helpers,
64
+ // filtering and sorting.
65
+ . AddFiltering ( )
66
+ . AddSorting ( )
67
+ . AddGlobalObjectIdentification ( )
67
68
68
- // Now we add some the DataLoader to our system.
69
- . AddDataLoader < AttendeeByIdDataLoader > ( )
70
- . AddDataLoader < SessionByIdDataLoader > ( )
71
- . AddDataLoader < SpeakerByIdDataLoader > ( )
72
- . AddDataLoader < TrackByIdDataLoader > ( )
69
+ // Now we add some the DataLoader to our system.
70
+ . AddDataLoader < AttendeeByIdDataLoader > ( )
71
+ . AddDataLoader < SessionByIdDataLoader > ( )
72
+ . AddDataLoader < SpeakerByIdDataLoader > ( )
73
+ . AddDataLoader < TrackByIdDataLoader > ( )
73
74
74
- // we make sure that the db exists and prefill it with conference data.
75
- . EnsureDatabaseIsCreated ( )
75
+ // we make sure that the db exists and prefill it with conference data.
76
+ . EnsureDatabaseIsCreated ( )
76
77
77
- // Since we are using subscriptions, we need to register a pub/sub system.
78
- // for our demo we are using a in-memory pub/sub system.
79
- . AddInMemorySubscriptions ( )
78
+ // Since we are using subscriptions, we need to register a pub/sub system.
79
+ // for our demo we are using a in-memory pub/sub system.
80
+ . AddInMemorySubscriptions ( )
80
81
81
- // Last we add support for persisted queries.
82
- // The first line adds the persisted query storage,
83
- // the second one the persisted query processing pipeline.
84
- . AddFileSystemQueryStorage ( "./persisted_queries" )
85
- . UsePersistedQueryPipeline ( ) ;
82
+ // Last we add support for persisted queries.
83
+ // The first line adds the persisted query storage,
84
+ // the second one the persisted query processing pipeline.
85
+ . AddFileSystemQueryStorage ( "./persisted_queries" )
86
+ . UsePersistedQueryPipeline ( ) ;
86
87
}
87
88
88
89
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -101,14 +102,21 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
101
102
app . UseEndpoints ( endpoints =>
102
103
{
103
104
// We will be using the new routing API to host our GraphQL middleware.
104
- endpoints . MapGraphQL ( ) ;
105
+ endpoints . MapGraphQL ( )
106
+ . WithOptions ( new GraphQLServerOptions
107
+ {
108
+ Tool =
109
+ {
110
+ GaTrackingId = "UA-72800164-1"
111
+ }
112
+ } ) ;
105
113
106
114
endpoints . MapGet ( "/" , context =>
107
115
{
108
- context . Response . Redirect ( "/graphql" ) ;
116
+ context . Response . Redirect ( "/graphql" , true ) ;
109
117
return Task . CompletedTask ;
110
118
} ) ;
111
119
} ) ;
112
120
}
113
121
}
114
- }
122
+ }
0 commit comments