You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, load the generated module and add its `.apolloLink` to your Apollo Link:
126
+
127
+
```js
128
+
// load the generated module
129
+
var OperationStoreClient =require("./OperationStoreClient")
130
+
131
+
// Integrate the link to another link:
132
+
constlink=ApolloLink.from([
133
+
authLink,
134
+
OperationStoreClient.apolloLink,
135
+
httpLink,
136
+
])
137
+
138
+
// Create a client
139
+
constclient=newApolloClient({
140
+
link: link,
141
+
cache:newInMemoryCache(),
142
+
});
143
+
```
144
+
145
+
__Update the controller__: Apollo Link supports extra parameters _nested_ as `params[:extensions][:operationId]`, so update your controller to add that param to context:
146
+
147
+
```ruby
148
+
# app/controllers/graphql_controller.rb
149
+
context = {
150
+
# ...
151
+
# Support Apollo Link:
152
+
operation_id: params[:extensions][:operationId]
153
+
}
154
+
```
155
+
156
+
Now, `context[:operation_id]` will be used to fetch a query from the database.
157
+
116
158
## Use with plain JavaScript
117
159
118
160
`OperationStoreClient.getOperationId` takes an operation name as input and returns the server-side alias for that operation:
0 commit comments