![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
graphql-ruby-client
Advanced tools
JavaScript support for GraphQL projects using graphql-pro's OperationStore
for persisted queries.
See the server-side docs on http://graphql-ruby.org
sync
utilityThis package contains a command line utility, graphql-ruby-client sync
:
$ graphql-ruby-client sync # ...
Authorizing with HMAC
Syncing 4 operations to http://myapp.com/graphql/operations...
3 added
1 not modified
0 failed
Generating client module in app/javascript/graphql/OperationStoreClient.js...
✓ Done!
sync
Takes several options:
option | description |
---|---|
--url | Sync API url |
--path | Local directory to search for .graphql / .graphql.js files |
--client | Client ID (created on server) |
--secret | Client Secret (created on server) |
--outfile | Destination for generated JS code |
You can see these and a few others with graphql-ruby-client sync --help
.
graphql-ruby-client
can persist queries from relay-compiler
using the embedded @relayHash
value.
To sync your queries with the server, use the --path
option to point to your __generated__
directory, for example:
# sync a Relay project
$ graphql-ruby-client sync --path=src/__generated__ --outfile=src/OperationStoreClient.js --url=...
Then, the generated code may be integrated with Relay's Network Layer:
// ...
// require the generated module:
const OperationStoreClient = require('./OperationStoreClient')
// ...
function fetchQuery(operation, variables, cacheConfig, uploadables) {
const requestParams = {
variables,
operationName: operation.name,
}
if (process.env.NODE_ENV === "production")
// In production, use the stored operation
requestParams.operationId = OperationStoreClient.getOperationId(operation.name)
} else {
// In development, use the query text
requestParams.query = operation.text,
}
return fetch('/graphql', {
method: 'POST',
headers: { /*...*/ },
body: JSON.stringify(requestParams),
}).then(/* ... */);
}
// ...
(Only Relay Modern is supported. Legacy Relay can't generate static queries.)
Use the --path
option to point at your .graphql
files:
$ graphql-ruby-client sync --path=src/graphql/ --url=...
Then, load the generated module and add its .apolloMiddleware
to your network interface with .use([...])
:
// load the generated module
var OperationStoreClient = require("./OperationStoreClient")
// attach it as middleware in production
// (in development, send queries to the server as normal)
if (process.env.NODE_ENV === "production") {
MyNetworkInterface.use([OperationStoreClient.apolloMiddleware])
}
Now, the middleware will replace query strings with operationId
s.
OperationStoreClient.getOperationId
takes an operation name as input and returns the server-side alias for that operation:
var OperationStoreClient = require("./OperationStoreClient")
OperationStoreClient.getOperationId("AppHomeQuery") // => "my-frontend-app/7a8078c7555e20744cb1ff5a62e44aa92c6e0f02554868a15b8a1cbf2e776b6f"
OperationStoreClient.getOperationId("ProductDetailQuery") // => "my-frontend-app/6726a3b816e99b9971a1d25a1205ca81ecadc6eb1d5dd3a71028c4b01cc254c1"
Post the operationId
in your GraphQL requests:
// Lookup the operation name:
var operationId = OperationStoreClient.getOperationId(operationName)
// Include it in the params:
$.post("/graphql", {
operationId: operationId,
variables: queryVariables,
}, function(response) {
// ...
})
OperationStore
uses HMAC-SHA256 to authenticate requests.
Pass the key to graphql-ruby-client sync
as --secret
to authenticate it:
$ export MY_SECRET_KEY= "abcdefg..."
$ graphql-ruby-client sync ... --secret=$MY_SECRET_KEY
# ...
Authenticating with HMAC
# ...
yarn install
yarn run test
npm link .
FAQs
JavaScript client for graphql-ruby
The npm package graphql-ruby-client receives a total of 58,719 weekly downloads. As such, graphql-ruby-client popularity was classified as popular.
We found that graphql-ruby-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.