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

graphql-tools-update | gql-tag preset/plugin | drop node 10 support #6267

Merged
merged 3 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .changeset/shaggy-crews-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-codegen/gql-tag-operations': minor
'@graphql-codegen/gql-tag-operations-preset': minor
---

new plugin/preset gql-tag-operations
56 changes: 56 additions & 0 deletions .changeset/soft-ducks-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
'@graphql-cli/codegen': major
'@graphql-codegen/cli': major
'@graphql-codegen/core': major
'@graphql-codegen/c-sharp': major
'@graphql-codegen/c-sharp-operations': major
'@graphql-codegen/flow': major
'@graphql-codegen/flow-operations': major
'@graphql-codegen/flow-resolvers': major
'@graphql-codegen/java-apollo-android': major
'@graphql-codegen/java-common': major
'@graphql-codegen/java': major
'@graphql-codegen/kotlin': major
'@graphql-codegen/java-resolvers': major
'@graphql-codegen/jsdoc': major
'@graphql-codegen/schema-ast': major
'@graphql-codegen/visitor-plugin-common': major
'@graphql-codegen/typescript-apollo-angular': major
'@graphql-codegen/typescript-apollo-client-helpers': major
'@graphql-codegen/typescript-compatibility': major
'@graphql-codegen/typescript-document-nodes': major
'@graphql-codegen/typescript-enum-array': major
'@graphql-codegen/typescript-generic-sdk': major
'@graphql-codegen/typescript-graphql-request': major
'@graphql-codegen/typescript-mongodb': major
'@graphql-codegen/typescript-oclif': major
'@graphql-codegen/typescript-operations': major
'@graphql-codegen/typescript-react-apollo': major
'@graphql-codegen/typescript-react-offix': major
'@graphql-codegen/typescript-react-query': major
'@graphql-codegen/typescript-resolvers': major
'@graphql-codegen/typescript-rtk-query': major
'@graphql-codegen/typescript-stencil-apollo': major
'@graphql-codegen/typescript-type-graphql': major
'@graphql-codegen/typed-document-node': major
'@graphql-codegen/typescript': major
'@graphql-codegen/typescript-urql': major
'@graphql-codegen/typescript-urql-graphcache': major
'@graphql-codegen/urql-svelte-operations-store': major
'@graphql-codegen/typescript-vue-apollo': major
'@graphql-codegen/typescript-vue-apollo-smart-ops': major
'@graphql-codegen/typescript-vue-urql': major
'@graphql-codegen/graphql-modules-preset': major
'@graphql-codegen/import-types-preset': major
'@graphql-codegen/near-operation-file-preset': major
'@graphql-codegen/plugin-helpers': major
---

Update to latest graphql-tools version.

‼️ ‼️ ‼️ Please note ‼️ ‼️ ‼️:

This is a breaking change since Node 10 is no longer supported in `graphql-tools`, and also no longer supported for Codegen packages.



1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev-test/githunt-invalid/invalid.graphql
12 changes: 10 additions & 2 deletions dev-test/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ generates:
- typescript
./dev-test/githunt/graphql-declared-modules.d.ts:
schema: ./dev-test/githunt/schema.json
documents: ./dev-test/githunt/**/*.graphql
documents:
- ./dev-test/githunt/**/*.graphql
plugins:
- typescript-graphql-files-modules
./dev-test/githunt/typed-document-nodes.ts:
Expand Down Expand Up @@ -245,7 +246,10 @@ generates:
- typescript-urql-graphcache
./dev-test/githunt:
schema: ./dev-test/githunt/schema.json
documents: ./dev-test/githunt/**/*.graphql
documents:
- ./dev-test/githunt/**/*.graphql
- ./dev-test/githunt-invalid/**/*.graphql
- '!./dev-test/githunt-invalid/**/*.graphql'
preset: near-operation-file
presetConfig:
extension: .stencil-component.tsx
Expand Down Expand Up @@ -393,3 +397,7 @@ generates:
gqlImport: graphql-tag
hooksImportFrom: '@apollo/react-hooks'
withMutationFn: false
./dev-test/gql-tag-operations/gql:
schema: ./dev-test/gql-tag-operations/schema.graphql
documents: './dev-test/gql-tag-operations/src/**/*.ts'
preset: gql-tag-operations-preset
1 change: 1 addition & 0 deletions dev-test/githunt-invalid/invalid.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INVALID
184 changes: 184 additions & 0 deletions dev-test/gql-tag-operations/gql/graphql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/* eslint-disable */
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
Date: any;
Url: any;
};

export type Meta = {
__typename?: 'Meta';
count?: Maybe<Scalars['Int']>;
};

export type Mutation = {
__typename?: 'Mutation';
createTweet?: Maybe<Tweet>;
deleteTweet?: Maybe<Tweet>;
markTweetRead?: Maybe<Scalars['Boolean']>;
};

export type MutationCreateTweetArgs = {
body?: Maybe<Scalars['String']>;
};

export type MutationDeleteTweetArgs = {
id: Scalars['ID'];
};

export type MutationMarkTweetReadArgs = {
id: Scalars['ID'];
};

export type Notification = {
__typename?: 'Notification';
id?: Maybe<Scalars['ID']>;
date?: Maybe<Scalars['Date']>;
type?: Maybe<Scalars['String']>;
};

export type Query = {
__typename?: 'Query';
Tweet?: Maybe<Tweet>;
Tweets?: Maybe<Array<Maybe<Tweet>>>;
TweetsMeta?: Maybe<Meta>;
User?: Maybe<User>;
Notifications?: Maybe<Array<Maybe<Notification>>>;
NotificationsMeta?: Maybe<Meta>;
};

export type QueryTweetArgs = {
id: Scalars['ID'];
};

export type QueryTweetsArgs = {
limit?: Maybe<Scalars['Int']>;
skip?: Maybe<Scalars['Int']>;
sort_field?: Maybe<Scalars['String']>;
sort_order?: Maybe<Scalars['String']>;
};

export type QueryUserArgs = {
id: Scalars['ID'];
};

export type QueryNotificationsArgs = {
limit?: Maybe<Scalars['Int']>;
};

export type Stat = {
__typename?: 'Stat';
views?: Maybe<Scalars['Int']>;
likes?: Maybe<Scalars['Int']>;
retweets?: Maybe<Scalars['Int']>;
responses?: Maybe<Scalars['Int']>;
};

export type Tweet = {
__typename?: 'Tweet';
id: Scalars['ID'];
body?: Maybe<Scalars['String']>;
date?: Maybe<Scalars['Date']>;
Author?: Maybe<User>;
Stats?: Maybe<Stat>;
};

export type User = {
__typename?: 'User';
id: Scalars['ID'];
username?: Maybe<Scalars['String']>;
first_name?: Maybe<Scalars['String']>;
last_name?: Maybe<Scalars['String']>;
full_name?: Maybe<Scalars['String']>;
/** @deprecated Field no longer supported */
name?: Maybe<Scalars['String']>;
avatar_url?: Maybe<Scalars['Url']>;
};

export type FooQueryVariables = Exact<{ [key: string]: never }>;

export type FooQuery = { __typename?: 'Query' } & {
Tweets?: Maybe<Array<Maybe<{ __typename?: 'Tweet' } & Pick<Tweet, 'id'>>>>;
};

export type LelFragment = { __typename?: 'Tweet' } & Pick<Tweet, 'id' | 'body'>;

export type BarQueryVariables = Exact<{ [key: string]: never }>;

export type BarQuery = { __typename?: 'Query' } & {
Tweets?: Maybe<Array<Maybe<{ __typename?: 'Tweet' } & LelFragment>>>;
};

export const LelFragmentDoc = {
kind: 'Document',
definitions: [
{
kind: 'FragmentDefinition',
name: { kind: 'Name', value: 'Lel' },
typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Tweet' } },
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
{ kind: 'Field', name: { kind: 'Name', value: 'body' } },
],
},
},
],
} as unknown as DocumentNode<LelFragment, unknown>;
export const FooDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'Foo' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'Tweets' },
selectionSet: {
kind: 'SelectionSet',
selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }],
},
},
],
},
},
],
} as unknown as DocumentNode<FooQuery, FooQueryVariables>;
export const BarDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'Bar' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'Tweets' },
selectionSet: {
kind: 'SelectionSet',
selections: [{ kind: 'FragmentSpread', name: { kind: 'Name', value: 'Lel' } }],
},
},
],
},
},
...LelFragmentDoc.definitions,
],
} as unknown as DocumentNode<BarQuery, BarQueryVariables>;
23 changes: 23 additions & 0 deletions dev-test/gql-tag-operations/gql/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable */
import * as graphql from './graphql';

const documents = {
'\n query Foo {\n Tweets {\n id\n }\n }\n': graphql.FooDocument,
'\n fragment Lel on Tweet {\n id\n body\n }\n': graphql.LelFragmentDoc,
'\n query Bar {\n Tweets {\n ...Lel\n }\n }\n': graphql.BarDocument,
};

export function gql(
source: '\n query Foo {\n Tweets {\n id\n }\n }\n'
): typeof documents['\n query Foo {\n Tweets {\n id\n }\n }\n'];
export function gql(
source: '\n fragment Lel on Tweet {\n id\n body\n }\n'
): typeof documents['\n fragment Lel on Tweet {\n id\n body\n }\n'];
export function gql(
source: '\n query Bar {\n Tweets {\n ...Lel\n }\n }\n'
): typeof documents['\n query Bar {\n Tweets {\n ...Lel\n }\n }\n'];

export function gql(source: string): unknown;
export function gql(source: string) {
return (documents as any)[source] ?? {};
}
52 changes: 52 additions & 0 deletions dev-test/gql-tag-operations/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
scalar Url
scalar Date

type Tweet {
id: ID!
body: String
date: Date
Author: User
Stats: Stat
}

type User {
id: ID!
username: String
first_name: String
last_name: String
full_name: String
name: String @deprecated
avatar_url: Url
}

type Stat {
views: Int
likes: Int
retweets: Int
responses: Int
}

type Notification {
id: ID
date: Date
type: String
}

type Meta {
count: Int
}

type Query {
Tweet(id: ID!): Tweet
Tweets(limit: Int, skip: Int, sort_field: String, sort_order: String): [Tweet]
TweetsMeta: Meta
User(id: ID!): User
Notifications(limit: Int): [Notification]
NotificationsMeta: Meta
}

type Mutation {
createTweet(body: String): Tweet
deleteTweet(id: ID!): Tweet
markTweetRead(id: ID!): Boolean
}
26 changes: 26 additions & 0 deletions dev-test/gql-tag-operations/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import { gql } from '../gql';

const FooQuery = gql(/* GraphQL */ `
query Foo {
Tweets {
id
}
}
`);

const LelFragment = gql(/* GraphQL */ `
fragment Lel on Tweet {
id
body
}
`);

const BarQuery = gql(/* GraphQL */ `
query Bar {
Tweets {
...Lel
}
}
`);
Loading