Initialisation
Added the packages and files for the backend server
This commit is contained in:
21
node_modules/@apollo/utils.dropunuseddefinitions/LICENSE
generated
vendored
Normal file
21
node_modules/@apollo/utils.dropunuseddefinitions/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
30
node_modules/@apollo/utils.dropunuseddefinitions/README.md
generated
vendored
Normal file
30
node_modules/@apollo/utils.dropunuseddefinitions/README.md
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# dropUnusedDefinitions
|
||||
|
||||
Given an operation document and an operation name, this function will return a
|
||||
new document with only the definitions required for the operation name provided.
|
||||
|
||||
If the provided operation name doesn't match any operation in the document,
|
||||
`dropUnusedDefinitions` will return the original document.
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { dropUnusedDefinitions } from "@apollo/utils.dropunuseddefinitions";
|
||||
|
||||
const operation = parse(`#graphql
|
||||
query Drop { ...DroppedFragment }
|
||||
fragment DroppedFragment on Query { abc }
|
||||
query Keep { ...KeptFragment }
|
||||
fragment KeptFragment on Query { def }
|
||||
`);
|
||||
const keepOperation = dropUnusedDefinitions(operation, "Keep");
|
||||
/**
|
||||
query Keep {
|
||||
...KeptFragment
|
||||
}
|
||||
|
||||
fragment KeptFragment on Query {
|
||||
def
|
||||
}
|
||||
*/
|
||||
```
|
||||
3
node_modules/@apollo/utils.dropunuseddefinitions/dist/index.d.ts
generated
vendored
Normal file
3
node_modules/@apollo/utils.dropunuseddefinitions/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type DocumentNode } from "graphql";
|
||||
export declare function dropUnusedDefinitions(ast: DocumentNode, operationName: string): DocumentNode;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@apollo/utils.dropunuseddefinitions/dist/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@apollo/utils.dropunuseddefinitions/dist/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,SAAS,CAAC;AAOhE,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,YAAY,EACjB,aAAa,EAAE,MAAM,GACpB,YAAY,CAQd"}
|
||||
13
node_modules/@apollo/utils.dropunuseddefinitions/dist/index.js
generated
vendored
Normal file
13
node_modules/@apollo/utils.dropunuseddefinitions/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.dropUnusedDefinitions = void 0;
|
||||
const graphql_1 = require("graphql");
|
||||
function dropUnusedDefinitions(ast, operationName) {
|
||||
const separated = (0, graphql_1.separateOperations)(ast)[operationName];
|
||||
if (!separated) {
|
||||
return ast;
|
||||
}
|
||||
return separated;
|
||||
}
|
||||
exports.dropUnusedDefinitions = dropUnusedDefinitions;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@apollo/utils.dropunuseddefinitions/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@apollo/utils.dropunuseddefinitions/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgE;AAOhE,SAAgB,qBAAqB,CACnC,GAAiB,EACjB,aAAqB;IAErB,MAAM,SAAS,GAAG,IAAA,4BAAkB,EAAC,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC;IACzD,IAAI,CAAC,SAAS,EAAE;QAGd,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,sDAWC"}
|
||||
26
node_modules/@apollo/utils.dropunuseddefinitions/package.json
generated
vendored
Normal file
26
node_modules/@apollo/utils.dropunuseddefinitions/package.json
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@apollo/utils.dropunuseddefinitions",
|
||||
"version": "2.0.1",
|
||||
"description": "Drop unused definitions from a GraphQL document",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/apollographql/apollo-utils.git",
|
||||
"directory": "packages/dropUnusedDefinitions/"
|
||||
},
|
||||
"keywords": [
|
||||
"apollo",
|
||||
"graphql",
|
||||
"typescript",
|
||||
"node"
|
||||
],
|
||||
"author": "Apollo <packages@apollographql.com>",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"graphql": "14.x || 15.x || 16.x"
|
||||
}
|
||||
}
|
||||
86
node_modules/@apollo/utils.dropunuseddefinitions/src/__tests__/dropUnusedDefinitions.test.ts
generated
vendored
Normal file
86
node_modules/@apollo/utils.dropunuseddefinitions/src/__tests__/dropUnusedDefinitions.test.ts
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
import { print, parse } from "graphql";
|
||||
import { dropUnusedDefinitions } from "..";
|
||||
|
||||
describe("dropUnusedDefinitions", () => {
|
||||
it("anonymous operation", () => {
|
||||
const operation = parse(`#graphql
|
||||
{abc}
|
||||
`);
|
||||
expect(print(dropUnusedDefinitions(operation, ""))).toMatchInlineSnapshot(`
|
||||
"{
|
||||
abc
|
||||
}"
|
||||
`);
|
||||
});
|
||||
|
||||
it("named operation", () => {
|
||||
const operation = parse(`#graphql
|
||||
query MyQuery {abc}
|
||||
`);
|
||||
expect(print(dropUnusedDefinitions(operation, "MyQuery")))
|
||||
.toMatchInlineSnapshot(`
|
||||
"query MyQuery {
|
||||
abc
|
||||
}"
|
||||
`);
|
||||
});
|
||||
|
||||
it("multiple operations", () => {
|
||||
const operation = parse(`#graphql
|
||||
query Keep { abc }
|
||||
query Drop { def }
|
||||
`);
|
||||
expect(print(dropUnusedDefinitions(operation, "Keep")))
|
||||
.toMatchInlineSnapshot(`
|
||||
"query Keep {
|
||||
abc
|
||||
}"
|
||||
`);
|
||||
});
|
||||
|
||||
it("includes only used fragments", () => {
|
||||
const operation = parse(`#graphql
|
||||
query Drop { ...DroppedFragment }
|
||||
fragment DroppedFragment on Query { abc }
|
||||
query Keep { ...KeptFragment }
|
||||
fragment KeptFragment on Query { def }
|
||||
`);
|
||||
expect(print(dropUnusedDefinitions(operation, "Keep")))
|
||||
.toMatchInlineSnapshot(`
|
||||
"query Keep {
|
||||
...KeptFragment
|
||||
}
|
||||
|
||||
fragment KeptFragment on Query {
|
||||
def
|
||||
}"
|
||||
`);
|
||||
});
|
||||
|
||||
it("preserves entire document when operation isn't found", () => {
|
||||
const operation = parse(`#graphql
|
||||
query Keep { ...KeptFragment }
|
||||
fragment KeptFragment on Query { abc }
|
||||
query AlsoKeep { ...AlsoKeptFragment }
|
||||
fragment AlsoKeptFragment on Query { def }
|
||||
`);
|
||||
expect(print(dropUnusedDefinitions(operation, "Unknown")))
|
||||
.toMatchInlineSnapshot(`
|
||||
"query Keep {
|
||||
...KeptFragment
|
||||
}
|
||||
|
||||
fragment KeptFragment on Query {
|
||||
abc
|
||||
}
|
||||
|
||||
query AlsoKeep {
|
||||
...AlsoKeptFragment
|
||||
}
|
||||
|
||||
fragment AlsoKeptFragment on Query {
|
||||
def
|
||||
}"
|
||||
`);
|
||||
});
|
||||
});
|
||||
5
node_modules/@apollo/utils.dropunuseddefinitions/src/__tests__/tsconfig.json
generated
vendored
Normal file
5
node_modules/@apollo/utils.dropunuseddefinitions/src/__tests__/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.base",
|
||||
"include": ["**/*"],
|
||||
"references": [{ "path": "../../" }]
|
||||
}
|
||||
19
node_modules/@apollo/utils.dropunuseddefinitions/src/index.ts
generated
vendored
Normal file
19
node_modules/@apollo/utils.dropunuseddefinitions/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { type DocumentNode, separateOperations } from "graphql";
|
||||
|
||||
// A GraphQL query may contain multiple named operations, with the operation to
|
||||
// use specified separately by the client. This transformation drops unused
|
||||
// operations from the query, as well as any fragment definitions that are not
|
||||
// referenced. (In general we recommend that unused definitions are dropped on
|
||||
// the client before sending to the server to save bandwidth and parsing time.)
|
||||
export function dropUnusedDefinitions(
|
||||
ast: DocumentNode,
|
||||
operationName: string,
|
||||
): DocumentNode {
|
||||
const separated = separateOperations(ast)[operationName];
|
||||
if (!separated) {
|
||||
// If the given operationName isn't found, just make this whole transform a
|
||||
// no-op instead of crashing.
|
||||
return ast;
|
||||
}
|
||||
return separated;
|
||||
}
|
||||
Reference in New Issue
Block a user