Socket
Socket
Sign inDemoInstall

@graphiql/toolkit

Package Overview
Dependencies
Maintainers
2
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphiql/toolkit - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1-canary-66346cbd.0

45

CHANGELOG.md
# @graphiql/toolkit
## 0.4.1-canary-66346cbd.0
### Patch Changes
- [`7f4acdeb`](https://github.com/graphql/graphiql/commit/7f4acdeb6e347876177ae7701acfea7798be20cb) [#1997](https://github.com/graphql/graphiql/pull/1997) Thanks [@acao](https://github.com/acao)! - Add support for variables `json` diagnostics, code completion with additionalInsertText, and hover to `monaco-graphql` using the built in `JSONSchema` support in `monaco-graphql`. 🎉
See the `monaco-graphql` README for instructions on how to set this up in your project.
The utility allows users to generate `JSONSchema` definitions for the variables JSON on the fly which they feed to monaco's json language api when editing an operation's documents.
**BREAKING CHANGE!!** for `monaco-graphql` to api instantiation and using `graphql` language id instead of `graphqlDev` - it does not apply to `graphiql` or `@graphiql/toolkit` - they receive patches because the underling util has a new feature. These may be some of the last major breaking changes to `monaco-graphql` before we are able to ship the first `@graphiql/react` sdk, and thus be able to build towards a `graphqil@2.0.0` release.
the `monaco-graphql` mode is now instantiated using a new pattern:
```ts
import { initialize } from 'monaco-graphql';
const monacoGraphQLAPI = await instantiate({
schemaConfig: { uri: 'http://myschema' },
schemaLoader: mySchemaLoader,
externalFragmentDefinitions:
myFragmentDefinitionNodes ?? `myFragment {} AnotherFragment {}`,
formattingOptions: {
prettier: {
printWidth: 120,
},
},
});
```
There are now several additional methods:
- `monacoGraphQLAPI.onSchemaLoaded((api) => console.log(api.schema.schema, api.schema.schemaString))` for any behavior where you want to wait for the schema to be present.
- `await monacoGrapQLAPI.reloadSchema()` - forces a new schema request without config changes, for example in development environments
- `const JSONSchema = monacoGraphQLAPI.getJSONSChema()` for adding json features, see the readme for more details on how to add this to your implementation.
- `monacoGraphQLAPI.setGraphQLSchema(myGraphQLSchema)` was added by popular request
but most existing methods work just as before!
this also introduces improvements:
- less redundant schema loading - schema is loaded in main process instead of in the webworkers, providing a single source of truth and an EventEmitter
- web worker stability has been improved by contributors in previous patches, but waiting for the schema to be present seems to prevent most issues with unnecessary re-creation of webworkers
- language providers and webworkers are only called to action once the schema is present in the cache
## 0.4.0

@@ -4,0 +49,0 @@

12

dist/create-fetcher/lib.d.ts
import { DocumentNode } from 'graphql';
import { Client, ClientOptions } from 'graphql-ws';
import type { Fetcher, FetcherResult, FetcherParams, CreateFetcherOptions } from './types';
import { Client, ClientOptions, ExecutionResult } from 'graphql-ws';
import type { Fetcher, FetcherParams, CreateFetcherOptions } from './types';
export declare const isSubscriptionWithName: (document: DocumentNode, name: string) => boolean;
export declare const createSimpleFetcher: (options: CreateFetcherOptions, httpFetch: typeof fetch) => Fetcher;
export declare const createWebsocketsFetcherFromUrl: (url: string, connectionParams?: ClientOptions['connectionParams']) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<FetcherResult>) | undefined;
export declare const createWebsocketsFetcherFromClient: (wsClient: Client) => (graphQLParams: FetcherParams) => AsyncIterableIterator<FetcherResult>;
export declare const createWebsocketsFetcherFromUrl: (url: string, connectionParams?: ClientOptions['connectionParams']) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>) | undefined;
export declare const createWebsocketsFetcherFromClient: (wsClient: Client) => (graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>;
export declare const createLegacyWebsocketsFetcher: (legacyWsClient: {
request: (params: FetcherParams) => unknown;
}) => (graphQLParams: FetcherParams) => AsyncIterableIterator<FetcherResult>;
}) => (graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>;
export declare const createMultipartFetcher: (options: CreateFetcherOptions, httpFetch: typeof fetch) => Fetcher;
export declare const getWsFetcher: (options: CreateFetcherOptions) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<FetcherResult>) | undefined;
export declare const getWsFetcher: (options: CreateFetcherOptions) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>) | undefined;
//# sourceMappingURL=lib.d.ts.map
import type { DocumentNode, IntrospectionQuery } from 'graphql';
import type { Client, ClientOptions } from 'graphql-ws';
import type { Client, ClientOptions, ExecutionResult } from 'graphql-ws';
export declare type Observable<T> = {

@@ -27,3 +27,3 @@ subscribe(opts: {

};
export declare type FetcherResultPayload = {
export declare type ExecutionResultPayload = {
data: IntrospectionQuery;

@@ -44,6 +44,10 @@ errors?: Array<any>;

};
export declare type FetcherResult = FetcherResultPayload | string;
export declare type FetcherResultPayload = ExecutionResultPayload;
export declare type MaybePromise<T> = T | Promise<T>;
export declare type SyncFetcherResult = FetcherResult | Observable<FetcherResult> | AsyncIterable<FetcherResult>;
export declare type FetcherReturnType = MaybePromise<SyncFetcherResult>;
export declare type FetcherResult = ExecutionResult | {
data: IntrospectionQuery;
};
export declare type SyncExecutionResult = ExecutionResult | Observable<ExecutionResult> | AsyncIterable<ExecutionResult>;
export declare type SyncFetcherResult = SyncExecutionResult;
export declare type FetcherReturnType = MaybePromise<SyncExecutionResult>;
export declare type Fetcher = (graphQLParams: FetcherParams, opts?: FetcherOpts) => FetcherReturnType;

@@ -50,0 +54,0 @@ export interface CreateFetcherOptions {

@@ -44,4 +44,14 @@ ## Create Fetcher

#### Adding Websockets
#### Adding `graphql-ws` websockets subscriptions
first you'll need to install `graphql-ws` as a peer dependency:
```bash
npm install --save graphql-ws
```
```bash
yarn add graphql-ws
```
Just by providing the `subscriptionUrl`, you can also generate a `graphql-ws` client. This client now supports both HTTP/Multipart Incremental Delivery for `@defer` and `@stream`, _and_ websockets subscriptions

@@ -48,0 +58,0 @@

import { DocumentNode } from 'graphql';
import { Client, ClientOptions } from 'graphql-ws';
import type { Fetcher, FetcherResult, FetcherParams, CreateFetcherOptions } from './types';
import { Client, ClientOptions, ExecutionResult } from 'graphql-ws';
import type { Fetcher, FetcherParams, CreateFetcherOptions } from './types';
export declare const isSubscriptionWithName: (document: DocumentNode, name: string) => boolean;
export declare const createSimpleFetcher: (options: CreateFetcherOptions, httpFetch: typeof fetch) => Fetcher;
export declare const createWebsocketsFetcherFromUrl: (url: string, connectionParams?: ClientOptions['connectionParams']) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<FetcherResult>) | undefined;
export declare const createWebsocketsFetcherFromClient: (wsClient: Client) => (graphQLParams: FetcherParams) => AsyncIterableIterator<FetcherResult>;
export declare const createWebsocketsFetcherFromUrl: (url: string, connectionParams?: ClientOptions['connectionParams']) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>) | undefined;
export declare const createWebsocketsFetcherFromClient: (wsClient: Client) => (graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>;
export declare const createLegacyWebsocketsFetcher: (legacyWsClient: {
request: (params: FetcherParams) => unknown;
}) => (graphQLParams: FetcherParams) => AsyncIterableIterator<FetcherResult>;
}) => (graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>;
export declare const createMultipartFetcher: (options: CreateFetcherOptions, httpFetch: typeof fetch) => Fetcher;
export declare const getWsFetcher: (options: CreateFetcherOptions) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<FetcherResult>) | undefined;
export declare const getWsFetcher: (options: CreateFetcherOptions) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>) | undefined;
//# sourceMappingURL=lib.d.ts.map

@@ -31,3 +31,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { meros } from 'meros';
import { createClient } from 'graphql-ws';
import { createClient, } from 'graphql-ws';
import { isAsyncIterable, makeAsyncIterableIteratorFromSink, } from '@n1ru4l/push-pull-async-iterable-iterator';

@@ -34,0 +34,0 @@ export const isSubscriptionWithName = (document, name) => {

import type { DocumentNode, IntrospectionQuery } from 'graphql';
import type { Client, ClientOptions } from 'graphql-ws';
import type { Client, ClientOptions, ExecutionResult } from 'graphql-ws';
export declare type Observable<T> = {

@@ -27,3 +27,3 @@ subscribe(opts: {

};
export declare type FetcherResultPayload = {
export declare type ExecutionResultPayload = {
data: IntrospectionQuery;

@@ -44,6 +44,10 @@ errors?: Array<any>;

};
export declare type FetcherResult = FetcherResultPayload | string;
export declare type FetcherResultPayload = ExecutionResultPayload;
export declare type MaybePromise<T> = T | Promise<T>;
export declare type SyncFetcherResult = FetcherResult | Observable<FetcherResult> | AsyncIterable<FetcherResult>;
export declare type FetcherReturnType = MaybePromise<SyncFetcherResult>;
export declare type FetcherResult = ExecutionResult | {
data: IntrospectionQuery;
};
export declare type SyncExecutionResult = ExecutionResult | Observable<ExecutionResult> | AsyncIterable<ExecutionResult>;
export declare type SyncFetcherResult = SyncExecutionResult;
export declare type FetcherReturnType = MaybePromise<SyncExecutionResult>;
export declare type Fetcher = (graphQLParams: FetcherParams, opts?: FetcherOpts) => FetcherReturnType;

@@ -50,0 +54,0 @@ export interface CreateFetcherOptions {

{
"name": "@graphiql/toolkit",
"version": "0.4.0",
"version": "0.4.1-canary-66346cbd.0",
"description": "Utility to build a fetcher for GraphiQL",

@@ -23,4 +23,3 @@ "contributors": [

"dependencies": {
"@n1ru4l/push-pull-async-iterable-iterator": "^3.0.0",
"graphql-ws": "^4.9.0",
"@n1ru4l/push-pull-async-iterable-iterator": "^3.1.0",
"meros": "^1.1.4"

@@ -31,6 +30,8 @@ },

"isomorphic-fetch": "^3.0.0",
"subscriptions-transport-ws": "^0.9.19"
"subscriptions-transport-ws": "^0.9.19",
"graphql-ws": "^5.5.5"
},
"peerDependencies": {
"graphql": ">= 15.5.0 <= 16.0.0-experimental-stream-defer.5"
"graphql": ">= 15.5.0 <= 16.0.0-experimental-stream-defer.5",
"graphql-ws": ">= 4.5.0"
},

@@ -37,0 +38,0 @@ "keywords": [

import { DocumentNode, visit, GraphQLError } from 'graphql';
import { meros } from 'meros';
import { createClient, Client, ClientOptions } from 'graphql-ws';
import {
createClient,
Client,
ClientOptions,
ExecutionResult,
} from 'graphql-ws';
import {
isAsyncIterable,

@@ -11,6 +16,5 @@ makeAsyncIterableIteratorFromSink,

Fetcher,
FetcherResult,
FetcherParams,
FetcherOpts,
FetcherResultPayload,
ExecutionResultPayload,
CreateFetcherOptions,

@@ -96,3 +100,3 @@ } from './types';

) =>
makeAsyncIterableIteratorFromSink<FetcherResult>(sink =>
makeAsyncIterableIteratorFromSink<ExecutionResult>(sink =>
wsClient!.subscribe(graphQLParams, {

@@ -131,3 +135,3 @@ ...sink,

const observable = legacyWsClient.request(graphQLParams);
return makeAsyncIterableIteratorFromSink<FetcherResult>(
return makeAsyncIterableIteratorFromSink<ExecutionResult>(
// @ts-ignore

@@ -161,3 +165,3 @@ sink => observable.subscribe(sink).unsubscribe,

}).then(response =>
meros<Extract<FetcherResultPayload, { hasNext: boolean }>>(response, {
meros<Extract<ExecutionResultPayload, { hasNext: boolean }>>(response, {
multiple: true,

@@ -164,0 +168,0 @@ }),

import type { DocumentNode, IntrospectionQuery } from 'graphql';
import type { Client, ClientOptions } from 'graphql-ws';
import type { Client, ClientOptions, ExecutionResult } from 'graphql-ws';

@@ -39,3 +39,3 @@ export type Observable<T> = {

export type FetcherResultPayload =
export type ExecutionResultPayload =
| {

@@ -57,13 +57,17 @@ data: IntrospectionQuery;

export type FetcherResult = FetcherResultPayload | string;
export type FetcherResultPayload = ExecutionResultPayload;
export type MaybePromise<T> = T | Promise<T>;
export type SyncFetcherResult =
| FetcherResult
| Observable<FetcherResult>
| AsyncIterable<FetcherResult>;
export type FetcherResult = ExecutionResult | { data: IntrospectionQuery };
export type FetcherReturnType = MaybePromise<SyncFetcherResult>;
export type SyncExecutionResult =
| ExecutionResult
| Observable<ExecutionResult>
| AsyncIterable<ExecutionResult>;
export type SyncFetcherResult = SyncExecutionResult;
export type FetcherReturnType = MaybePromise<SyncExecutionResult>;
export type Fetcher = (

@@ -70,0 +74,0 @@ graphQLParams: FetcherParams,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc