@@ -66,9 +66,9 @@ func (msg OperationMessage) String() string {
66
66
return "<invalid>"
67
67
}
68
68
69
- // UserFromAuthTokenFunc is a function that resolves an auth token
69
+ // AuthenticateFunc is a function that resolves an auth token
70
70
// into a user (or returns an error if that isn't possible).
71
- type UserFromAuthTokenFunc func (token string ) (interface {}, error )
71
+ type AuthenticateFunc func (token string ) (interface {}, error )
72
72
73
73
// ConnectionEventHandlers define the event handlers for a connection.
74
74
// Event handlers allow other system components to react to events such
@@ -95,8 +95,8 @@ type ConnectionEventHandlers struct {
95
95
// ConnectionConfig defines the configuration parameters of a
96
96
// GraphQL WebSocket connection.
97
97
type ConnectionConfig struct {
98
- UserFromAuthToken UserFromAuthTokenFunc
99
- EventHandlers ConnectionEventHandlers
98
+ Authenticate AuthenticateFunc
99
+ EventHandlers ConnectionEventHandlers
100
100
}
101
101
102
102
// Connection is an interface to represent GraphQL WebSocket connections.
@@ -268,8 +268,8 @@ func (conn *connection) readLoop() {
268
268
if err := json .Unmarshal (rawPayload , & data ); err != nil {
269
269
conn .SendError (errors .New ("Invalid GQL_CONNECTION_INIT payload" ))
270
270
} else {
271
- if conn .config .UserFromAuthToken != nil {
272
- user , err := conn .config .UserFromAuthToken (data .AuthToken )
271
+ if conn .config .Authenticate != nil {
272
+ user , err := conn .config .Authenticate (data .AuthToken )
273
273
if err != nil {
274
274
conn .SendError (fmt .Errorf ("Failed to authenticate user: %v" , err ))
275
275
} else {
0 commit comments