Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra(graphql): upgrade graphql to v16 and apollo-server to v4 #8753

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
383790d
wip - apollo graphql upgrade
luvkapur Mar 14, 2024
4e0246c
wip - apollo graphql upgrade
luvkapur Apr 2, 2024
fe7e45b
wip - apollo server v4 update
luvkapur Apr 4, 2024
66d9bad
apollo graphql upgrade
luvkapur Apr 5, 2024
5f2db2e
merge origin/master
luvkapur Apr 5, 2024
cc2afd3
merge origin/master
luvkapur Apr 5, 2024
c3bdbba
merge origin/master
luvkapur Apr 5, 2024
cc8435e
uninstall subscription-transport
luvkapur Apr 5, 2024
8079890
install subscription-transport back @apollo/client still uses it as p…
luvkapur Apr 5, 2024
dc551c3
update gql imports
luvkapur Apr 5, 2024
027d574
setup proxy sub
luvkapur Apr 5, 2024
2f81d31
fix proxy subscription
luvkapur Apr 5, 2024
b4e2f72
update graphql client to not use subscription-transport-ws protocol f…
luvkapur Apr 7, 2024
e4593d9
successfully remove subscriptions-transport-ws
luvkapur Apr 7, 2024
0d3a095
wip - fix subscriptions
luvkapur Apr 8, 2024
ba69c5c
clean up
luvkapur Apr 8, 2024
3342a6a
wip - fix ws subscriptions
luvkapur Apr 8, 2024
76368d1
integrate remote schema stitching
luvkapur Apr 9, 2024
77de0bc
Merge branch 'master' into graphql-apollo-update
luvkapur Apr 9, 2024
9f97824
bump core aspect env version
luvkapur Apr 9, 2024
0b54cbb
lint fix
luvkapur Apr 9, 2024
81fc426
merge origin/master
luvkapur Apr 9, 2024
ba1fbbc
merge origin/master
luvkapur Apr 9, 2024
6bfad5e
bump teambit.harmony/envs/core-aspect-env-jest
luvkapur Apr 9, 2024
27a5d32
merge origin/master
luvkapur Apr 9, 2024
a6cf185
add explicit types for DocumentNode in hooks
luvkapur Apr 9, 2024
631df4a
fix hooks to use useQuery from @apollo/client
luvkapur Apr 9, 2024
5fe68b7
build fix
luvkapur Apr 9, 2024
6949fe0
lint fix
luvkapur Apr 9, 2024
8e4f08a
bump teambit.harmony/envs/core-aspect-env-jest to v0.0.13
GiladShoham Apr 10, 2024
f64d3f6
merge origin/master
luvkapur Apr 12, 2024
3d45d97
fix writing subscription data to client cache
luvkapur Apr 16, 2024
ee86afa
Merge branch 'master' into graphql-apollo-update
luvkapur Apr 16, 2024
6abcb0d
sync core-aspect-env version
luvkapur Apr 16, 2024
b1499ad
Merge branch 'master' into graphql-apollo-update
luvkapur Apr 16, 2024
c8a3150
update hooks to use types from @apollo/client instead of graphql
luvkapur Apr 16, 2024
c61d90e
sync with origin/master
luvkapur Apr 30, 2024
388ebd4
remove deprecated graphql-types-json and replace it with graphql-scalars
luvkapur Apr 30, 2024
d275531
fix to get symphony working
luvkapur Aug 1, 2024
6261601
upgrade core aspect env
luvkapur Aug 1, 2024
ce6ff11
add resolver adapter to pass context as first param
luvkapur Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
776 changes: 679 additions & 97 deletions .bitmap

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ jobs:
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.0.30-v1
key: core-aspect-env-v0.0.31-v1
- run: echo $BIT_FEATURES
- run: node -v
- run: npm -v
Expand Down Expand Up @@ -487,7 +487,7 @@ jobs:
name: bbit install
command: cd bit && bbit install
- save_cache:
key: core-aspect-env-v0.0.30-v1
key: core-aspect-env-v0.0.31-v1
paths:
- /home/circleci/Library/Caches/Bit/capsules/caec9a1075d4addee151dbe7e351b809aaa4b088
- run: cd bit && npm run link-bit-legacy
Expand Down Expand Up @@ -533,7 +533,7 @@ jobs:
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
- restore_cache:
key: core-aspect-env-v0.0.30-v1
key: core-aspect-env-v0.0.31-v1
# - update_ssh_agent
# temporary, check if we can remove it
- run: cd bit && bit cc
Expand Down Expand Up @@ -570,7 +570,7 @@ jobs:
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
- restore_cache:
key: core-aspect-env-v0.0.30-v1
key: core-aspect-env-v0.0.31-v1
- bit_config:
env: "hub"
- restore_cache:
Expand Down Expand Up @@ -882,7 +882,7 @@ jobs:
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.0.30-v1
key: core-aspect-env-v0.0.31-v1
- run: npm view @teambit/bit version > ./version.txt
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
Expand Down
6 changes: 3 additions & 3 deletions components/hooks/use-lane-components/use-lane-components.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { gql } from '@apollo/client';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';
import { ComponentID, ComponentModel, componentOverviewFields } from '@teambit/component';
import { LaneId } from '@teambit/lane-id';
import { ComponentDescriptor } from '@teambit/component-descriptor';
import { compact } from 'lodash';

const GET_LANE_COMPONENTS = gql`
const GET_LANE_COMPONENTS: DocumentNode = gql`
query LaneComponent($ids: [String!], $extensionId: String, $skipList: Boolean!) {
lanes {
id
Expand Down
12 changes: 6 additions & 6 deletions components/hooks/use-lanes/use-lanes.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useMemo, useCallback } from 'react';
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { LaneModel, LanesModel, LanesQuery } from '@teambit/lanes.ui.models.lanes-model';
import { gql } from '@apollo/client';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { LaneModel, LanesModel } from '@teambit/lanes.ui.models.lanes-model';
import { gql } from 'graphql-tag';
import { LaneId } from '@teambit/lane-id';
import { isEqual } from 'lodash';
import { useLanesContext } from './lanes-context';

const GET_LANES = gql`
const GET_LANES: DocumentNode = gql`
query Lanes(
$extensionId: String
$laneIds: [String!]
Expand Down Expand Up @@ -170,7 +170,7 @@ type UseRootLanes = (
const useRootLanes: UseRootLanes = (viewedLaneId, skip, options = {}, scope) => {
const { ids, offset, limit, sort } = options;

const { data, fetchMore, loading } = useDataQuery<LanesQuery>(GET_LANES, {
const { data, fetchMore, loading } = useDataQuery(GET_LANES, {
variables: {
laneIds: ids,
offset,
Expand Down Expand Up @@ -258,7 +258,7 @@ const useRootLanes: UseRootLanes = (viewedLaneId, skip, options = {}, scope) =>
};

export const useSearchLanes: SearchLanes = (search, skip) => {
const { data: searchData, loading: loadingSearch } = useDataQuery<LanesQuery>(GET_LANES, {
const { data: searchData, loading: loadingSearch } = useDataQuery(GET_LANES, {
variables: {
search,
skipViewedLane: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';
import { LaneId } from '@teambit/lane-id';
import { ComponentID, ComponentIdObj } from '@teambit/component-id';
import { LaneDiff, PlainLaneDiff, ChangeType } from '@teambit/lanes.entities.lane-diff';

export type LaneDiffStatusQueryResponse = {
lanes: {
diffStatus: {
source: { name: string; scope: string };
target: { name: string; scope: string };
upToDate: boolean;
componentsStatus: Array<{
componentId: ComponentIdObj;
changes: ChangeType[];
upToDate: boolean;
sourceHead: string;
targetHead?: string;
}>;
};
};
};

export const QUERY_LANE_DIFF_STATUS: DocumentNode = gql`
query LaneDiffStatus($source: String!, $target: String!, $options: DiffStatusOptions) {
lanes {
id
diffStatus(source: $source, target: $target, options: $options) {
id
source {
name
scope
}
target {
name
scope
}
componentsStatus {
id
componentId {
scope
name
version
}
sourceHead
targetHead
changes
upToDate
unrelated
}
}
}
}
`;

export type UseLaneDiffStatusResult = { loading?: boolean; laneDiff?: LaneDiff };
export type UseLaneDiffStatus = (props: UseLaneDiffStatusProps) => UseLaneDiffStatusResult;
export type UseLaneDiffStatusOptions = {
skipChanges?: boolean;
skipUpToDate?: boolean;
};

export type UseLaneDiffStatusProps = {
baseId?: string;
compareId?: string;
options?: UseLaneDiffStatusOptions;
};

export const useLaneDiffStatus: UseLaneDiffStatus = ({ baseId, compareId, options }) => {
const { data, loading } = useDataQuery<LaneDiffStatusQueryResponse>(QUERY_LANE_DIFF_STATUS, {
variables: {
source: compareId,
target: baseId,
options,
},
skip: !baseId || !compareId,
});

const plainLaneDiff: PlainLaneDiff | undefined = data?.lanes.diffStatus && {
sourceLane: LaneId.from(data.lanes.diffStatus.source.name, data.lanes.diffStatus.source.scope).toString(),
targetLane: LaneId.from(data.lanes.diffStatus.target.name, data.lanes.diffStatus.target.scope).toString(),
diff: data.lanes.diffStatus.componentsStatus.map((c) => ({
...c,
changes: c.changes || [],
componentId: ComponentID.fromObject(c.componentId).toString(),
})),
};

const laneDiff = plainLaneDiff && LaneDiff.from(plainLaneDiff);

return {
loading,
laneDiff,
};
};
6 changes: 3 additions & 3 deletions components/ui/hooks/use-core-aspects/use-core-aspects.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { gql } from '@apollo/client';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';

export type CoreAspectIdByPackageName = {
[packageName: string]: string;
};

const GET_CORE_ASPECTS = gql`
const GET_CORE_ASPECTS: DocumentNode = gql`
query CoreAspects {
coreAspects
}
Expand Down
6 changes: 3 additions & 3 deletions scopes/api-reference/hooks/use-api/use-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { gql } from '@apollo/client';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';
import { APIReferenceModel } from '@teambit/api-reference.models.api-reference-model';
import { APINodeRenderer } from '@teambit/api-reference.models.api-node-renderer';

const GET_SCHEMA = gql`
const GET_SCHEMA: DocumentNode = gql`
query Schema($componentId: String!, $skipInternals: Boolean) {
getHost {
id # used for GQL caching
Expand Down
17 changes: 7 additions & 10 deletions scopes/api-reference/hooks/use-schema/use-schema.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DataQueryResult, useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { gql } from '@apollo/client';
import { SchemaQueryResult, APIReferenceModel } from '@teambit/api-reference.models.api-reference-model';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';
import { APIReferenceModel } from '@teambit/api-reference.models.api-reference-model';
import { APINodeRenderer } from '@teambit/api-reference.models.api-node-renderer';

const GET_SCHEMA = gql`
const GET_SCHEMA: DocumentNode = gql`
query Schema($extensionId: String!, $componentId: String!) {
getHost(id: $extensionId) {
id # used for GQL caching
Expand All @@ -16,11 +16,8 @@ export function useSchema(
host: string,
componentId: string,
apiNodeRenderers: APINodeRenderer[]
): { apiModel?: APIReferenceModel } & Omit<
DataQueryResult<SchemaQueryResult, { extensionId: string; componentId: string }>,
'data'
> {
const { data, ...rest } = useDataQuery(GET_SCHEMA, {
): { apiModel?: APIReferenceModel; loading?: boolean } {
const { data, loading } = useDataQuery(GET_SCHEMA, {
variables: {
extensionId: host,
componentId,
Expand All @@ -30,7 +27,7 @@ export function useSchema(
const apiModel = data?.getHost?.getSchema ? APIReferenceModel.from(data, apiNodeRenderers) : undefined;

return {
...rest,
loading,
apiModel,
};
}
1 change: 1 addition & 0 deletions scopes/cloud/cloud/cloud.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export class CloudMain {
const { clientId: clientIdFromReq, redirectUri, username: usernameFromReq } = req.query;
const username = typeof usernameFromReq === 'string' ? usernameFromReq : undefined;
let { token } = req.query;

if (Array.isArray(token)) {
token = token[0];
}
Expand Down
6 changes: 3 additions & 3 deletions scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { gql } from '@apollo/client';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';
import { ScopeDescriptor } from '@teambit/scopes.scope-descriptor';
import { ScopeID } from '@teambit/scopes.scope-id';

export const GET_CLOUD_SCOPES_QUERY = gql`
export const GET_CLOUD_SCOPES_QUERY: DocumentNode = gql`
query GET_CLOUD_SCOPES($ids: [String!]) {
getCloudScopes(ids: $ids) {
id
Expand Down
6 changes: 3 additions & 3 deletions scopes/cloud/hooks/use-current-user/use-current-user.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { gql } from '@apollo/client';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';
import { CloudUser } from '@teambit/cloud.models.cloud-user';

export const CURRENT_USER_QUERY = gql`
export const CURRENT_USER_QUERY: DocumentNode = gql`
query CurrentUser($redirectUrl: String!) {
getCurrentUser {
username
Expand Down
4 changes: 2 additions & 2 deletions scopes/cloud/hooks/use-logout/use-logout.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMutation } from '@teambit/ui';
import { gql } from '@apollo/client';
import { gql, DocumentNode } from '@apollo/client';

export const LOGOUT_MUTATION = gql`
export const LOGOUT_MUTATION: DocumentNode = gql`
mutation LogoutUser {
logout
}
Expand Down
3 changes: 2 additions & 1 deletion scopes/compilation/bundler/dev-server.graphql.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@teambit/component';
import { Schema } from '@teambit/graphql';
import { gql } from '@apollo/client';
import { gql } from 'graphql-tag';

import { BundlerMain } from './bundler.main.runtime';

Expand All @@ -26,6 +26,7 @@ export function devServerSchema(bundler: BundlerMain): Schema {
// the gotHost.get query is "id".
// see it in scopes/component/component/component.graphql.ts
const requestedId = context.body.variables.id;

// if we ask for specific id with specific version it means we want to fetch if from scope
// so don't return the server url
// see https://github.com/teambit/bit/issues/5328
Expand Down
6 changes: 3 additions & 3 deletions scopes/component/component/host/use-component-host.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { gql } from '@apollo/client';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';

import { ComponentHostModel } from './component-host-model';

const COMPONENT_HOST = gql`
const COMPONENT_HOST: DocumentNode = gql`
{
getHost {
id # used for GQL caching
Expand Down
6 changes: 3 additions & 3 deletions scopes/component/component/ui/aspect-page/aspect-page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { AspectBox } from '@teambit/harmony.ui.aspect-box';
import React, { useContext } from 'react';
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { gql } from '@apollo/client';
import { useQuery as useDataQuery, DocumentNode } from '@apollo/client';
import { gql } from 'graphql-tag';
import { EmptyBox } from '@teambit/design.ui.empty-box';
import { H1 } from '@teambit/documenter.ui.heading';
import { Separator } from '@teambit/documenter.ui.separator';
import styles from './aspect-page.module.scss';
import { ComponentContext } from '../context';

const GET_COMPONENT = gql`
const GET_COMPONENT: DocumentNode = gql`
query ($id: String!) {
getHost {
get(id: $id) {
Expand Down
2 changes: 1 addition & 1 deletion scopes/component/component/ui/use-component-logs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
import { LegacyComponentLog } from '@teambit/legacy-component-log';
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
import { useQuery as useDataQuery } from '@apollo/client';
import { ComponentLogsResult, Filters } from './use-component.model';
import { GET_COMPONENT_WITH_LOGS } from './use-component.fragments';
import { ComponentError } from './component-error';
Expand Down
Loading