= ({
10 | data,
11 | maxHeight = 400,
12 | }) => {
13 | const classes = useVirtualizedJsonViewerStyles();
14 |
15 | return (
16 |
17 | {JSON.stringify(data, null, 2)}
18 |
19 | );
20 | };
21 |
--------------------------------------------------------------------------------
/packages/apollo-forest-run/compat/src/utilities/common/compact.ts:
--------------------------------------------------------------------------------
1 | import { TupleToIntersection } from './mergeDeep';
2 |
3 | /**
4 | * Merges the provided objects shallowly and removes
5 | * all properties with an `undefined` value
6 | */
7 | export function compact(
8 | ...objects: TArgs
9 | ): TupleToIntersection {
10 | const result = Object.create(null);
11 |
12 | objects.forEach(obj => {
13 | if (!obj) return;
14 | Object.keys(obj).forEach(key => {
15 | const value = (obj as any)[key];
16 | if (value !== void 0) {
17 | result[key] = value;
18 | }
19 | });
20 | });
21 |
22 | return result;
23 | }
24 |
--------------------------------------------------------------------------------
/packages/apollo-react-relay-duct-tape-compiler/src/typescriptTransforms/__tests__/fixtures/type-generator/mutation-with-response-on-inline-fragments.graphql:
--------------------------------------------------------------------------------
1 | mutation TestMutation($input: CommentCreateInput!) @raw_response_type {
2 | commentCreate(input: $input) {
3 | viewer {
4 | actor {
5 | ...InlineFragmentWithOverlappingFields
6 | }
7 | }
8 | }
9 | }
10 |
11 | fragment InlineFragmentWithOverlappingFields on Actor {
12 | ... on User {
13 | hometown {
14 | id
15 | name
16 | }
17 | }
18 | ... on Page {
19 | name
20 | hometown {
21 | id
22 | message {
23 | text
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/packages/apollo-react-relay-duct-tape-compiler/src/typescriptTransforms/__tests__/fixtures/type-generator/match-field-in-query.graphql:
--------------------------------------------------------------------------------
1 | query NameRendererQuery {
2 | me {
3 | nameRenderer @match {
4 | ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react")
5 | ...MarkdownUserNameRenderer_name
6 | @module(name: "MarkdownUserNameRenderer.react")
7 | }
8 | }
9 | }
10 |
11 | fragment PlainUserNameRenderer_name on PlainUserNameRenderer {
12 | plaintext
13 | data {
14 | text
15 | }
16 | }
17 |
18 | fragment MarkdownUserNameRenderer_name on MarkdownUserNameRenderer {
19 | markdown
20 | data {
21 | markup
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestFragment.graphql.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable */
2 | /* eslint-disable */
3 | // @ts-nocheck
4 |
5 | import { FragmentRefs } from "@graphitation/apollo-react-relay-duct-tape";
6 | export type hooksTestFragment = {
7 | readonly id: string;
8 | readonly name: string;
9 | readonly __typename: "User";
10 | readonly " $fragmentType": "hooksTestFragment";
11 | };
12 | export type hooksTestFragment$data = hooksTestFragment;
13 | export type hooksTestFragment$key = {
14 | readonly " $data"?: hooksTestFragment$data | undefined;
15 | readonly " $fragmentSpreads": FragmentRefs<"hooksTestFragment">;
16 | };
17 |
--------------------------------------------------------------------------------
/examples/supermassive-todomvc/src/schema/utils.ts:
--------------------------------------------------------------------------------
1 | import { Kind } from "graphql";
2 | import { OperationDefinitionNode } from "@graphitation/supermassive";
3 | import { Operation } from "@apollo/client";
4 |
5 | export function getOperationDefinitionNode(
6 | operation: Operation
7 | ): OperationDefinitionNode | null {
8 | if (operation?.query?.definitions) {
9 | const operationDefinitionNode = operation.query.definitions.find(
10 | ({ kind }) => kind === Kind.OPERATION_DEFINITION
11 | ) as OperationDefinitionNode | undefined;
12 |
13 | if (operationDefinitionNode?.operation) {
14 | return operationDefinitionNode;
15 | }
16 | }
17 | return null;
18 | }
19 |
--------------------------------------------------------------------------------
/package-template/src/cli-cjs.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /**
4 | * This trampoline allows dependent packages inside this monorepo to use this
5 | * CLI tool without first needing to compile the TypeScript code to CommonJS
6 | * for Node to consume.
7 | *
8 | * It relies on the `bin` entry of the `package.json` file to point to this
9 | * file, but be overwritten by a `publishConfig.bin` entry to point directly to
10 | * the compiled version of `cli.ts`.
11 | */
12 |
13 | // Configure dynamic ts compiler
14 | require("ts-node").register({
15 | project: require("path").resolve(__dirname, "../tsconfig.json"),
16 | });
17 | // Now load normal ts cli bin
18 | require("./cli");
19 |
--------------------------------------------------------------------------------
/packages/apollo-forest-run/compat/src/utilities/observables/iteration.ts:
--------------------------------------------------------------------------------
1 | import { Observer } from "./Observable";
2 |
3 | export function iterateObserversSafely(
4 | observers: Set>,
5 | method: keyof Observer,
6 | argument?: A,
7 | ) {
8 | // In case observers is modified during iteration, we need to commit to the
9 | // original elements, which also provides an opportunity to filter them down
10 | // to just the observers with the given method.
11 | const observersWithMethod: Observer[] = [];
12 | observers.forEach(obs => obs[method] && observersWithMethod.push(obs));
13 | observersWithMethod.forEach(obs => (obs as any)[method](argument));
14 | }
15 |
--------------------------------------------------------------------------------
/packages/supermassive/src/utilities/annotateDocumentGraphQLTransform.ts:
--------------------------------------------------------------------------------
1 | import {
2 | FragmentDefinitionNode,
3 | GraphQLSchema,
4 | OperationDefinitionNode,
5 | } from "graphql";
6 | import {
7 | addMinimalViableSchemaToExecutableDefinitionNode,
8 | AddMinimalViableSchemaToRequestDocumentOptions,
9 | } from "./addMinimalViableSchemaToRequestDocument";
10 |
11 | export const annotateDocumentGraphQLTransform = (
12 | schema: GraphQLSchema,
13 | options?: AddMinimalViableSchemaToRequestDocumentOptions,
14 | ) => {
15 | return (node: FragmentDefinitionNode | OperationDefinitionNode) =>
16 | addMinimalViableSchemaToExecutableDefinitionNode(schema, node, options);
17 | };
18 |
--------------------------------------------------------------------------------
/packages/apollo-react-relay-duct-tape-compiler/src/__tests__/rewriteGraphitationDirectives.test.ts:
--------------------------------------------------------------------------------
1 | import { rewriteGraphitationDirectives } from "../rewriteGraphitationDirectives";
2 | import dedent from "dedent";
3 |
4 | describe(rewriteGraphitationDirectives, () => {
5 | it("rewrites @watchNode to Relay's @refetchable", () => {
6 | const doc = `
7 | fragment SomeModule_fooFragment on User @watchNode {
8 | name
9 | }
10 | `;
11 | expect(rewriteGraphitationDirectives(doc).trim()).toEqual(dedent`
12 | fragment SomeModule_fooFragment on User @refetchable(queryName: "SomeModule_fooWatchNodeQuery") {
13 | name
14 | }
15 | `);
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/examples/supermassive-todomvc/src/components/__generated__/TodoUpdatesSubscription.graphql.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable */
2 | /* eslint-disable */
3 | // @ts-nocheck
4 |
5 | import { FragmentRefs } from "@graphitation/apollo-react-relay-duct-tape";
6 | export type TodoUpdatesSubscriptionVariables = {
7 | limit: number;
8 | };
9 | export type TodoUpdatesSubscriptionResponse = {
10 | readonly emitTodos: {
11 | readonly id: string;
12 | readonly " $fragmentSpreads": FragmentRefs<"TodoFragment">;
13 | } | null;
14 | };
15 | export type TodoUpdatesSubscription = {
16 | readonly response: TodoUpdatesSubscriptionResponse;
17 | readonly variables: TodoUpdatesSubscriptionVariables;
18 | };
19 |
--------------------------------------------------------------------------------
/packages/apollo-forest-run/compat/src/link/utils/toPromise.ts:
--------------------------------------------------------------------------------
1 | import { invariant } from '../../utilities/globals';
2 | import { Observable } from '../../utilities';
3 |
4 | export function toPromise(observable: Observable): Promise {
5 | let completed = false;
6 | return new Promise((resolve, reject) => {
7 | observable.subscribe({
8 | next: data => {
9 | if (completed) {
10 | invariant.warn(
11 | `Promise Wrapper does not support multiple results from Observable`,
12 | );
13 | } else {
14 | completed = true;
15 | resolve(data);
16 | }
17 | },
18 | error: reject,
19 | });
20 | });
21 | }
22 |
--------------------------------------------------------------------------------
/packages/apollo-forest-run/compat/src/testing/core/mocking/mockClient.ts:
--------------------------------------------------------------------------------
1 | import { DocumentNode } from 'graphql';
2 |
3 | import { ApolloClient } from '../../../core';
4 | import { InMemoryCache, NormalizedCacheObject } from '../../../cache';
5 | import { mockSingleLink } from './mockLink';
6 |
7 | export function createMockClient(
8 | data: TData,
9 | query: DocumentNode,
10 | variables = {},
11 | ): ApolloClient {
12 | return new ApolloClient({
13 | link: mockSingleLink({
14 | request: { query, variables },
15 | result: { data },
16 | }).setOnError(error => { throw error }),
17 | cache: new InMemoryCache({ addTypename: false }),
18 | });
19 | }
20 |
--------------------------------------------------------------------------------
/packages/graphql-eslint-rules/src/non-nullable-list-items.ts:
--------------------------------------------------------------------------------
1 | import { GraphQLESLintRule } from "@graphql-eslint/eslint-plugin";
2 |
3 | const rule: GraphQLESLintRule = {
4 | meta: {
5 | type: "problem",
6 | docs: {
7 | description: `Ensures that list items are not nullable`,
8 | category: "Schema",
9 | },
10 | schema: [],
11 | },
12 | create(context) {
13 | return {
14 | ListType(node) {
15 | if (node.gqlType.kind !== "NonNullType") {
16 | context.report({
17 | message: `List items must be not nullable.`,
18 | node,
19 | });
20 | }
21 | },
22 | };
23 | },
24 | };
25 |
26 | export default rule;
27 |
--------------------------------------------------------------------------------
/packages/supermassive/src/utilities/schemaFragmentFromMinimalViableSchemaDocument.ts:
--------------------------------------------------------------------------------
1 | import {
2 | DocumentWithMinimalViableSchema,
3 | SchemaFragment,
4 | UserResolvers,
5 | } from "../types";
6 | import { createSchemaDefinitions } from "./mergeSchemaDefinitions";
7 |
8 | export function schemaFragmentFromMinimalViableSchemaDocument(
9 | document: DocumentWithMinimalViableSchema,
10 | resolvers: UserResolvers,
11 | schemaId: string,
12 | ): SchemaFragment {
13 | const schemaDefinitions = createSchemaDefinitions(
14 | document.definitions.map((def) => def.__defs),
15 | );
16 |
17 | return {
18 | schemaId,
19 | definitions: schemaDefinitions,
20 | resolvers,
21 | };
22 | }
23 |
--------------------------------------------------------------------------------
/examples/apollo-watch-fragments/src/index.tsx:
--------------------------------------------------------------------------------
1 | import "./wdyr";
2 |
3 | import * as React from "react";
4 | import ReactDOM from "react-dom";
5 | import App from "./App";
6 | import { ApolloClient, ApolloProvider } from "@apollo/client";
7 | import { createClient } from "./graphql";
8 |
9 | const client = createClient();
10 |
11 | ReactDOM.render(
12 |
13 |
14 |
15 |
16 | ,
17 | document.getElementById("root"),
18 | );
19 |
20 | /**
21 | * Make the client available to the debug console.
22 | */
23 | declare global {
24 | var $client: ApolloClient;
25 | }
26 | global.$client = client;
27 |
--------------------------------------------------------------------------------
/packages/apollo-react-relay-duct-tape-compiler/src/typescriptTransforms/__tests__/fixtures/type-generator/mutation-with-enums-on-fragment.graphql:
--------------------------------------------------------------------------------
1 | mutation CommentCreateMutation(
2 | $input: CommentCreateInput!
3 | $first: Int
4 | $orderBy: [String!]
5 | ) @raw_response_type {
6 | commentCreate(input: $input) {
7 | comment {
8 | friends(first: $first, orderby: $orderBy) {
9 | edges {
10 | node {
11 | id
12 | __typename
13 | ...FriendFragment
14 | }
15 | }
16 | }
17 | }
18 | }
19 | }
20 |
21 | fragment FriendFragment on User {
22 | name
23 | lastName
24 | profilePicture2 {
25 | test_enums
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/apollo-react-relay-duct-tape-compiler/src/cli-cjs.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /**
4 | * This trampoline allows dependent packages inside this monorepo to use this
5 | * CLI tool without first needing to compile the TypeScript code to CommonJS
6 | * for Node to consume.
7 | *
8 | * It relies on the `bin` entry of the `package.json` file to point to this
9 | * file, but be overwritten by a `publishConfig.bin` entry to point directly to
10 | * the compiled version of `cli.ts`.
11 | */
12 |
13 | // Configure dynamic ts compiler
14 | require("ts-node").register({
15 | project: require("path").resolve(__dirname, "../tsconfig.json"),
16 | });
17 | // Now load normal ts cli bin
18 | require("./cli");
19 |
--------------------------------------------------------------------------------
/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable @typescript-eslint/no-explicit-any */
2 |
3 | export interface FragmentReference {
4 | /**
5 | * In case of a watch query on a Node type, the `id` needs to be provided.
6 | * In case of a watch query on the Query type, this should be omitted.
7 | */
8 | id?: unknown;
9 |
10 | /**
11 | * These are the request variables, which is named awkwardly `__fragments`
12 | * because that's the name of the property Relay uses to pass context data so
13 | * not introducing a different property name felt right, from a migration
14 | * perspective.
15 | */
16 | __fragments?: Record;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/apollo-forest-run/compat/config/jest.config.js:
--------------------------------------------------------------------------------
1 | const { compilerOptions } = require("../tsconfig.json");
2 |
3 | module.exports = {
4 | rootDir: '../src',
5 | transform: {
6 | '^.+.(t|j)sx?$': 'ts-jest'
7 | },
8 | transformIgnorePatterns: [
9 | '/node_modules/(?!(quick-lru))'
10 | ],
11 | globals: {
12 | 'ts-jest': {
13 | diagnostics: {
14 | exclude: ['**'],
15 | },
16 | tsconfig: {
17 | ...compilerOptions,
18 | allowJs: true,
19 | },
20 | },
21 | },
22 | moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
23 | testURL: 'http://localhost',
24 | setupFiles: ['/config/jest/setup.ts'],
25 | testEnvironment: 'jsdom',
26 | };
27 |
--------------------------------------------------------------------------------
/packages/apollo-forest-run/compat/src/testing/core/mocking/mockWatchQuery.ts:
--------------------------------------------------------------------------------
1 | import { MockedResponse } from './mockLink';
2 | import mockQueryManager from './mockQueryManager';
3 | import { ObservableQuery } from '../../../core';
4 |
5 | export default (
6 | reject: (reason: any) => any,
7 | ...mockedResponses: MockedResponse[]
8 | ): ObservableQuery => {
9 | const queryManager = mockQueryManager(reject, ...mockedResponses);
10 | const firstRequest = mockedResponses[0].request;
11 | return queryManager.watchQuery({
12 | query: firstRequest.query!,
13 | variables: firstRequest.variables,
14 | notifyOnNetworkStatusChange: false // XXX might not always be the right option. Set for legacy reasons.
15 | });
16 | };
17 |
--------------------------------------------------------------------------------
/packages/apollo-react-relay-duct-tape-compiler/src/typescriptTransforms/__tests__/fixtures/type-generator/unmasked-fragment-spreads.graphql:
--------------------------------------------------------------------------------
1 | fragment UserProfile on User {
2 | profilePicture(size: $ProfilePicture_SIZE) {
3 | ...PhotoFragment @relay(mask: false)
4 |
5 | # duplicated field should be merged
6 | ...AnotherRecursiveFragment @relay(mask: false)
7 |
8 | # Compose child fragment
9 | ...PhotoFragment
10 | }
11 | }
12 |
13 | fragment PhotoFragment on Image {
14 | uri
15 | ...RecursiveFragment @relay(mask: false)
16 | }
17 |
18 | fragment RecursiveFragment on Image @relay(mask: false) {
19 | uri
20 | width
21 | }
22 |
23 | fragment AnotherRecursiveFragment on Image {
24 | uri
25 | height
26 | }
27 |
--------------------------------------------------------------------------------
/.config/1espt/PipelineAutobaseliningConfig.yml:
--------------------------------------------------------------------------------
1 | ## DO NOT MODIFY THIS FILE MANUALLY. This is part of auto-baselining from 1ES Pipeline Templates. Go to [https://aka.ms/1espt-autobaselining] for more details.
2 |
3 | pipelines:
4 | 8:
5 | retail:
6 | source:
7 | credscan:
8 | lastModifiedDate: 2024-10-14
9 | eslint:
10 | lastModifiedDate: 2024-10-14
11 | psscriptanalyzer:
12 | lastModifiedDate: 2024-10-14
13 | armory:
14 | lastModifiedDate: 2024-10-14
15 | binary:
16 | credscan:
17 | lastModifiedDate: 2025-01-20
18 | binskim:
19 | lastModifiedDate: 2025-01-20
20 | spotbugs:
21 | lastModifiedDate: 2025-01-20
22 |
--------------------------------------------------------------------------------
/packages/apollo-forest-run/compat/src/react/hooks/useApolloClient.ts:
--------------------------------------------------------------------------------
1 | import { invariant } from '../../utilities/globals';
2 | import { useContext } from 'react';
3 | import { ApolloClient } from '../../core';
4 | import { getApolloContext } from '../context';
5 |
6 | export function useApolloClient(
7 | override?: ApolloClient