-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for near-operation-file preset (#2099)
* try to fix fragments issues with near-operation-file * fix for prettier * fixes for fragments imports
- Loading branch information
1 parent
ccac3a4
commit 9f27ef9
Showing
14 changed files
with
210 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
schema: | ||
- 'schema.graphql' | ||
documents: | ||
- './src/**/*.graphql' | ||
config: | ||
namingConvention: change-case#pascalCase | ||
withHooks: true | ||
generates: | ||
src/gql/__generated__/types.ts: | ||
- 'typescript' | ||
src/: | ||
preset: near-operation-file | ||
presetConfig: | ||
extension: .generated.tsx | ||
baseTypesPath: gql/__generated__/types.ts | ||
plugins: | ||
- add: /* eslint-disable */ | ||
- typescript-operations | ||
- typescript-react-apollo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
type TypeB { | ||
param1: String | ||
param2: String | ||
} | ||
|
||
type TypeA { | ||
field1: String | ||
field2: String | ||
field3: String | ||
field4: String | ||
field5: String | ||
field6: String | ||
field7: TypeB | ||
} | ||
|
||
type Query { | ||
things: TypeA! | ||
} | ||
|
||
schema { | ||
query: Query | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable */ | ||
import * as Types from '../gql/__generated__/types'; | ||
|
||
import gql from 'graphql-tag'; | ||
export type ComponentA_TypeAFragment = { __typename?: 'TypeA' } & Pick<Types.TypeA, 'field1'>; | ||
export const ComponentA_TypeAFragmentDoc = gql` | ||
fragment ComponentA_TypeA on TypeA { | ||
field1 | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fragment ComponentA_TypeA on TypeA { | ||
field1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable */ | ||
import * as Types from '../gql/__generated__/types'; | ||
|
||
import gql from 'graphql-tag'; | ||
export type ComponentB_TypeBFragment = { __typename?: 'TypeB' } & Pick<Types.TypeB, 'param1' | 'param2'>; | ||
|
||
export type ComponentB_TypeAFragment = { __typename?: 'TypeA' } & Pick<Types.TypeA, 'field3' | 'field4' | 'field5' | 'field6'> & { field7: Types.Maybe<{ __typename?: 'TypeB' } & ComponentB_TypeBFragment> }; | ||
export const ComponentB_TypeBFragmentDoc = gql` | ||
fragment ComponentB_TypeB on TypeB { | ||
param1 | ||
param2 | ||
} | ||
`; | ||
export const ComponentB_TypeAFragmentDoc = gql` | ||
fragment ComponentB_TypeA on TypeA { | ||
field3 | ||
field4 | ||
field5 | ||
field6 | ||
field7 { | ||
...ComponentB_TypeB | ||
} | ||
} | ||
${ComponentB_TypeBFragmentDoc} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
fragment ComponentB_TypeB on TypeB { | ||
param1 | ||
param2 | ||
} | ||
|
||
fragment ComponentB_TypeA on TypeA { | ||
field3 | ||
field4 | ||
field5 | ||
field6 | ||
field7 { | ||
...ComponentB_TypeB | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable */ | ||
import * as Types from './gql/__generated__/types'; | ||
|
||
import { ComponentB_TypeAFragment } from './ComponentB/document.generated'; | ||
import { ComponentA_TypeAFragment } from './ComponentA/document.generated'; | ||
import gql from 'graphql-tag'; | ||
import { ComponentA_TypeAFragmentDoc } from './ComponentA/document.generated'; | ||
import { ComponentB_TypeAFragmentDoc } from './ComponentB/document.generated'; | ||
import * as React from 'react'; | ||
import * as ReactApollo from 'react-apollo'; | ||
import * as ReactApolloHooks from 'react-apollo-hooks'; | ||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
export type ComponentC_FetchThingsQueryVariables = {}; | ||
|
||
export type ComponentC_FetchThingsQuery = { __typename?: 'Query' } & { things: { __typename?: 'TypeA' } & ComponentC_TypeAFragment }; | ||
|
||
export type ComponentC_TypeAFragment = { __typename?: 'TypeA' } & (ComponentA_TypeAFragment & ComponentB_TypeAFragment); | ||
export const ComponentC_TypeAFragmentDoc = gql` | ||
fragment ComponentC_TypeA on TypeA { | ||
...ComponentA_TypeA | ||
...ComponentB_TypeA | ||
} | ||
${ComponentA_TypeAFragmentDoc} | ||
${ComponentB_TypeAFragmentDoc} | ||
`; | ||
export const ComponentC_FetchThingsDocument = gql` | ||
query ComponentC_FetchThings { | ||
things { | ||
...ComponentC_TypeA | ||
} | ||
} | ||
${ComponentC_TypeAFragmentDoc} | ||
`; | ||
export type ComponentC_FetchThingsComponentProps = Omit<ReactApollo.QueryProps<ComponentC_FetchThingsQuery, ComponentC_FetchThingsQueryVariables>, 'query'>; | ||
|
||
export const ComponentC_FetchThingsComponent = (props: ComponentC_FetchThingsComponentProps) => <ReactApollo.Query<ComponentC_FetchThingsQuery, ComponentC_FetchThingsQueryVariables> query={ComponentC_FetchThingsDocument} {...props} />; | ||
|
||
export type ComponentC_FetchThingsProps<TChildProps = {}> = Partial<ReactApollo.DataProps<ComponentC_FetchThingsQuery, ComponentC_FetchThingsQueryVariables>> & TChildProps; | ||
export function withComponentC_FetchThings<TProps, TChildProps = {}>(operationOptions?: ReactApollo.OperationOption<TProps, ComponentC_FetchThingsQuery, ComponentC_FetchThingsQueryVariables, ComponentC_FetchThingsProps<TChildProps>>) { | ||
return ReactApollo.withQuery<TProps, ComponentC_FetchThingsQuery, ComponentC_FetchThingsQueryVariables, ComponentC_FetchThingsProps<TChildProps>>(ComponentC_FetchThingsDocument, { | ||
alias: 'withComponentC_FetchThings', | ||
...operationOptions, | ||
}); | ||
} | ||
|
||
export function useComponentC_FetchThingsQuery(baseOptions?: ReactApolloHooks.QueryHookOptions<ComponentC_FetchThingsQueryVariables>) { | ||
return ReactApolloHooks.useQuery<ComponentC_FetchThingsQuery, ComponentC_FetchThingsQueryVariables>(ComponentC_FetchThingsDocument, baseOptions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
query ComponentC_FetchThings { | ||
things { | ||
...ComponentC_TypeA # We're using it before declare | ||
# Causing self imports and then duplicate declare | ||
} | ||
} | ||
|
||
fragment ComponentC_TypeA on TypeA { | ||
...ComponentA_TypeA | ||
...ComponentB_TypeA # Fragments that this fragment is | ||
# uses are getting imported with no usage. | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters