Skip to content

Commit

Permalink
Fix/stencil one (#2075)
Browse files Browse the repository at this point in the history
* Fix stencil-apollo plugin for stencil-one

* Fix tests

* Update docs

* Do not use functional components

* Support stencil's bundler

* Use general config for fragments
  • Loading branch information
ardatan authored and dotansimha committed Jul 3, 2019
1 parent b5f7fb3 commit 4c60eb9
Show file tree
Hide file tree
Showing 24 changed files with 452 additions and 497 deletions.
8 changes: 6 additions & 2 deletions dev-test/codegen.yml
Expand Up @@ -121,16 +121,20 @@ generates:
- typescript
- typescript-operations
- typescript-stencil-apollo
./dev-test/githunt/types.stencilApollo.class.tsx:
./dev-test/githunt:
schema: ./dev-test/githunt/schema.json
documents: ./dev-test/githunt/**/*.graphql
preset: near-operation-file
presetConfig:
extension: .stencil-component.tsx
baseTypesPath: types.d.ts
plugins:
- add: // tslint:disable
- typescript
- typescript-operations
- typescript-stencil-apollo
config:
componentType: class
globalNamespace: true
./dev-test/star-wars/types.ts:
schema: ./dev-test/star-wars/schema.json
documents: ./dev-test/star-wars/**/*.graphql
Expand Down
42 changes: 42 additions & 0 deletions dev-test/githunt/comment-added.subscription.stencil-component.tsx
@@ -0,0 +1,42 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';
import 'stencil-apollo';
import { Component, Prop, h } from '@stencil/core';

declare global {
export type OnCommentAddedSubscriptionVariables = {
repoFullName: Types.Scalars['String']
};


export type OnCommentAddedSubscription = ({ __typename?: 'Subscription' } & { commentAdded: Types.Maybe<({ __typename?: 'Comment' } & Pick<Types.Comment, 'id' | 'createdAt' | 'content'> & { postedBy: ({ __typename?: 'User' } & Pick<Types.User, 'login' | 'html_url'>) })> });

}


const OnCommentAddedDocument = gql`
subscription onCommentAdded($repoFullName: String!) {
commentAdded(repoFullName: $repoFullName) {
id
postedBy {
login
html_url
}
createdAt
content
}
}
`;

@Component({
tag: 'apollo-on-comment-added'
})
export class OnCommentAddedComponent {
@Prop() renderer: import('stencil-apollo').SubscriptionRenderer<OnCommentAddedSubscription, OnCommentAddedSubscriptionVariables>;
render() {
return <apollo-subscription subscription={ OnCommentAddedDocument } renderer={ this.renderer } />;
}
}

61 changes: 61 additions & 0 deletions dev-test/githunt/comment.query.stencil-component.tsx
@@ -0,0 +1,61 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';
import { CommentsPageCommentFragmentDoc } from './comments-page-comment.fragment.stencil-component';
import 'stencil-apollo';
import { Component, Prop, h } from '@stencil/core';

declare global {
export type CommentQueryVariables = {
repoFullName: Types.Scalars['String'],
limit?: Types.Maybe<Types.Scalars['Int']>,
offset?: Types.Maybe<Types.Scalars['Int']>
};


export type CommentQuery = ({ __typename?: 'Query' } & { currentUser: Types.Maybe<({ __typename?: 'User' } & Pick<Types.User, 'login' | 'html_url'>)>, entry: Types.Maybe<({ __typename?: 'Entry' } & Pick<Types.Entry, 'id' | 'createdAt' | 'commentCount'> & { postedBy: ({ __typename?: 'User' } & Pick<Types.User, 'login' | 'html_url'>), comments: Array<Types.Maybe<({ __typename?: 'Comment' } & CommentsPageCommentFragment)>>, repository: ({ __typename?: 'Repository' } & Pick<Types.Repository, 'full_name' | 'html_url'> & ({ __typename?: 'Repository' } & Pick<Types.Repository, 'description' | 'open_issues_count' | 'stargazers_count'>)) })> });

}


const CommentDocument = gql`
query Comment($repoFullName: String!, $limit: Int, $offset: Int) {
currentUser {
login
html_url
}
entry(repoFullName: $repoFullName) {
id
postedBy {
login
html_url
}
createdAt
comments(limit: $limit, offset: $offset) {
...CommentsPageComment
}
commentCount
repository {
full_name
html_url
... on Repository {
description
open_issues_count
stargazers_count
}
}
}
}
${CommentsPageCommentFragmentDoc}`;

@Component({
tag: 'apollo-comment'
})
export class CommentComponent {
@Prop() renderer: import('stencil-apollo').QueryRenderer<CommentQuery, CommentQueryVariables>;
render() {
return <apollo-query query={ CommentDocument } renderer={ this.renderer } />;
}
}

@@ -0,0 +1,21 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';

declare global {
export type CommentsPageCommentFragment = ({ __typename?: 'Comment' } & Pick<Types.Comment, 'id' | 'createdAt' | 'content'> & { postedBy: ({ __typename?: 'User' } & Pick<Types.User, 'login' | 'html_url'>) });

}

export const CommentsPageCommentFragmentDoc = gql`
fragment CommentsPageComment on Comment {
id
postedBy {
login
html_url
}
createdAt
content
}
`;
35 changes: 35 additions & 0 deletions dev-test/githunt/current-user.query.stencil-component.tsx
@@ -0,0 +1,35 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';
import 'stencil-apollo';
import { Component, Prop, h } from '@stencil/core';

declare global {
export type CurrentUserForProfileQueryVariables = {};


export type CurrentUserForProfileQuery = ({ __typename?: 'Query' } & { currentUser: Types.Maybe<({ __typename?: 'User' } & Pick<Types.User, 'login' | 'avatar_url'>)> });

}


const CurrentUserForProfileDocument = gql`
query CurrentUserForProfile {
currentUser {
login
avatar_url
}
}
`;

@Component({
tag: 'apollo-current-user-for-profile'
})
export class CurrentUserForProfileComponent {
@Prop() renderer: import('stencil-apollo').QueryRenderer<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>;
render() {
return <apollo-query query={ CurrentUserForProfileDocument } renderer={ this.renderer } />;
}
}

28 changes: 28 additions & 0 deletions dev-test/githunt/feed-entry.fragment.stencil-component.tsx
@@ -0,0 +1,28 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';
import { VoteButtonsFragmentDoc } from './vote-buttons.fragment.stencil-component';
import { RepoInfoFragmentDoc } from './repo-info.fragment.stencil-component';

declare global {
export type FeedEntryFragment = ({ __typename?: 'Entry' } & Pick<Types.Entry, 'id' | 'commentCount'> & { repository: ({ __typename?: 'Repository' } & Pick<Types.Repository, 'full_name' | 'html_url'> & { owner: Types.Maybe<({ __typename?: 'User' } & Pick<Types.User, 'avatar_url'>)> }) } & (VoteButtonsFragment & RepoInfoFragment));

}

export const FeedEntryFragmentDoc = gql`
fragment FeedEntry on Entry {
id
commentCount
repository {
full_name
html_url
owner {
avatar_url
}
}
...VoteButtons
...RepoInfo
}
${VoteButtonsFragmentDoc}
${RepoInfoFragmentDoc}`;
44 changes: 44 additions & 0 deletions dev-test/githunt/feed.query.stencil-component.tsx
@@ -0,0 +1,44 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';
import { FeedEntryFragmentDoc } from './feed-entry.fragment.stencil-component';
import { VoteButtonsFragmentDoc } from './vote-buttons.fragment.stencil-component';
import { RepoInfoFragmentDoc } from './repo-info.fragment.stencil-component';
import 'stencil-apollo';
import { Component, Prop, h } from '@stencil/core';

declare global {
export type FeedQueryVariables = {
type: Types.FeedType,
offset?: Types.Maybe<Types.Scalars['Int']>,
limit?: Types.Maybe<Types.Scalars['Int']>
};


export type FeedQuery = ({ __typename?: 'Query' } & { currentUser: Types.Maybe<({ __typename?: 'User' } & Pick<Types.User, 'login'>)>, feed: Types.Maybe<Array<Types.Maybe<({ __typename?: 'Entry' } & FeedEntryFragment)>>> });

}


const FeedDocument = gql`
query Feed($type: FeedType!, $offset: Int, $limit: Int) {
currentUser {
login
}
feed(type: $type, offset: $offset, limit: $limit) {
...FeedEntry
}
}
${FeedEntryFragmentDoc}`;

@Component({
tag: 'apollo-feed'
})
export class FeedComponent {
@Prop() renderer: import('stencil-apollo').QueryRenderer<FeedQuery, FeedQueryVariables>;
render() {
return <apollo-query query={ FeedDocument } renderer={ this.renderer } />;
}
}

36 changes: 36 additions & 0 deletions dev-test/githunt/new-entry.mutation.stencil-component.tsx
@@ -0,0 +1,36 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';
import 'stencil-apollo';
import { Component, Prop, h } from '@stencil/core';

declare global {
export type SubmitRepositoryMutationVariables = {
repoFullName: Types.Scalars['String']
};


export type SubmitRepositoryMutation = ({ __typename?: 'Mutation' } & { submitRepository: Types.Maybe<({ __typename?: 'Entry' } & Pick<Types.Entry, 'createdAt'>)> });

}


const SubmitRepositoryDocument = gql`
mutation submitRepository($repoFullName: String!) {
submitRepository(repoFullName: $repoFullName) {
createdAt
}
}
`;

@Component({
tag: 'apollo-submit-repository'
})
export class SubmitRepositoryComponent {
@Prop() renderer: import('stencil-apollo').MutationRenderer<SubmitRepositoryMutation, SubmitRepositoryMutationVariables>;
render() {
return <apollo-mutation mutation={ SubmitRepositoryDocument } renderer={ this.renderer } />;
}
}

24 changes: 24 additions & 0 deletions dev-test/githunt/repo-info.fragment.stencil-component.tsx
@@ -0,0 +1,24 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';

declare global {
export type RepoInfoFragment = ({ __typename?: 'Entry' } & Pick<Types.Entry, 'createdAt'> & { repository: ({ __typename?: 'Repository' } & Pick<Types.Repository, 'description' | 'stargazers_count' | 'open_issues_count'>), postedBy: ({ __typename?: 'User' } & Pick<Types.User, 'html_url' | 'login'>) });

}

export const RepoInfoFragmentDoc = gql`
fragment RepoInfo on Entry {
createdAt
repository {
description
stargazers_count
open_issues_count
}
postedBy {
html_url
login
}
}
`;
38 changes: 38 additions & 0 deletions dev-test/githunt/submit-comment.mutation.stencil-component.tsx
@@ -0,0 +1,38 @@
// tslint:disable
import * as Types from './types.d';

import gql from 'graphql-tag';
import { CommentsPageCommentFragmentDoc } from './comments-page-comment.fragment.stencil-component';
import 'stencil-apollo';
import { Component, Prop, h } from '@stencil/core';

declare global {
export type SubmitCommentMutationVariables = {
repoFullName: Types.Scalars['String'],
commentContent: Types.Scalars['String']
};


export type SubmitCommentMutation = ({ __typename?: 'Mutation' } & { submitComment: Types.Maybe<({ __typename?: 'Comment' } & CommentsPageCommentFragment)> });

}


const SubmitCommentDocument = gql`
mutation submitComment($repoFullName: String!, $commentContent: String!) {
submitComment(repoFullName: $repoFullName, commentContent: $commentContent) {
...CommentsPageComment
}
}
${CommentsPageCommentFragmentDoc}`;

@Component({
tag: 'apollo-submit-comment'
})
export class SubmitCommentComponent {
@Prop() renderer: import('stencil-apollo').MutationRenderer<SubmitCommentMutation, SubmitCommentMutationVariables>;
render() {
return <apollo-mutation mutation={ SubmitCommentDocument } renderer={ this.renderer } />;
}
}

0 comments on commit 4c60eb9

Please sign in to comment.