This file contains hidden or 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
""" | |
creates a virtual field on the entity that may be queried but cannot be set manually through the mappings API. | |
""" | |
directive @derivedFrom(field: String!) on FIELD_DEFINITION | |
""" | |
Marks the GraphQL type as indexable entity. Each type that should be an entity is required to be annotated with this directive. | |
""" | |
directive @entity on OBJECT |
This file contains hidden or 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
async function fetchGraphQL<TResult, TVariables>( | |
operation: TypedDocumentNode<TResult, TVariables>, | |
...[variables]: TVariables extends Record<string, never> ? [] : [TVariables] | |
): Promise<TResult> { | |
const response = await fetch("http://MY-SERVER/graphql", { | |
headers: { | |
'Content-Type': 'application/json', | |
Accept: 'application/json', | |
}, | |
method: 'POST', |
This file contains hidden or 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
schema: PATH_OR_URL_TO_SCHEMA | |
documents: GLOB_EXPRESSION_FOR_OPERATIONS | |
generates: | |
./src/types.ts: | |
plugins: | |
- typescript | |
- typescript-operations |
This file contains hidden or 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
codegen/_graphql.tsx: | |
plugins: | |
- 'typescript' | |
- 'typescript-operations' | |
- 'typescript-resolvers': | |
avoidOptionals: false | |
- 'typescript-react-apollo' | |
config: | |
withHooks: true | |
hooksImportFrom: '@apollo/react-hooks' |
This file contains hidden or 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
overwrite: true | |
schema: schema.graphql | |
documents: "documents/*.graphql" | |
generates: | |
generated/components.tsx: | |
plugins: | |
- typescript | |
- typescript-operations | |
- typescript-react-apollo |
This file contains hidden or 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
{ | |
"name": "java-app", | |
"scripts": { | |
"postinstall": "graphql-codegen" | |
}, | |
"dependencies": { | |
"graphql": "14.2.1", | |
"@graphql-codegen/cli": "1.2.2-beta.0", | |
"@graphql-codegen/java-resolvers": "1.2.2-beta.0" | |
} |
This file contains hidden or 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
package com.java.generated; | |
import com.myapp.models.UserModel; | |
import com.myapp.models.ChatModel; | |
import com.myapp.models.BaseModel; | |
import graphql.schema.TypeResolver; | |
import graphql.schema.DataFetcher; | |
public class Resolvers { | |
public interface Chat { |
This file contains hidden or 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
schema: src/app/resources/schema.graphql | |
generates: | |
src/app/graphql/generated/Resolvers.java: | |
plugins: | |
- java-resolvers | |
config: | |
mappers: | |
User: com.myapp.models.UserModel#UserModel | |
Chat: com.myapp.models.ChatModel#ChatModel | |
Node: com.myapp.models.BaseModel#BaseModel |
This file contains hidden or 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
package com.java.generated; | |
import graphql.schema.TypeResolver; | |
import graphql.schema.DataFetcher; | |
public class Resolvers { | |
public interface Chat { | |
public DataFetcher<Object> id(); | |
public DataFetcher<Iterable<Object>> users(); | |
public DataFetcher<String> title(); |
This file contains hidden or 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
type Query { | |
me: User! | |
} | |
interface Node { | |
id: ID! | |
} | |
type User implements Node { | |
id: ID! |
NewerOlder