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

Make getInputTypeName action work #157

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions dist/actions/action.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export default class Action {
* @param {Data | undefined} variables Variables to send with the mutation
* @param {Function} dispatch Vuex Dispatch method for the model
* @param {Model} model The model this mutation affects.
* @param {string} action Name of the current action like 'persist' or 'push'
* @param {boolean} multiple Tells if we're requesting a single record or multiple.
* @returns {Promise<any>}
*/
protected static mutation(name: string, variables: Data | undefined, dispatch: DispatchFunction, model: Model): Promise<any>;
protected static mutation(name: string, variables: Data | undefined, dispatch: DispatchFunction, model: Model, action: string): Promise<any>;
/**
* Convenience method to get the model from the state.
* @param {RootState} state Vuex state
Expand All @@ -37,13 +38,15 @@ export default class Action {
* @param {Arguments} args
* @param {Model} model
* @param {Data} data
* @param {string} action Name of the current action like 'persist' or 'push'
* @returns {Arguments}
*/
static addRecordToArgs(args: Arguments, model: Model, data: Data): Arguments;
static addRecordToArgs(args: Arguments, model: Model, data: Data, action: string, mutationName: string): Arguments;
/**
* Transforms each field of the args which contains a model.
* @param {Arguments} args
* @param {string} action Name of the current action like 'persist' or 'push'
* @returns {Arguments}
*/
protected static transformArgs(args: Arguments): Arguments;
protected static transformArgs(args: Arguments, action: string): Arguments;
}
2 changes: 1 addition & 1 deletion dist/adapters/adapter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export default interface Adapter {
getConnectionMode(): ConnectionMode;
getArgumentMode(): ArgumentMode;
getFilterTypeName(model: Model): string;
getInputTypeName(model: Model, action?: string): string;
getInputTypeName(model: Model, action?: string, mutation?: string): string;
prepareSchemaTypeName(name: string): string;
}
2 changes: 1 addition & 1 deletion dist/adapters/builtin/default-adapter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class DefaultAdapter implements Adapter {
getConnectionMode(): ConnectionMode;
getArgumentMode(): ArgumentMode;
getFilterTypeName(model: Model): string;
getInputTypeName(model: Model, action?: string): string;
getInputTypeName(model: Model, action?: string, mutation?: string): string;
getNameForDestroy(model: Model): string;
getNameForFetch(model: Model, plural: boolean): string;
getNameForPersist(model: Model): string;
Expand Down
12 changes: 8 additions & 4 deletions dist/graphql/query-builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class QueryBuilder {
* Builds a field for the GraphQL query and a specific model
*
* @param {Model|string} model The model to use
* @param {string} action Name of the current action like 'persist' or 'push'
* @param {boolean} multiple Determines whether plural/nodes syntax or singular syntax is used.
* @param {Arguments} args The args that will be passed to the query field ( user(role: $role) )
* @param {Array<Model>} path The relations in this list are ignored (while traversing relations).
Expand All @@ -20,19 +21,20 @@ export default class QueryBuilder {
*
* @todo Do we need the allowIdFields param?
*/
static buildField(model: Model | string, multiple?: boolean, args?: Arguments, path?: Array<string>, name?: string, filter?: boolean, allowIdFields?: boolean): string;
static buildField(model: Model | string, action: string, multiple?: boolean, args?: Arguments, path?: Array<string>, name?: string, filter?: boolean, allowIdFields?: boolean): string;
/**
* Generates a query.
* Currently only one root field for the query is possible.
* @param {string} type 'mutation' or 'query'
* @param {Model | string} model The model this query or mutation affects. This mainly determines the query fields.
* @param {string} action Name of the current action like 'persist' or 'push'
* @param {string} name Optional name of the query/mutation. Will overwrite the name from the model.
* @param {Arguments} args Arguments for the query
* @param {boolean} multiple Determines if the root query field is a connection or not (will be passed to buildField)
* @param {boolean} filter When true the query arguments are passed via a filter object.
* @returns {any} Whatever gql() returns
*/
static buildQuery(type: string, model: Model | string, name?: string, args?: Arguments, multiple?: boolean, filter?: boolean): import("graphql").DocumentNode;
static buildQuery(type: string, model: Model | string, action: string, name?: string, args?: Arguments, multiple?: boolean, filter?: boolean): import("graphql").DocumentNode;
/**
* Generates the arguments string for a graphql query based on a given map.
*
Expand All @@ -51,14 +53,15 @@ export default class QueryBuilder {
* => 'users(filter: { active: $active })'
*
* @param model
* @param {string} action Name of the current action like 'persist' or 'push'
* @param {Arguments | undefined} args
* @param {boolean} signature When true, then this method generates a query signature instead of key/value pairs
* @param filter
* @param {boolean} allowIdFields If true, ID fields will be included in the arguments list
* @param {GraphQLField} field Optional. The GraphQL mutation or query field
* @returns {String}
*/
static buildArguments(model: Model, args?: Arguments, signature?: boolean, filter?: boolean, allowIdFields?: boolean, field?: GraphQLField | null): string;
static buildArguments(model: Model, action: string, args?: Arguments, signature?: boolean, filter?: boolean, allowIdFields?: boolean, field?: GraphQLField | null): string;
/**
* Determines the GraphQL primitive type of a field in the variables hash by the field type or (when
* the field type is generic attribute) by the variable type.
Expand All @@ -75,8 +78,9 @@ export default class QueryBuilder {
*
* @param {Model} model
* @param {Array<Model>} path
* @param {string} action Name of the current action like 'persist' or 'push'
* @returns {string}
*/
static buildRelationsQuery(model: null | Model, path?: Array<string>): string;
static buildRelationsQuery(model: null | Model, path: string[] | undefined, action: string): string;
private static prepareArguments;
}
9 changes: 7 additions & 2 deletions dist/graphql/transformer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ export default class Transformer {
* @param {Model} model Base model of the mutation/query
* @param {Data} data Data to transform
* @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist.
* @param {string} action Name of the current action like 'persist' or 'push'
* @param {string} mutationName Name of the current mutation like 'ceatePost'
* @param {Array<String>} whitelist of fields
* @param {Map<string, Array<string>>} outgoingRecords List of record IDs that are already added to the
* outgoing data in order to detect recursion.
* @param {boolean} recursiveCall Tells if it's a recursive call.
* @returns {Data}
*/
static transformOutgoingData(model: Model, data: Data, read: boolean, whitelist?: Array<String>, outgoingRecords?: Map<string, Array<string>>, recursiveCall?: boolean): Data;
static transformOutgoingData(model: Model, data: Data, read: boolean, action: string, mutationName: string, whitelist?: Array<String>, outgoingRecords?: Map<string, Array<string>>, recursiveCall?: boolean): Data;
/**
* Transforms a set of incoming data to the format vuex-orm requires.
*
Expand All @@ -34,14 +36,17 @@ export default class Transformer {
* @param {string} fieldName Name of the field to check.
* @param {any} value Value of the field.
* @param {Model} model Model class which contains the field.
* @param {string} action Name of the current action like 'persist' or 'push'
* @param {string} mutationName Name of the current mutation like 'createPost'
* @param {Array<String>|undefined} whitelist Contains a list of fields which should always be included.
* @returns {boolean}
*/
static shouldIncludeOutgoingField(forFilter: boolean, fieldName: string, value: any, model: Model, whitelist?: Array<String>): boolean;
static shouldIncludeOutgoingField(forFilter: boolean, fieldName: string, value: any, model: Model, action: string, mutationName: string, whitelist?: Array<String>): boolean;
/**
* Tells whether a field is in the input type.
* @param {Model} model
* @param {string} fieldName
* @param {string} action Name of the current action like 'persist' or 'push'
*/
private static inputTypeContainsField;
/**
Expand Down
Loading