How to log calls to deprecated fields in apollo server - graphql

We marked some fields in our schema using the #deprecated directive. Now we want to log if these fields are still in use from some of our clients. What would be the best way to do this, without using Apollo Studio.

If you have access to the client code, then you can utilize GraphQL Inspector to check for deprecated usage. Using the CLI, you just do:
graphql-inspector validate DOCUMENTS SCHEMA
where DOCUMENTS is a glob pattern used to match the files containing the queries and SCHEMA is a pointer to the schema used for validation. The files containing the queries can be .graphql files or .js/.ts files. The schema pointer can be a URL to your schema or one or more .graphql files with your schema's type definitions. See here and here for additional ways to provide the schema and documents.
If you don't have access to the client code, or specifically need to log deprecated usage on every request, then you can write your own Apollo Server plugin and utilize GraphQL Inspector's programmatic API instead to validate each request's parsed document as it comes in. The parsed document will be available beginning with the validationDidStart lifecycle hook. See the docs for a complete example of how to write your own plugin.

Related

How can I create a NestJS graphql server with dynamic schema with respect to user?

I am using Nest JS for server and new to Graphql, I want to create a graphql server but schema defines in Graphql module in app.module. I am using schema first appraoch.
app.module
in importing Graphql Module, typepaths property defines to create typings from schemas present in any path.
but I don't have any particular schema because I want my user to enter any thing he want and fetch data using Graphql where typings should be with respect to particular user.
Things I tried:
I tried to rewrite the schema using filesystem methods from service but to update typings from schema nest server needs to restart to generate typings again.
please anyone give me a guide or any approach how can I achieve dynamic typings. I want a server which shows a graphql playground but user should be allow to query with respect to their data.
like for user 1 this highlighted box can be a schema but for different user this schema should be with respect to himself:user 1 should see this schema and should query only using this schema
Related Images are attached in link.
Any guide would be appreciated, Thanks!

how to disable certain cloud code to automatically include in auto schema graphql parse-server?

While activate graphql function in parse-server, i got this warning msg in my log:
warn: Function my-cloud-code-function could not be added to the auto schema because GraphQL names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/.
I know i can remove the warning by fixing the function name and update it to the proper name format. But what i really want is to disable certain function to be automatically included in auto schema graphql parse-server. How can i do that? I believe there should be some parse server graphql option to exclude it from the list, but i can not found.

Extract Graphql queries sent by a browser application with Apollo client

I am trying to simplify the process of exporting GraphQL queries sent by my application for documentation purposes. For the record, I want to be able to paste those queries into Postman collections.
Here are my different approaches:
Relying on .graphql files: first it's still very difficult to setup with a full fledged TypeScript + Webpack + Babel setup (using Next.js). Anyway, it does not provide variables, so you only have half the query.
Relying on the network tab. From there, we can copy queries content and import into Postman. Combined with Cypress it could provide an awesome workflow. It works OK, but Apollo Client will send queries as JSON objects, difficult to interpret
I tried to use the "application/graphql" content-type. It's way more readable and available in Postman. BUUUT it is non-standard, and thus not available in Apollo client.
So my question is rather open, but what are the possibilities to enable extracting graphql queries (and variables) sent by my browser and inject them into Postman?
Most promising solution is enabling "application/graphql" client side, or converting the JSON representation back to a string representation. But I could explore another possibility (eg using Apollo Engine as an intermediate)
A way to do this is to use the apollo CLI tool. It includes a client:extract command that extracts all of the GraphQL operations/documents in your application into a file. You run the tool on your JS(X)/TS(X) files and it extracts the GraphQL documents into a file that looks like this (this output is the result of pointing the tool at a single file containing a single query):
{
"version": 2,
"operations": [
{
"signature": "b4f318e6aebcc3631bc88eedef09c6001bb8c310917e97ee6df4a99e17c3c056",
"document": "query BootstrapQuery{user:viewer{__typename delivery_time_1 delivery_time_2 devices{__typename fcm_token id notification{__typename enabled}}has_password id label location name next_delivery_string oauths{__typename email id name picture provider}plan plan_billing_service plan_expires plan_since plan_will_renew profile_picture recovery_email timezone username}}",
"metadata": {
"engineSignature": ""
}
}
]
}
You can then use that file however you want.
In my case, I use this tool to publish an allow-list of operations to Hasura. I'm not sure what you mean by injecting queries into Postman, but I think this tool may provide you with an automated start that would be an improvement over manual copy/pasting.

Change CSV Delimiter in ORDS

I've recently setup Oracle Rest Data Services (ORDS) and managed to successfully create several endpoints returning both JSON and CSV data. However, is there was a way to change the delimiter (such as to a tab or pipe) on csv/query services? Since the ORDS packages are encrypted, there's no way to do modifications on that front, and none of the documentation I've read suggests there's a built in option to make this change.
I'm considering creating an plugin into ORDS that would basically call the CSV path and then convert it to the new delimiter before returning the data, but before that I wanted to make sure there wasn't any easier way of accomplishing this.
Take a look at Developing Oracle Rest Data Applications
Pattern: POST http://< HOST>:< PORT >/ords/< SchemaAlias>/< ObjectAlias>/batchload?< Parameters>
One parameter is: delimiter
"Sets the field delimiter for the fields in the file. The default is the comma (,)."

In WebAPI Breeze implementation, can I avoid exposing Metadata function?

Opening Metadata function using Breeze via API is actually equivalent of exposing the underlying database schema.
Is there a way to avoid opening up metadata api call? I tried not exposing it as suggested. I got the following error
Query failed Metadata query failed for: /breeze/NorthWind/Metadata; The requested resource does not support http method 'GET'.
What is the right way of avoiding exposing Breeze Metadata calls.
In addition to obtaining metadata via an API, there are another couple of approaches you could consider:
Load metadata from a script. With this approach, you embed the metadata in a script. After loading the script, the Breeze EntityManager can be initialized using the metadata from the script rather than calling an API. I've found this approach quite useful for unit testing when a dependency on accessing a server is undesirable. See Load metadata from script for more details.
Build metadata with hand-written Javascript code to configure it. You probably wouldn't want to do this for a complex data model that you have already defined in Entity Framework, but it can be useful if that isn't a constraint. See Metadata by hand for discussion on this approach.
Once you do have metadata, you can export and import the metadata (such as to the browser's window.localStorage area) using MetadataStore.exportMetadata and MetadataStore.importMetadata respectively.
You need to provide some sort of metadata for Breeze to work. If you do not want to expose your DB structure, either you have to manually change the metadata generated, or have another layer in between your DB entities and the data classes you want to expose. You can generate the metadata of the intermediate layer by data annotations.

Resources